From: sashiko-bot@kernel.org
To: EisenWalds <aerovynqueque@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] tracing: Fix sanitize_field_type() overlapping strcpy() and word boundary check
Date: Fri, 04 Dec 2026 16:55:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-250246@kernel.org> (raw)
In-Reply-To: <20261204163630.17660-2-aerovynqueque@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] tracing: missing Fixes trailer for sanitize_field_type() bug
fixes
- [Low] tracing: redundant unsigned char cast and inaccurate UB comment
for isalnum()
--
commit fc0f6e4347c9a99f474f4909ae248ae5f2a89b9a
Author: EisenWalds <aerovynqueque@gmail.com>
> tracing: Fix sanitize_field_type() overlapping strcpy() and word boundary check
>
> sanitize_field_type() removes __attribute__((...)) from a type
> string. It has two issues:
>
> 1. strcpy(attr, next) is called with overlapping source and
> destination in the same buffer. Overlapping strcpy() is undefined
> behavior per the C standard; use memmove() instead.
>
> 2. The word boundary check used isspace(attr[-1]), which skipped
> attributes that follow punctuation such as "*__attribute__((...))"
> or "(__attribute__((...))". Check for identifier characters
> (alnum or '_') instead, so those forms are sanitized correctly.
>
> While here, compare against the buffer start (ret) instead of the
> moving search position (next), so the previous-character check is
> skipped only when attr is at the very beginning of the buffer.
> Also cast to unsigned char before isalnum() to avoid undefined
> behavior on signed char.
>
> Signed-off-by: EisenWalds <aerovynqueque@gmail.com>
[Severity: Low]
This fixes two bugs in sanitize_field_type() introduced by commit
1a967e92bf47 ("tracing: Remove "__attribute__()" from the type field of
event format"). Should this include:
Fixes: 1a967e92bf47 ("tracing: Remove "__attribute__()" from the type field of event format")
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 0e396c67a704b..ec0194d164d57 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -3703,8 +3703,19 @@ static char *sanitize_field_type(const char *type)
>
> next = (char *)type;
> while ((attr = strstr(next, ATTRIBUTE_STR))) {
> - /* Retry if "__attribute__(" is a part of another word. */
> - if (attr != next && !isspace(attr[-1])) {
> + /*
> + * Reject if "__attribute__(" is part of another identifier,
> + * e.g. "my__attribute__(" or "_foo__attribute__(".
> + * Checking the previous character is enough: alnum or '_'
> + * means it is still part of an identifier. Other characters
> + * (space, '*', '(', etc.) are valid because C allows an
> + * attribute to follow punctuation, e.g. "*__attribute__((...))".
> + *
> + * Cast to unsigned char to avoid UB when char is signed and
> + * the byte is non-ASCII.
> + */
> + if (attr != ret &&
> + (isalnum((unsigned char)attr[-1]) || attr[-1] == '_')) {
> next = attr + ATTRIBUTE_STR_LEN;
> continue;
> }
[Severity: Low]
This isn't a bug, but the (unsigned char) cast and the undefined behavior
note in this comment and the commit message are unnecessary in the kernel.
include/linux/ctype.h already casts the argument of isalnum() to unsigned
char in __ismask(), and the top-level Makefile builds with -funsigned-char.
Nearby callers such as update_event_printk() pass char directly to
isalnum() without a cast. Can the cast and the undefined behavior note be
dropped from the comment and commit message?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204163630.17660-1-aerovynqueque@gmail.com?part=2
next prev parent reply other threads:[~2026-12-04 16:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 16:36 [PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation EisenWalds
2026-12-04 16:36 ` [PATCH 2/2] tracing: Fix sanitize_field_type() overlapping strcpy() and word boundary check EisenWalds
2026-12-04 16:55 ` sashiko-bot [this message]
2026-12-04 18:21 ` Steven Rostedt
2026-12-04 18:15 ` [PATCH 1/2] tracing: Clean up find_event_field() assignment-in-if and type truncation Steven Rostedt
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-250246@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aerovynqueque@gmail.com \
--cc=linux-trace-kernel@vger.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.