From patchwork Sat Dec 10 13:58:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 32029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1327740wrr; Sat, 10 Dec 2022 06:04:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5m3O/cBusooGiq8wNKM0pt41f3VjaxGlH4bZ5rcsogdf+FMB6KGWOnCaLNudaBULKgfFpx X-Received: by 2002:a05:6402:538a:b0:468:ccfb:bed4 with SMTP id ew10-20020a056402538a00b00468ccfbbed4mr7485276edb.28.1670680817894; Sat, 10 Dec 2022 06:00:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670680817; cv=none; d=google.com; s=arc-20160816; b=oyNvshcgyZy5Yj5gEDcwEb8ZmifOS4S/cM4ix9sQc5aRCXpNEQ0xbkhHLg6RpiN09h I22R5rzt0P8d1uhJVKsmRr+bsZWZdnSGU2sNSYZVyE1z8palj/xXxKAQP2CV6NbV5pgP tFR/3mFHHtCE5qpUN9s5I/BUaF/qPOZ8CwuWsu59uiR2It6WWHJ00PEYFKO+4IqszmN4 bV2+KUjW2N9Meh9tK3KLmMU7SSpS1ZJHFIECR3OhpqlWZnj7ArKOE5mMZ7RE8b/leDdl p1eOeghPDb55rSr53WjlCpPn5yzjCwC8g3S9WNAQN+C+IbwH4J19sLlVFLqcBMfsHR6A f4VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=zwyzyq3VPNcFfY8PVPeV0L5j89FChBswFbbWcXIV6rc=; b=wflSd6Lawx7ck+H/KduVqWKVPjewnmjksT1R9XC8XkW16XfrWKxWPdHMbeXA/ogDKh QtX14NZv0Hir+LYnJ73+g1gyS0ucF7T1G+TXXUKxoagTXvh92Y6pwTNq3lbthr5BkhBK UqZMECoYyWWfOE7mu70W4M6DPWB9Ngjsh1w0khkDd8iIthtAEL7h1PnLcvB3LKV4Fg04 TyVLKWxqWgP85Et6Ji/SUZheU4/90O9B+9o20iKTjg0sU351kwBgzNjey/9fiIHMYDjl BphEeb4LXcslR0PEtoC5zAEYSxgvuzLrbzemkq8Kab4emijYrZJqq7/Aw6Fky5skL6S6 axjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020aa7df10000000b0046c33d9ea8csi3266367edy.599.2022.12.10.05.59.54; Sat, 10 Dec 2022 06:00:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbiLJN6y (ORCPT + 99 others); Sat, 10 Dec 2022 08:58:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbiLJN61 (ORCPT ); Sat, 10 Dec 2022 08:58:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2CC6275; Sat, 10 Dec 2022 05:58:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6FD6560C21; Sat, 10 Dec 2022 13:58:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D709EC43445; Sat, 10 Dec 2022 13:58:25 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1p40My-000kpL-2w; Sat, 10 Dec 2022 08:58:24 -0500 Message-ID: <20221210135824.775707099@goodmis.org> User-Agent: quilt/0.66 Date: Sat, 10 Dec 2022 08:58:00 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , stable@vger.kernel.org, Rafael Mendonca Subject: [for-next][PATCH 10/25] tracing/probes: Handle system names with hyphens References: <20221210135750.425719934@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751835809229483990?= X-GMAIL-MSGID: =?utf-8?q?1751835809229483990?= From: "Steven Rostedt (Google)" When creating probe names, a check is done to make sure it matches basic C standard variable naming standards. Basically, starts with alphabetic or underline, and then the rest of the characters have alpha-numeric or underline in them. But system names do not have any true naming conventions, as they are created by the TRACE_SYSTEM macro and nothing tests to see what they are. The "xhci-hcd" trace events has a '-' in the system name. When trying to attach a eprobe to one of these trace points, it fails because the system name does not follow the variable naming convention because of the hyphen, and the eprobe checks fail on this. Allow hyphens in the system name so that eprobes can attach to the "xhci-hcd" trace events. Link: https://lore.kernel.org/all/Y3eJ8GiGnEvVd8%2FN@macondo/ Link: https://lore.kernel.org/linux-trace-kernel/20221122122345.160f5077@gandalf.local.home Cc: Masami Hiramatsu Cc: stable@vger.kernel.org Fixes: 5b7a96220900e ("tracing/probe: Check event/group naming rule at parsing") Reported-by: Rafael Mendonca Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.h | 19 ++++++++++++++++--- kernel/trace/trace_probe.c | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 48643f07bc01..8f37ff032b4f 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1954,17 +1954,30 @@ static __always_inline void trace_iterator_reset(struct trace_iterator *iter) } /* Check the name is good for event/group/fields */ -static inline bool is_good_name(const char *name) +static inline bool __is_good_name(const char *name, bool hash_ok) { - if (!isalpha(*name) && *name != '_') + if (!isalpha(*name) && *name != '_' && (!hash_ok || *name != '-')) return false; while (*++name != '\0') { - if (!isalpha(*name) && !isdigit(*name) && *name != '_') + if (!isalpha(*name) && !isdigit(*name) && *name != '_' && + (!hash_ok || *name != '-')) return false; } return true; } +/* Check the name is good for event/group/fields */ +static inline bool is_good_name(const char *name) +{ + return __is_good_name(name, false); +} + +/* Check the name is good for system */ +static inline bool is_good_system_name(const char *name) +{ + return __is_good_name(name, true); +} + /* Convert certain expected symbols into '_' when generating event names */ static inline void sanitize_event_name(char *name) { diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 36dff277de46..bb2f95d7175c 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -246,7 +246,7 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup, return -EINVAL; } strlcpy(buf, event, slash - event + 1); - if (!is_good_name(buf)) { + if (!is_good_system_name(buf)) { trace_probe_log_err(offset, BAD_GROUP_NAME); return -EINVAL; }