From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v20 11/11] tracing/wprobe: Support BTF struct offset resolution in set_wprobe trigger
Date: Mon, 16 Nov 2026 05:50:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-216228@kernel.org> (raw)
In-Reply-To: <179480687961.38065.3960820028039271755.stgit@devnote2>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] tracing/wprobe: truncated command logged by
wprobe_trigger_field_parse()
--
commit 2effd66bbdbad9649e094446a260cd6b20b2df1c
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
tracing/wprobe: Support BTF struct offset resolution in set_wprobe trigger
This commit adds BTF struct offset resolution support for the target
address field in set_wprobe and clear_wprobe event triggers, along with
documentation and a selftest.
Link: https://lore.kernel.org/all/59637b96946653393a7ad3c7de094094796b39c2.1785067572.git.wangjinchao600@gmail.com/
> diff --git a/kernel/trace/trace_wprobe.c b/kernel/trace/trace_wprobe.c
> index d2b41aa69cfdf..ad9ab606d3f47 100644
> --- a/kernel/trace/trace_wprobe.c
> +++ b/kernel/trace/trace_wprobe.c
[ ... ]
> @@ -1230,6 +1231,223 @@ static void wprobe_trigger_free(struct event_trigger_data *data)
> }
> }
>
> +#ifdef CONFIG_PROBE_EVENTS_BTF_ARGS
[ ... ]
> +/* parse typecast: (TYPE[,ASGN])EVENT_FIELD->FIELD[.SUBFIELD...][+-OFFS] and set adjust. */
> +static int wprobe_trigger_typecast_parse(char *field_str,
> + struct trace_event_file *file,
> + struct wprobe_trigger_data *wprobe_data,
> + const char *glob)
> +{
> + struct btf *btf __free(btf_put) = NULL;
> + char *buf __free(kfree) = NULL;
> + struct ftrace_event_field *field;
> + const struct btf_type *type;
> + char *assign_field;
> + char *event_field;
> + char *type_field;
> + char *type_name;
> + char *offs;
> + long val = 0;
> + int base_offset = field_str - glob;
> + int event_field_offset;
> + int id, adjust;
> +
> + buf = kstrdup(field_str, GFP_KERNEL);
> + if (!buf)
> + return -ENOMEM;
[ ... ]
> +static int wprobe_trigger_field_parse(char *field_str, struct trace_event_file *file,
> + struct wprobe_trigger_data *wprobe_data,
> + const char *glob)
> +{
> + struct ftrace_event_field *field;
> + char *offs;
> +
> + if (field_str[0] == '(')
> + return wprobe_trigger_typecast_parse(field_str, file, wprobe_data, glob);
> +
> + offs = strpbrk(field_str, "+-");
> + if (offs) {
> + long val;
> +
> + if (kstrtol(offs, 0, &val) < 0) {
> + wprobe_trigger_log_err(file, glob, offs - glob, BAD_DEREF_OFFS);
> + return -EINVAL;
> + }
> + wprobe_data->adjust = val;
> + *offs = '\0';
> + }
> +
> + field = trace_find_event_field(file->event_call, field_str);
> + if (!field) {
> + wprobe_trigger_log_err(file, glob, field_str - glob, NO_EVENT_FIELD);
> + return -ENOENT;
> + }
> + if (field->size != sizeof(void *)) {
> + wprobe_trigger_log_err(file, glob, field_str - glob, WPROBE_BAD_FIELD);
> + return -ENOEXEC;
> + }
> + wprobe_data->offset = field->offset;
> + wprobe_data->field = kstrdup(field_str, GFP_KERNEL);
> + if (!wprobe_data->field)
> + return -ENOMEM;
> +
> + return 0;
> +}
[ ... ]
> @@ -1306,93 +1522,25 @@ static int wprobe_trigger_cmd_parse(struct event_command *cmd_ops,
>
> /* clear_wprobe does not need field, but can have optional field. */
> if (!clear) {
> - char *offs;
> + char *field_str = strsep(¶m, ":");
>
> - /* Find target field, which must be equivalent to "void *" */
> - field_str = strsep(¶m, ":");
> if (!field_str) {
> wprobe_trigger_log_err(file, glob, strlen(glob), WPROBE_NEED_FIELD);
> ret = -EINVAL;
> goto out_free;
> }
> -
> - offs = strpbrk(field_str, "+-");
> - if (offs) {
> - long val;
> -
> - if (kstrtol(offs, 0, &val) < 0) {
> - wprobe_trigger_log_err(file, glob, offs - glob, BAD_DEREF_OFFS);
> - ret = -EINVAL;
> - goto out_free;
> - }
> - wprobe_data->adjust = val;
> - *offs = '\0';
> - }
> -
> - event = file->event_call;
> - field = trace_find_event_field(event, field_str);
> - if (!field) {
> - wprobe_trigger_log_err(file, glob, field_str - glob, NO_EVENT_FIELD);
> - ret = -ENOENT;
> - goto out_free;
> - }
> -
> - if (field->size != sizeof(void *)) {
> - wprobe_trigger_log_err(file, glob, field_str - glob, WPROBE_BAD_FIELD);
> - ret = -ENOEXEC;
> - goto out_free;
> - }
> - wprobe_data->offset = field->offset;
> - wprobe_data->field = kstrdup(field_str, GFP_KERNEL);
> - if (!wprobe_data->field) {
> - ret = -ENOMEM;
> + ret = wprobe_trigger_field_parse(field_str, file, wprobe_data, glob);
> + if (ret < 0)
> goto out_free;
[Severity: Low]
Does wprobe_trigger_log_err() still print a truncated command string when
wprobe_trigger_field_parse() or wprobe_trigger_typecast_parse() fails?
wprobe_trigger_typecast_parse() duplicates field_str to avoid mutating
glob in place, but wprobe_trigger_cmd_parse() has already split event_str
and field_str out of param using strsep(¶m, ":"), which overwrites the
colon after event_str inside glob with a NUL byte:
kernel/trace/trace_wprobe.c:wprobe_trigger_cmd_parse() {
...
if (param_and_filter) {
/* Recover original trigger string to show the error log correctly. */
if (*(param_and_filter - 1) == '\0')
*(param_and_filter - 1) = ':';
...
ret = event_trigger_separate_filter(param_and_filter, ¶m, &filter, true);
...
event_str = strsep(¶m, ":");
...
}
Because that colon at *(field_str - 1) (and any colon after field_str when
a count follows) is never restored, tracing_log_err() stops printing glob
right after event_str, while the error caret position is still calculated
relative to field_str inside glob and lands past the end of the printed
command. In the non-typecast path of wprobe_trigger_field_parse(),
*offs = '\0' also truncates glob before logging NO_EVENT_FIELD or
WPROBE_BAD_FIELD.
--
Sashiko AI review · https://sashiko.dev/#/patchset/179480675130.38065.3086970856119381693.stgit@devnote2?part=11
prev parent reply other threads:[~2026-11-16 5:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 5:25 [PATCH v20 00/11] tracing: wprobe: x86: Add wprobe for watchpoint Masami Hiramatsu (Google)
2026-11-16 5:26 ` [PATCH v20 01/11] x86/hw_breakpoints: Add arch_modify_local_hw_breakpoint_addr() API Masami Hiramatsu (Google)
2026-11-16 5:47 ` sashiko-bot
2026-11-16 5:26 ` [PATCH v20 02/11] HWBP: Add modify_local_hw_breakpoint_addr() API Masami Hiramatsu (Google)
2026-11-16 5:57 ` sashiko-bot
2026-11-16 5:26 ` [PATCH v20 03/11] perf/hw_breakpoint: Add register_wide_hw_breakpoint_cpuslocked() API Masami Hiramatsu (Google)
2026-11-16 5:44 ` sashiko-bot
2026-11-16 5:26 ` [PATCH v20 04/11] tracing/wprobe: Add wprobe (watchpoint probe) trace event support Masami Hiramatsu (Google)
2026-11-16 5:56 ` sashiko-bot
2026-11-16 5:26 ` [PATCH v20 05/11] x86: hw_breakpoint: Add a kconfig to clarify when a breakpoint fires Masami Hiramatsu (Google)
2026-11-16 5:34 ` sashiko-bot
2026-11-16 5:27 ` [PATCH v20 06/11] selftests: tracing: Add a basic testcase for wprobe Masami Hiramatsu (Google)
2026-11-16 5:34 ` sashiko-bot
2026-11-16 5:27 ` [PATCH v20 07/11] selftests: tracing: Add syntax " Masami Hiramatsu (Google)
2026-11-16 5:42 ` sashiko-bot
2026-11-16 5:27 ` [PATCH v20 08/11] tracing/wprobe: Add set_wprobe and clear_wprobe event triggers Masami Hiramatsu (Google)
2026-11-16 6:20 ` sashiko-bot
2026-11-16 5:27 ` [PATCH v20 09/11] selftests: tracing: Add wprobe trigger testcases Masami Hiramatsu (Google)
2026-11-16 5:52 ` sashiko-bot
2026-11-16 5:27 ` [PATCH v20 10/11] tracing/wprobe: Support BTF typecast in fetchargs Masami Hiramatsu (Google)
2026-11-16 5:52 ` sashiko-bot
2026-11-16 5:27 ` [PATCH v20 11/11] tracing/wprobe: Support BTF struct offset resolution in set_wprobe trigger Masami Hiramatsu (Google)
2026-11-16 5:50 ` 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=sashiko-outbox-216228@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@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.