Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1483311lqb; Sun, 26 May 2024 03:17:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4EcoJA2NhkBuNnFDrBZW+he4KlmMEfHM4uUlRsc6VVE35n6jlPAIUtAdVF2yxKe+N4SVtPhZnvDjSp1KKTQk3rSlB8YNcFvxNoG0v6A== X-Google-Smtp-Source: AGHT+IGn24W74ngXdx9FEeVUg+fzNTWsOdyyKtAyH6vc+dnTk4PuMJx6LNxsCDdt4I0CGCOLi4Rl X-Received: by 2002:a17:906:1585:b0:a5e:b0a3:ba53 with SMTP id a640c23a62f3a-a62642e0bcdmr381838766b.44.1716718639307; Sun, 26 May 2024 03:17:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716718639; cv=pass; d=google.com; s=arc-20160816; b=spZqYd9jsjrHwPUW8XaNs+DJ7tocLB4AbzbEh+heCuQOJrkoc2eW09MgR0bqmfqMV2 tdNmjvKY66ElESOrzcWLkjYF05zqntI/mGC5jMxd3cCSMEwQXYBPPg7kWVMtJ2+n5OWE a9VfyarHubnxnp7tCSJstytlhnSuYspKinjymOrgkeSgPPuCsUKz7//itsK8T/S+47V2 tY7KcIBVo8Fvea2Dek9A0ZrYBI8nqnpkNjeu4taN6zJ8wl6uWtMnCek4t8/n1PY31JIy 0+OfGNezMv7BbWZ64udoIOV29VBWahXF9cv+Qybdotx8nIUKzEpM133xOIEgsSH+QvG2 FIew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=xbt7jutg35su27PX5Oh7Ji6HQ3QQH3obwhrLdTCRmNg=; fh=rvi8deMiA+mb17pglfjfEW6yJJw2jWEo1iA9yZ2sBdw=; b=dRUqRe1Nu8MCrZHh7LQHfUrhoVH2TxK3OJbg+ECEcqeLRsTAv9djpYoUF6AlEWFASD FxpcLEMZ8vop21lrkiK9/4KmZnnPz8v9WKa5pebxsnPG7HEc7BE8z7G5enrPfIpr8JK8 TziIg+xzf8OXEaao4CTGoVWJu/ZSdpX7ztSTkFyWrc35D/t69LbECqLp7upn8pksipdq WbWr8ADuOSWnd16L1ICJPfsLuk6dmBPlc8pKpniUZwJsFpW02Q7+a0pJGh7C/3EhdpZd yQTIhG+bEgx1BDW8eHwhqae+SDcmSGCqYjbGzxMY3znA76/9dN4VuOFja1CZLnrxnKv6 +s+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gIsCvxAs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189711-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189711-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cd92252si273836966b.769.2024.05.26.03.17.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 03:17:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189711-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gIsCvxAs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189711-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189711-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B97EA1F21CA8 for ; Sun, 26 May 2024 10:17:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 347ECB664; Sun, 26 May 2024 10:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gIsCvxAs" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BFEC1A2C32; Sun, 26 May 2024 10:17:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716718632; cv=none; b=TK83paJzC9exjiY2PuQx88S2kGwcYIj1Pfy7MvK0sv0oojqkrjE72lheqS6QAfhn14/X259NxGOvxjYShRNI8SkOTkx0llK/2GSBG8So0MhuAqL2zhkdOQiGkKwZJA43/fwdh8sKs+I1wTuyvV/1qUtolclGJzo0kyremA9xDAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716718632; c=relaxed/simple; bh=QKjuM6qyhhJojJ3NC+Cer9ULUtQ6PLmygGkAhHO8PFY=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=W7rNBN9fkym5vlv/j5llIay8i0LibjbdiraaIOlMEBN3YdCKJ5mw9s77iZu5zSVp8zYMXgjBQMDbgM8SppR0pqGyoQLt5LIVnBacyAPeDZvlCJri6p3qAxLZSwlotTE7VHSD6pFbC420gHPzDwM/hJf8c3fhyaOeUMutRb/uapU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gIsCvxAs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68FB7C2BD10; Sun, 26 May 2024 10:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716718631; bh=QKjuM6qyhhJojJ3NC+Cer9ULUtQ6PLmygGkAhHO8PFY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gIsCvxAs64g72Z0RyzjJMvqvGss61cn42Obg0UKT9kraQHQKi2FiYa+X+i0c4Az96 Ixaj76lUfJVzxEWSX9XTnWsRh9JKm28tw6SHEIuF/T3s+FamqouIqbwb/P2bL14C+p CG+qiYOW/0aQYwu8YSAVnlftbVXvvDVwYYEEQw2ymHAb5xl4xdOKEveuBCSXv1BPf9 jODMz1r7WukDaoZme7p7uQCvQd3RNv0ZBDerrBKitqC66VkYOPbLicLPp3zlukPqp5 WzqKr+Q2qEBx9teqt2Hg2/5vvEA8rYFxioCjy3efruLcK3ssocvYKnXCA3fPOKUI8P +IxrpKxgfWCOQ== Date: Sun, 26 May 2024 19:17:08 +0900 From: Masami Hiramatsu (Google) To: Carlos =?UTF-8?B?TMOzcGV6?= Cc: linux-trace-kernel@vger.kernel.org, Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Alan Maguire , linux-kernel@vger.kernel.org (open list:TRACING) Subject: Re: [PATCH] tracing/probes: fix error check in parse_btf_field() Message-Id: <20240526191708.860651c915600a535cc2e579@kernel.org> In-Reply-To: <20240525182131.15740-1-clopez@suse.de> References: <20240525182131.15740-1-clopez@suse.de> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sat, 25 May 2024 20:21:32 +0200 Carlos López wrote: > btf_find_struct_member() might return NULL or an error via the > ERR_PTR() macro. However, its caller in parse_btf_field() only checks > for the NULL condition. Fix this by using IS_ERR() and returning the > error up the stack. > Thanks for finding it! I think this requires new error message for error_log file. Can you add the log as trace_probe_log_err(ctx->offset, BTF_ERROR); And define BTF_ERROR in ERRORS@kernel/trace/trace_probe.h ? Thank you, > Fixes: c440adfbe3025 ("tracing/probes: Support BTF based data structure field access") > Signed-off-by: Carlos López > --- > kernel/trace/trace_probe.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c > index 5e263c141574..5417e9712157 100644 > --- a/kernel/trace/trace_probe.c > +++ b/kernel/trace/trace_probe.c > @@ -554,6 +554,8 @@ static int parse_btf_field(char *fieldname, const struct btf_type *type, > anon_offs = 0; > field = btf_find_struct_member(ctx->btf, type, fieldname, > &anon_offs); > + if (IS_ERR(field)) > + return PTR_ERR(field); > if (!field) { > trace_probe_log_err(ctx->offset, NO_BTF_FIELD); > return -ENOENT; > -- > 2.35.3 > -- Masami Hiramatsu (Google)