Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp562428rdh; Wed, 14 Feb 2024 05:22:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXum+dX5qkh8MqYtA8dwZqguJfhrzf+hQAgaDou1rlbUWNfSXlwfa+qcHXRJ4hITfvNoTGGuHU8G12dr2ozC85lj12IVucKDWfj7QuLVw== X-Google-Smtp-Source: AGHT+IEHd6QH9rrYbuHUMEDaysH1Ge7nPxt1JFpVpUQdD4sSkqwgdvWLcRPWtEUAplemTs8gMQ3A X-Received: by 2002:a05:6512:2211:b0:511:ac21:57db with SMTP id h17-20020a056512221100b00511ac2157dbmr1129224lfu.0.1707916976190; Wed, 14 Feb 2024 05:22:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707916976; cv=pass; d=google.com; s=arc-20160816; b=wu40xdt7tQMFsTpPK2Fu2XQXqUHyM0P+rthz1yEBnB0PHdoK3D2OIW8cV+kjJGVb5I 4SpFiJNTevB26Spwi0Rs6FDf1Aa/trW2GFItz5l/0fvKzYn1Mbn7+Un0za4W0an+Iq/2 /2WTkXhQmE95sdPi7W2Ow+HtYhGyXAxTyFuPOk0jUaG4bsxr6+a2Fci6O4DSCEdA5YcF w+G1sSR9spiTIsHTpc8kwKZk/+pjJxYzIbawkb9JK/NnvRcDpPvx2kIBG/IccM9Y2tJR 5l4B3KWFc1y7xMP3P9OKf00D0d3mDwYwtN5QnEHWhhcHeLOv+delGUy0IAHa+0ln897O KOhw== 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:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Hi5TdHCU92m/Da3Q9M581ex8WENc3t14/Yipn4BIVCE=; fh=EZ9jIQob1JReU7WzRRGCjDtUoIvSkq4P1UUPgabHLak=; b=IX0eFKRlvl/uc6sPg0CNA5niTNota1/TJWAeYi49/OC3urFcRR3AXrhK07WxUN95JZ 30DJw9ubYVj84CZ79N0t6xXlvUNWigqxA/UyzhVQ8HnYr/rg/ing5EpEj7zki3IoxPK4 QP+Id5L5UxxD3yTVOgQiQyBZ6f8NX7ztHLxiZb3b05DdlR0BUrqpHmTS8O9kWWUTaMUB r2RszJlyfy4DyUtaPPfSexpBwDjCzsHQIItZeMRjcrBQYCaezj9KfbrzM7qRkPY6SJhJ BCeY/SLwXv4SWHxJ3NRT059HmZtiAreocpJT/05pM1IpooHm7DziPzPWoN8758f0JpUy eCSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KhlP+mtw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65267-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65267-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCU/OFqzRmdcyRU+WhdYpZUMCBZZHLDWpBcjU22PX0l75dAs7ZIKPjtVQ4tRbns7iSlyvqExEity/YQ86LoCVBH9berqlm7CylT6k1wnsg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d14-20020a056402078e00b0056289a3709fsi697031edy.380.2024.02.14.05.22.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:22:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65267-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=KhlP+mtw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65267-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65267-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 C986B1F22069 for ; Wed, 14 Feb 2024 13:22:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7A0A54BC4; Wed, 14 Feb 2024 13:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KhlP+mtw" 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 EFC7754670; Wed, 14 Feb 2024 13:22:27 +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=1707916948; cv=none; b=KSvdU+fsRkmncM0lJZHgBxD9835P8RrjGeJQKTt5mUNQgM1XQCNNYERzxprzGdHK0Yw3DlRWTaqov9dbhX8gJUvJTNtFFTUF38z0SAxs1DZxjzFTlwFQXxmXHNaVMUUJF3RMIjzgQLze+5cB8F4qFMpBQJ9rX/D/5d735yiCzo0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707916948; c=relaxed/simple; bh=VG0MktVwabnUwipPLIf3jQPx5AW1d8Ms9iB0R5HsZLM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=DpK0buTCf2ZXq4VtVWJJ20nvMQYAyCTk4KbU47unmgScskGHtmPCJy8edS3mCexj5HD+1ASoVfj3f+gTiJxuD7qzMVJuweIkVTQcpi5plZ5DPymYu0trzya1DLUGgFdfpPh5mecgkVA0MPC3zu5XAKH1pRsFmllmRTLY3faGikM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KhlP+mtw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60B9DC433F1; Wed, 14 Feb 2024 13:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707916947; bh=VG0MktVwabnUwipPLIf3jQPx5AW1d8Ms9iB0R5HsZLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhlP+mtw5Bf4V+dPyp3lg0cekg2L2ynWetLOiRWpvw9Abm+7ips+UHJ7N2BI6Sl71 FdarhNIIPmOPBISl3ZDC0DFRfXj+xWD1UKSdsNj4522KYs4QZ+GT7Zp8O5E0UDbFDS qHxEWBTEqRlU78XLQkqvE0fD3p2zSZ+fhoTjodO4V8KLzL93rOvevt6CgwE3hpwA4Q Q5R89ZDItmQW/IL2L8cJwPrGn+xWPIIYTCxuq0R0JCDJ8tIHqzPbnFUW8RSHeZrrI6 hmSB8tFbE7JvC8xjOOoKqdTSUbkdPvhT+85hYdY3tHBKqYgEDY+dofCHR4UKJ7dzp0 uTzQMvb3K+uog== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , mhiramat@kernel.org Subject: [PATCH RFC 1/5] tracing/probes: Fix to search structure fields correctly Date: Wed, 14 Feb 2024 22:22:23 +0900 Message-Id: <170791694361.389532.10047514554799419688.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170791693437.389532.6816883363982512874.stgit@devnote2> References: <170791693437.389532.6816883363982512874.stgit@devnote2> User-Agent: StGit/0.19 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 From: Masami Hiramatsu (Google) Fix to search a field from the structure which has anonymous union correctly. Since the reference `type` pointer was updated in the loop, the search loop suddenly aborted where it hits an anonymous union. Thus it can not find the field after the anonymous union. This avoids updating the cursor `type` pointer in the loop. Fixes: 302db0f5b3d8 ("tracing/probes: Add a function to search a member of a struct/union") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_btf.c b/kernel/trace/trace_btf.c index ca224d53bfdc..5bbdbcbbde3c 100644 --- a/kernel/trace/trace_btf.c +++ b/kernel/trace/trace_btf.c @@ -91,8 +91,8 @@ const struct btf_member *btf_find_struct_member(struct btf *btf, for_each_member(i, type, member) { if (!member->name_off) { /* Anonymous union/struct: push it for later use */ - type = btf_type_skip_modifiers(btf, member->type, &tid); - if (type && top < BTF_ANON_STACK_MAX) { + if (btf_type_skip_modifiers(btf, member->type, &tid) && + top < BTF_ANON_STACK_MAX) { anon_stack[top].tid = tid; anon_stack[top++].offset = cur_offset + member->offset;