From patchwork Wed Nov 8 12:12:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 162995 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp867748vqo; Wed, 8 Nov 2023 04:13:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqDdkO9ZRfLEZ4HZWTaPWt7qzliNx4EctJW9bjTp5iHF9z5AkXn/eAftiH7PUESjKGORWM X-Received: by 2002:a05:6870:1382:b0:1eb:e8b:7206 with SMTP id 2-20020a056870138200b001eb0e8b7206mr1525289oas.14.1699445589272; Wed, 08 Nov 2023 04:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699445589; cv=none; d=google.com; s=arc-20160816; b=oElq/B/eG+dBnZ3JGVaPIPb8Otr+I9ohwG5rX27oqJe33sxrLBWOA0/ojdlH/kjbJI 5tHmJSBJiXYehmbVBrYYVLglaSiRH148noXtbK+QKhDDuu0XlqiTScxDD4aeVVH4x0y9 /tHk+MzJlhVUSW4golE1VnrabMqM18W4kZHXV82iNIxdLrMnPzhP3tx9m3oZueYNr0UM NoS+Yycgaoy6HN6Mini0B+zx8bFHr1MQ6rd4ltr5MUkif1H07qxFp/lLGDdU9pvPWWvX gwmkTAS+6ZUmZgp0Oe3YhtQSZyz4MAun2qyoG08UwU9yCKGok+c3i3pQZGwALXxaEutF jjxw== 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 :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=Vi5h78jbIq43EmSFRdXtjKWG5W/rSeZPP8sA+YqMx7Q=; fh=5bIR2BA3b4kEVsG3/1DGxfXTklUQr/q6tGBdJQraBnw=; b=V3W3sqXZz9JQrfBftYQ76JRC9uGyGuj6DfjNk/zmcRaXvLaoU7d3B3FVxtxRLJb/kI lI4FAlSEMLX1KGg7nPPNueSs9Wg7LYumH/gPDXghC0IwrmfzhFiyJVNy70s75igrRVrf QaaZTJwadB/Kpmor1f3ZAyuo37f3VeLUhHBn4E+o6BR9WA4IEAU1NurRNmagacbTZWxi t6Arc57fW3YxSTmGUSzCGuM3E/YaOb7k3oOli7ldMhUi468EDgHvOcFvNFbZBnSE1+1R 3+l2laDRREqeRnDw5wBqDhDU9L95+vvLmTJLKiQDINB04N/Daa4VYrwdxy7jRaAFUhgE A8BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lg2khy5V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a7-20020a634d07000000b00573fa8f2829si4648378pgb.383.2023.11.08.04.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 04:13:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lg2khy5V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CBE14825F1F1; Wed, 8 Nov 2023 04:13:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231611AbjKHMMr (ORCPT + 32 others); Wed, 8 Nov 2023 07:12:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbjKHMMq (ORCPT ); Wed, 8 Nov 2023 07:12:46 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065351BDA for ; Wed, 8 Nov 2023 04:12:44 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AD7CC433C7; Wed, 8 Nov 2023 12:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699445563; bh=+eAilYuOk3JTzvBWmWCHjKEGTbGwH1VoT0du41XzHkM=; h=From:To:Cc:Subject:Date:From; b=Lg2khy5VnTr4hSSQFTnp+3EWklP0+zB3gDr9gj4Z/o6SJ8jxiIkoJTPtJsFnegZNp anTnF8Dwd1+Mi7zOx4cYvm7Cx3jygIRIXrNj6EyYPvffOWhu3Yg2g5yBwOWzr1aSzx nYnpUKOSGjWocux6Q9xKVeRq4IPqJoOS4GUkVgS3uytaz9ftdkDY8S1d2pC2GuuVJW UWm2A2K1/wxL82pIAh6VuiO23NFwXxZ/7aNOqagpv08GHxOTlklRP7GaH5aJQPzk0f jFkViraw267rOfbFY1OecCtZXdfsAseSRzmSD9ZEdY/RNuVYnkZrKS/G9YGxubif9k Fi7qz5ArBZzzQ== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org, Steven Rostedt Cc: linux-kernel@vger.kernel.org, mhiramat@kernel.org Subject: [PATCH v2] tracing: fprobe-event: Fix to check tracepoint event and return Date: Wed, 8 Nov 2023 21:12:39 +0900 Message-Id: <169944555933.45057.12831706585287704173.stgit@devnote2> X-Mailer: git-send-email 2.34.1 User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 08 Nov 2023 04:13:01 -0800 (PST) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781559559028366995 X-GMAIL-MSGID: 1781997858163391576 From: Masami Hiramatsu (Google) Fix to check the tracepoint event is not valid with $retval. The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval") introduced automatic return probe conversion with $retval. But since tracepoint event does not support return probe, $retval is not acceptable. Without this fix, ftracetest, tprobe_syntax_errors.tc fails; [22] Tracepoint probe event parser error log check [FAIL] ---- # tail 22-tprobe_syntax_errors.tc-log.mRKroL + ftrace_errlog_check trace_fprobe t kfree ^$retval dynamic_events + printf %s t kfree + wc -c + pos=8 + printf %s t kfree ^$retval + tr -d ^ + command=t kfree $retval + echo Test command: t kfree $retval Test command: t kfree $retval + echo ---- So 't kfree $retval' should fail (tracepoint doesn't support return probe) but passed it. Fixes: 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - update the patch description to show what test fails. --- kernel/trace/trace_fprobe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c index 8bfe23af9c73..7d2ddbcfa377 100644 --- a/kernel/trace/trace_fprobe.c +++ b/kernel/trace/trace_fprobe.c @@ -927,11 +927,12 @@ static int parse_symbol_and_return(int argc, const char *argv[], for (i = 2; i < argc; i++) { tmp = strstr(argv[i], "$retval"); if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') { + if (is_tracepoint) { + trace_probe_log_set_index(i); + trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE); + return -EINVAL; + } *is_return = true; - /* - * NOTE: Don't check is_tracepoint here, because it will - * be checked when the argument is parsed. - */ break; } }