From patchwork Tue Jul 25 01:37:19 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: 125258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2170269vqg; Mon, 24 Jul 2023 18:48:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlFXcQ+JiOEip0XS9b67DF2XpHv875iIBSKnjgGuKjceMANWPGbMVmh1F1vA83dp6BqWAkNf X-Received: by 2002:a17:902:a3cb:b0:1a9:40d5:b0ae with SMTP id q11-20020a170902a3cb00b001a940d5b0aemr7854023plb.12.1690249722411; Mon, 24 Jul 2023 18:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690249722; cv=none; d=google.com; s=arc-20160816; b=P6C0zBBw2g296UAv5wlSmLu2P7IoWlvCw4/WR9mmlWdlkYTkSCFqCPfUP0/g4WopYX bxHAqpEPCwh5OFg8j7ZlLffi09LxUUoMhZGNT/nIk3PtKIFLt13VkJyBAOwEp7VCLniD Gdo1L5wl4bTea/fCGr03+uRb/f1sf7dXSFlQ2ipkVMvgfdFPLft20a1Hym/4YIoQjK/I 5ug8Q+8vzIeAglI+RM15S7KPPH9BmNvrogVP9v7VEvAZM/p0likGbCCNOMTQN7WQFNeR 92Ba8U+Ay+awloq5RqFkFkeUSqQxzMkZ4+WuzR5tt0EUILrxm9JxE3EV9Tnxe7Ix/Hge v86Q== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=221AuPrxEU7Y2mxIJy9+juYs/FAEOCYzboeUOsLdKB4=; fh=Fqd6DmBBbnJ31dnFa0sLTxQwyplx7sPTJZpWe9yucIo=; b=dZyOImyd6XDn2+oiJxUqICKEEGwao62KuESWE5zMFZfdyFIUtPePwukFqkl2lVugMc C4syWXEFPxZ87k4SXm95kc6dnFqVAHnPkq4npVcmUxUeENVKzUxOzLlMn1HcI3Vfaf+J W809CL4lD27jSlVnmhEnwtIgXfqUAACHIO/jRc4dGXZ+SWQhYICke2R9vxcgcsQLOuPZ 6M5i7vh6SS1oj6Mx2VHGBit+wmSPwP2xJhGFeEgoroz+YVvaAKJuhKB+rgwKQgzycMi+ OjawmLh69OXbxJZagx6o3pz/I5f+Dnw1GpI0MD2800yEhO23ADhco35YxXLc3Uqr++TA Nk1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="EEj/E2My"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a170903230b00b001b7e5ed70d4si11131810plh.440.2023.07.24.18.48.29; Mon, 24 Jul 2023 18:48:42 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="EEj/E2My"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbjGYBh3 (ORCPT + 99 others); Mon, 24 Jul 2023 21:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbjGYBh1 (ORCPT ); Mon, 24 Jul 2023 21:37:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E643B1999; Mon, 24 Jul 2023 18:37:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 43764614B3; Tue, 25 Jul 2023 01:37:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52EE7C433C8; Tue, 25 Jul 2023 01:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690249043; bh=cvdO36sarOiv5ZpCKU2EQAmrbByydT2MCd5DqCQtaFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EEj/E2Mycd/XZbLGupp5s+8D92HNLgkPGx5U4N1chxUQYnai33YzObkt0amlp6B5g Ccu4gS6hmfSEnEnoCCTJ2m6mhb4w0wt5gapkbjqMlQSz4zQECibfcPbnXBk34qI9hi MrPgmNDygVn0NQP+YjXvJemZFfaW6FCLq4WeeHIjsxB1sNIWcpBjnrBI81vyYInpdI q4KBDxS9zjz5kXljewbBOaqQ6X/BJh/GugFqBjtdez7ENbLrQ+vFI81LdXKpX+yG4t /i0dsNR6DrOLctEOWzhwbq4Vp8tVU11WPr9t5GuNaTkItt6VQccBZFxBxaDdKTGo6L m9k+H632j2L4g== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org, Steven Rostedt Cc: linux-kernel@vger.kernel.org, mhiramat@kernel.org Subject: [PATCH 1/2] tracing/probes: Fix to add NULL check for BTF APIs Date: Tue, 25 Jul 2023 10:37:19 +0900 Message-Id: <169024903951.395371.11361556840733470934.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <169024903018.395371.1006584451160707296.stgit@devnote2> References: <169024903018.395371.1006584451160707296.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1772355293152877008 X-GMAIL-MSGID: 1772355293152877008 From: Masami Hiramatsu (Google) Since find_btf_func_param() abd btf_type_by_id() can return NULL, the caller must check the return value correctly. Fixes: b576e09701c7 ("tracing/probes: Support function parameters if BTF is available") Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_probe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index b2b726bea1f9..c68a72707852 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -386,12 +386,12 @@ static const struct btf_type *find_btf_func_proto(const char *funcname) /* Get BTF_KIND_FUNC type */ t = btf_type_by_id(btf, id); - if (!btf_type_is_func(t)) + if (!t || !btf_type_is_func(t)) return ERR_PTR(-ENOENT); /* The type of BTF_KIND_FUNC is BTF_KIND_FUNC_PROTO */ t = btf_type_by_id(btf, t->type); - if (!btf_type_is_func_proto(t)) + if (!t || !btf_type_is_func_proto(t)) return ERR_PTR(-ENOENT); return t; @@ -443,7 +443,7 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code, if (!ctx->params) { params = find_btf_func_param(ctx->funcname, &ctx->nr_params, ctx->flags & TPARG_FL_TPOINT); - if (IS_ERR(params)) { + if (IS_ERR_OR_NULL(params)) { trace_probe_log_err(ctx->offset, NO_BTF_ENTRY); return PTR_ERR(params); } @@ -1273,7 +1273,7 @@ const char **traceprobe_expand_meta_args(int argc, const char *argv[], params = find_btf_func_param(ctx->funcname, &nr_params, ctx->flags & TPARG_FL_TPOINT); - if (IS_ERR(params)) { + if (IS_ERR_OR_NULL(params)) { if (args_idx != -1) { /* $arg* requires BTF info */ trace_probe_log_err(0, NOSUP_BTFARG); From patchwork Tue Jul 25 01:37:29 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: 125261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2176628vqg; Mon, 24 Jul 2023 19:05:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlF4AvGuOFQPaMwDVi9Ks/wjdCkTQgpzssD4oML+b2gyEPlAQm15kP5+lUJ+dQdW/4Vk/n1q X-Received: by 2002:a17:906:3154:b0:993:f9d4:eab3 with SMTP id e20-20020a170906315400b00993f9d4eab3mr11633805eje.18.1690250737248; Mon, 24 Jul 2023 19:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690250737; cv=none; d=google.com; s=arc-20160816; b=LjI86mAL8tJeh4yfkgnAM90clEPsnkRUMWba9t+86JqsrHKMHy8byOJRf/Pthqe8bA cYWdm28w5DlNYugID8LhiSIXQZfnKf46TrMwL+yR87e8miCYsQGqeLRYOCpc4dVOQf29 DqZjZ2h60JyfX7dCIYkGaPfxK6Z1zl6LQaiVlfCsfp1d2seLOdPE7ebcgzbuOmhsb8Py DqJEDrSdeSLx3cLSSYlO/qNmuMZ3h+hhy2/56yUMCL3w2y9PI/+duFwhU2AOBVouENTG veFVyJc4U2HHgiM4Kfvjr7ZlxFSDLhzzqFUPDHyrbbP9QS1CzMa5/LvAKZkEkeR7MxjO DqxA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cOSgwz/83Qbem09hY2NZDmPfz5LC+06Ixh+07V9GpLI=; fh=Fqd6DmBBbnJ31dnFa0sLTxQwyplx7sPTJZpWe9yucIo=; b=a8LtiikEKA+4wuMzw2gSzLqHDbTuourNiv9bzB+sSc73cDbQPtnfgViBt2KEqIWETg 3m6o49Uho8pDjhRD8i0HSi8aDIAc0DAtDzy73Qi6ktblConqTONSFAvcnPqqdbWLwsmH 0KuRbeJmNVwnmw5fdoW2pXLVm3IZ+01t80ECuDyx1GeNGSwapF7Dxld7cpNBpmNgiaML +/PPBgI+DRY/1bzyO6cSwjhMnOiNaH/G5Sum5aqUiwO4sQgIBQCcwN9oqOR6YC21yIg/ nyFdNhpmdDpgK7uvXwExJ+DLAmmaT6KZmnGbPXSIiUUI9W/4SLEFftsi/MVu8NpVLTqH EfzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MkywLUpT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a1709062c0100b0099027b40d82si7173193ejh.243.2023.07.24.19.05.13; Mon, 24 Jul 2023 19:05:37 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MkywLUpT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbjGYBhs (ORCPT + 99 others); Mon, 24 Jul 2023 21:37:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbjGYBho (ORCPT ); Mon, 24 Jul 2023 21:37:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 633341737; Mon, 24 Jul 2023 18:37:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ABECB614A0; Tue, 25 Jul 2023 01:37:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2A2BC433C7; Tue, 25 Jul 2023 01:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690249052; bh=56b5kXnejQjCHe2JxyM6/FN8IqjBfg03Kg+93ShB/SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MkywLUpT5IUmYfg5rewkx3z978JM7HselXR+8lyXsG/PnXfRLEAmSjTM1hReDqYZQ 9dc3lkl/WKKd6WKw5jvvQHfroBXPP0VWBeP/n5KHyYhfAT+8NyDOih24HtUswm6RUc 4UHlOBcJwEK3KMC/rg9lyU0stJB9AV8H0JL0Rymb8cB9PPAa1cGl61kZ5SLwbKH0Ry z+lBBTxgA/T82UAxeEO73nf6VH53eXWplyYJMxxd1hH7HjTq45jyX5A/j679LyR0oH 6qeTw8CMFjoUauN4IXMytDNyGxbOAyXNFU1fS2FDVrXm5uGb3snWMRUMSdcgB5uH6h 9ptCSgLHOeLqg== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org, Steven Rostedt Cc: linux-kernel@vger.kernel.org, mhiramat@kernel.org Subject: [PATCH 2/2] selftests/ftrace: Fix to check fprobe event eneblement Date: Tue, 25 Jul 2023 10:37:29 +0900 Message-Id: <169024904889.395371.17998733386857387118.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <169024903018.395371.1006584451160707296.stgit@devnote2> References: <169024903018.395371.1006584451160707296.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1772356357343763612 X-GMAIL-MSGID: 1772356357343763612 From: Masami Hiramatsu (Google) Fix to check the availability of fprobe and kprobes for add_remove_btfarg.tc. Only if both kprobe and fprobe are not supported, it should return "unsupported". Signed-off-by: Masami Hiramatsu (Google) --- .../ftrace/test.d/dynevent/add_remove_btfarg.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc index b89de1771655..f34b14ef9781 100644 --- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_btfarg.tc @@ -13,7 +13,7 @@ if grep -qF "f[:[/][]] [%return] []" README ; the FPROBES=yes fi -if [ -z "$KPROBES" -a "$FPROBES" ] ; then +if [ -z "$KPROBES" -a -z "$FPROBES" ] ; then exit_unsupported fi