Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2019959lqb; Mon, 27 May 2024 05:31:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9HFT6oXBhDvwzsr3p/D9reL7HkOfwbPRjw1kuvuk4/G8VszyxEtdd9gk8PiT5AIa7mUPY3UWIVaYXfOiFBdTBswRMc6z9fOCrYcb/+Q== X-Google-Smtp-Source: AGHT+IH8N+TIBLt9nM84qbhhB6O2VsugE23gzeTL9KySwkcE2T0UKQ7HXLVwBS6R/WN4BsDOn2OH X-Received: by 2002:a05:6a00:6c87:b0:6f8:bae3:37b4 with SMTP id d2e1a72fcca58-6f8f2c7041emr9551627b3a.5.1716813116087; Mon, 27 May 2024 05:31:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716813116; cv=pass; d=google.com; s=arc-20160816; b=hJ68mopbQPdYJn8zrMsbu6gHYigAxWkOrP1m0ZdHxJx9pPzkke4poZcsrZftzgdJJd KHyWsBZ3gb+eXNpbO+6pyAL9vZdfxynPgUQw3j4EE9TZ5+KXyg/HJ2JQ9dtMJkOGqdVi Xa/9TWz97enREPXmRexyIm8ozS3FM458kBLAqbFfd0GPuVqekviZF/kN+LTWRLkyC/3o E8+OQESJTLI24mh2wN2cyOe5/lPFWzzK1K644fX8BfZ6ipnxppFob572vEP/jw+CBN44 +dP9kvVjRx5+PitJ01DDTInv3k6ssOgFKOG65/2WQIGVDwUSuExfqqyLVveOPa3vWOsU dS0A== 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=Q4ZCxzxiOm2lxox+J4+1BCwBMx6Eqh/Gho2RIUEw+Q8=; fh=rvi8deMiA+mb17pglfjfEW6yJJw2jWEo1iA9yZ2sBdw=; b=p5DidW/bEHDd+4cqlNqyGsFxGMP7vcfxze6/vLUoea2KtOfhkCUWgwZED8ICRYt+2j QMM88hSvevBHbcUEflmGimwbMaG1NIzjb/snYPlp3qTdmJ51QcjjBDMrzHfZpWdCyxCM YaSpR6v3bJ9lUCNPcTYDUC6vNtRACU2syJ/rgZ5YTa3L7aCCLsbGTB8RE6/ePaFb3dtM x122K6b7F0TjDj1OZsVvwCdqX7W9goM7RLW6ep25166cHYe0Vm/NLCFWUGqAALehtITO VxkadUOfsZZxOtXP6aAQeITlgnTmQw5K2y00n4pUp8Wg2yzOjtTtAAKThWBtcYWGQCcn 7O9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m7EbQaw3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190583-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-68221b758b1si6536821a12.117.2024.05.27.05.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190583-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m7EbQaw3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190583-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190583-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8AFD02842A8 for ; Mon, 27 May 2024 12:31:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EE0C15E5AF; Mon, 27 May 2024 12:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m7EbQaw3" 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 A78B313BC31; Mon, 27 May 2024 12:31:49 +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=1716813109; cv=none; b=VIg+A2riXiOQgRwltsxbdYF+qjdYcusgQr8zPY26qaG2xXM1ox9WkXGH4oM2HazriHTUH1E53aRn0NYUV9qfrYLB8duukkx2jjqd5lEnRRyTEatH5Ut1DaxuxYPS/apNngzU8wMc/6COW/eGPYIWYDGajJrTW9DOXmVDk4AEh1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813109; c=relaxed/simple; bh=dEr1eVERIFIU7dLP++AfOw57CChhj5RmQUdT0i9PbpQ=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=l0Z1Qw9hPYtOhoTwI/kg/YzTg7UrpiTRA6B9UyToo2sM12AE84wyZ+qixoDzl/6ypn0n5Xovo+PVmJlEJQvYsKH65OEM0gPZ8WEpNAL4OID73kGxpgzu2f1f27kQ+F/tnCgc9nOnenOvE4o3vEV3tcOSmFXF9rhtQuULrZPM+jU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m7EbQaw3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7210C32781; Mon, 27 May 2024 12:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716813109; bh=dEr1eVERIFIU7dLP++AfOw57CChhj5RmQUdT0i9PbpQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=m7EbQaw3RNWe6dTQgsJ5YgGu5nsD+jDrZXWjElKDAfKwzRLyn+UwOBJHPXIks6hE7 8KZszY8TvZH5L5c7Av3pJDoOsPHVvw7xtWEUGMYuyb1325vSXAt8lDfmYcIH/aEERn yOdWb9rcUQCGOLPvoPrZCQ13BFfhegTFH3sgdwXKuSq1JoQzyt6vFgBl6wz4hz4wAa mppR0PDSFwE0B9wUyAw7oRF5QpCQ2n3QdbqHYulZHEwlKJglSwP1FhfNBkeVEB794P CaFJt+4xejgJ6yhAEvTmNpYlciJbxuDgAqVuaG2mtQMpcrIRIV/98SVyw+UCKUeeS2 RfuO2/uVyLyiw== Date: Mon, 27 May 2024 21:31:44 +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 v2] tracing/probes: fix error check in parse_btf_field() Message-Id: <20240527213144.1883fcdf4d97d08ea12988bd@kernel.org> In-Reply-To: <20240527094351.15687-1-clopez@suse.de> References: <20240527094351.15687-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 Mon, 27 May 2024 11:43:52 +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 updating! This version looks good to me. Let me pick this to probes/fixes. Thank you, > Fixes: c440adfbe3025 ("tracing/probes: Support BTF based data structure field access") > Signed-off-by: Carlos López > --- > v2: added call to trace_probe_log_err() > > kernel/trace/trace_probe.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c > index 5e263c141574..39877c80d6cb 100644 > --- a/kernel/trace/trace_probe.c > +++ b/kernel/trace/trace_probe.c > @@ -554,6 +554,10 @@ 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)) { > + trace_probe_log_err(ctx->offset, BAD_BTF_TID); > + return PTR_ERR(field); > + } > if (!field) { > trace_probe_log_err(ctx->offset, NO_BTF_FIELD); > return -ENOENT; > -- > 2.35.3 > -- Masami Hiramatsu (Google)