Re: [PATCH 1/1] tracing: Fix UBSAN shift-out-of-bounds in test_event_printk()

From: Steven Rostedt

Date: Wed Nov 25 2026 - 10:38:40 EST


On Wed, 25 Nov 2026 16:03:56 +0800
Kuyo Chang <kuyo.chang@xxxxxxxxxxxx> wrote:
> kernel/trace/trace_events.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 7f89160aeff3..5933fc92f786 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -526,7 +526,7 @@ static void test_event_printk(struct trace_event_call *call)
> case 'a': case 'd': case 'D':
> case 'g': case 't': case 'C':
> case 'O': case 'f':
> - if (WARN_ONCE(arg == 63,
> + if (WARN_ONCE(arg >= 63,
> "Too many args for event: %s",
> trace_event_name(call)))
> return;
> @@ -556,7 +556,7 @@ static void test_event_printk(struct trace_event_call *call)
> if ((fmt[i + j] == 's')) {
> if (star)
> arg++;
> - if (WARN_ONCE(arg == 63,
> + if (WARN_ONCE(arg >= 63,
> "Too many args for event: %s",
> trace_event_name(call)))
> return;
> @@ -610,7 +610,7 @@ static void test_event_printk(struct trace_event_call *call)
>
> test_double_dereference(fmt + start_arg, e - start_arg, call);
>
> - if (dereference_flags & (1ULL << arg)) {
> + if (arg < 64 && (dereference_flags & (1ULL << arg))) {

The above should never happen. If anything, arg >= 64 should exit this
function immediately.

-- Steve


> handle_dereference_arg(fmt + start_arg, string_flags,
> e - start_arg,
> &dereference_flags, arg, call);
> @@ -625,7 +625,7 @@ static void test_event_printk(struct trace_event_call *call)
>
> test_double_dereference(fmt + start_arg, i - start_arg, call);
>
> - if (dereference_flags & (1ULL << arg)) {
> + if (arg < 64 && (dereference_flags & (1ULL << arg))) {
> handle_dereference_arg(fmt + start_arg, string_flags,
> i - start_arg,
> &dereference_flags, arg, call);