From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v10 11/11] tracing/wprobe: Support BTF typecast in wprobe trigger command
Date: Wed, 22 Jul 2026 23:31:04 +0000 [thread overview]
Message-ID: <20260722233104.70A9E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <178476147632.26117.14371948325944867725.stgit@devnote2>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect BTF kflag check in get_offset_of_field() falsely rejects nested structs and computes massive out-of-bounds offsets for bitfield members.
--
--- Patch [11]: [PATCH v10 11/11] tracing/wprobe: Support BTF typecast in wprobe trigger command ---
commit 61f26bb67fea52d49bbb314e0a53092298348830
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
tracing/wprobe: Support BTF typecast in wprobe trigger command
This commit extends the set_wprobe trigger syntax to support automatic
BTF-based offset calculation. It allows symbolic watchpoint placement at
specific struct fields by resolving the offset of a member within a struct
type using BTF, avoiding the need for manual numeric offsets.
> diff --git a/kernel/trace/trace_wprobe.c b/kernel/trace/trace_wprobe.c
> index 1edfdddf241de..2926eabfe3c1d 100644
> --- a/kernel/trace/trace_wprobe.c
> +++ b/kernel/trace/trace_wprobe.c
[ ... ]
> @@ -925,6 +926,143 @@ static void wprobe_trigger_free(struct event_trigger_data *data)
> }
> }
>
> +#ifdef CONFIG_PROBE_EVENTS_BTF_ARGS
> +
> +static int get_offset_of_field(struct btf *btf, const struct btf_type *type, char *field_name)
> +{
> + const struct btf_member *field;
> + int bitoffs = 0;
> + u32 anon_offs;
> + char *next;
> +
> + do {
> + next = strchr(field_name, '.');
> + if (next)
> + *next++ = '\0';
> +
> + field = btf_find_struct_member(btf, type, field_name, &anon_offs);
> + if (IS_ERR_OR_NULL(field))
> + return -ENOENT;
> + type = btf_type_by_id(btf, field->type);
> +
> + /* Reject bitfield member access */
> + if (btf_type_kflag(type))
> + return -EINVAL;
> +
> + /* add offset for anonymous struct type */
> + bitoffs += anon_offs + field->offset;
[Severity: High]
Does this code in get_offset_of_field() incorrectly check the child member's
type instead of the parent struct?
Because the type variable is updated to the child member's type before
evaluating btf_type_kflag(type), it seems this check will fail to reject
bitfields (since a child type like BTF_KIND_INT doesn't have a kflag).
When a bitfield is not rejected, field->offset (which contains the bitfield
size shifted by 24 bits for structs with kflag=1) is directly added to
bitoffs, producing an out-of-bounds byte offset for the watchpoint.
Additionally, could this falsely reject valid accesses if the target member
is a nested struct that does have its kflag set?
--
Sashiko AI review · https://sashiko.dev/#/patchset/178476134787.26117.10094977293012760490.stgit@devnote2?part=11
prev parent reply other threads:[~2026-07-22 23:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 23:02 [PATCH v10 00/11] tracing: wprobe: x86: Add wprobe for watchpoint Masami Hiramatsu (Google)
2026-07-22 23:02 ` [PATCH v10 01/11] tracing: wprobe: Add watchpoint probe event based on hardware breakpoint Masami Hiramatsu (Google)
2026-07-22 23:32 ` sashiko-bot
2026-07-22 23:02 ` [PATCH v10 02/11] x86: hw_breakpoint: Add a kconfig to clarify when a breakpoint fires Masami Hiramatsu (Google)
2026-07-22 23:11 ` sashiko-bot
2026-07-22 23:03 ` [PATCH v10 03/11] selftests: tracing: Add a basic testcase for wprobe Masami Hiramatsu (Google)
2026-07-22 23:03 ` [PATCH v10 04/11] selftests: tracing: Add syntax " Masami Hiramatsu (Google)
2026-07-22 23:03 ` [PATCH v10 05/11] x86/hw_breakpoint: Unify breakpoint install/uninstall Masami Hiramatsu (Google)
2026-07-22 23:26 ` sashiko-bot
2026-07-22 23:03 ` [PATCH v10 06/11] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Masami Hiramatsu (Google)
2026-07-22 23:25 ` sashiko-bot
2026-07-22 23:03 ` [PATCH v10 07/11] HWBP: Add modify_wide_hw_breakpoint_local() API Masami Hiramatsu (Google)
2026-07-22 23:04 ` [PATCH v10 08/11] tracing: wprobe: Add wprobe event trigger Masami Hiramatsu (Google)
2026-07-22 23:29 ` sashiko-bot
2026-07-22 23:04 ` [PATCH v10 09/11] selftests: ftrace: Add wprobe trigger testcase Masami Hiramatsu (Google)
2026-07-22 23:24 ` sashiko-bot
2026-07-22 23:04 ` [PATCH v10 10/11] tracing/wprobe: Support BTF typecast in fetchargs Masami Hiramatsu (Google)
2026-07-22 23:04 ` [PATCH v10 11/11] tracing/wprobe: Support BTF typecast in wprobe trigger command Masami Hiramatsu (Google)
2026-07-22 23:31 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260722233104.70A9E1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.