Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp802424rwb; Fri, 18 Nov 2022 08:24:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fazN/DFecM0WobfY7I0kWi6owrEATcPzHRyPqMCTD1mEAw6d6h+y91vkCYV1hS3Wc8ecW X-Received: by 2002:a05:6402:2409:b0:45c:935b:ae15 with SMTP id t9-20020a056402240900b0045c935bae15mr6649885eda.357.1668788699337; Fri, 18 Nov 2022 08:24:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668788699; cv=none; d=google.com; s=arc-20160816; b=0U8loD8BR0X23PlQ4mCYh72HAm7rB4+eUnT5ie+pOxZdraWggLs7nMN+7Wuze4jYHl ilXcVTRqcqzYPe7v/KwVswj7MLWaOn5m6WihCFzIve7qtoqJFEjn6JPdfEI3BRuuazhX X4LrYDce+N+mbMG6qgFjZzAmd9rAJxVru4pmkP7fslAuYc4FOrAltqzrV/TN6HW4ZOGX sf3Cd7pw8VdTcpWjWC1BUcYddywDBeoUZTU0BDitlLrC7ntu31mFnyOmS84j22L4RscE OFfpf7hFPLidKLv3VvmOPHpXFkPvgay5o/M46GIiYylf6Kd0mXrrWVzhA+robNZaj+ez D+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=s1yxFDoRjiPFkkNkNLiE23jlVAVPdPO7eADIHfRd+yg=; b=R18pOi1D1CUwXtYm4lWrjSRp3RfTuh7RLWRqb+4ydXr7GgpaEv+fSAgQRvgGjffJaF 9Wby0yzXV1DPhZcS1OnCpzp9NhdcT5CcMI+Wl0RxyrJD6fOv5PPyn8GvsZQCEcvUV4xU 87kffPkMatuTfiX6ZGKujp9cxEAKLEjx6xlq9N4Vkx3PLd7gF0j26NLfe8MJsJ4SF1Ru LBo5elWmO5Y7wkWbWe5G93Hd7gni55Kl08kuFSDT+JVpVMetfI4rNf3z1D3mPe/kydiU PNMpd1vDduPviSNhHO1zE6sHyBxdW/UgvJoJ7KhmsTjou8neKb+GiM6CzDTykHew6Syg /m3w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di14-20020a170906730e00b007addc76341csi3211958ejc.25.2022.11.18.08.24.26; Fri, 18 Nov 2022 08:24:59 -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 S242036AbiKRQTs (ORCPT + 92 others); Fri, 18 Nov 2022 11:19:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235084AbiKRQTp (ORCPT ); Fri, 18 Nov 2022 11:19:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F766B3AF; Fri, 18 Nov 2022 08:19:44 -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 ams.source.kernel.org (Postfix) with ESMTPS id AC555B8243D; Fri, 18 Nov 2022 16:19:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7428C433C1; Fri, 18 Nov 2022 16:19:41 +0000 (UTC) Date: Fri, 18 Nov 2022 11:19:40 -0500 From: Steven Rostedt To: Rafael Mendonca Cc: Masami Hiramatsu , "Tzvetomir Stoyanov (VMware)" , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Tom Zanussi Subject: Re: [PATCH] tracing/eprobe: Update cond flag before enabling trigger Message-ID: <20221118111940.1268da2b@gandalf.local.home> In-Reply-To: References: <20221116192552.1066630-1-rafaelmendsr@gmail.com> <20221117211726.4bbbb96a@gandalf.local.home> <20221117213109.6119750e@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Fri, 18 Nov 2022 10:34:40 -0300 Rafael Mendonca wrote: > It did not trigger the NULL pointer issue to be more specific. When > creating event probe for all events I was unable to create any event for > the xhci-hcd system: > > root@localhost:/sys/kernel/tracing# echo 'e xhci-hcd/xhci_add_endpoint' > dynamic_events > -bash: echo: write error: Invalid argument > > Debugging the issue it seems that the problem is in the is_good_name() > check, which returns false for "xhci-hcd". Should we sanitize it by Ouch. I didn't realize that. > converting '-' into '_'? Actually, it's just the system name that's an issue. I tested this patch and it appears to work. -- Steve diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 54ee5711c729..a16fb4c9642e 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1955,17 +1955,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; }