Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hui Su" <sh_def@163.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Fix crash passing ERR_PTR to kthread_stop()
Date: Sat, 15 Aug 2026 19:10:34 +0000	[thread overview]
Message-ID: <20260815191034.82D8F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260815190151.568893-4-sh_def@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Silent Test Bypass
--

--- Patch [1]: [PATCH] tracing: Fix crash passing ERR_PTR to kthread_stop() ---
commit 40985725587eec80dcbbfbf251d18cd9797fe26c
Author: Hui Su <sh_def@163.com>

    tracing: Fix crash passing ERR_PTR to kthread_stop()

    event_test_stuff() calls kthread_run() and unconditionally passes the
    returned task_struct pointer to kthread_stop(). kthread_run() returns an
    error pointer such as ERR_PTR(-ENOMEM) when kthread creation fails, for
    example under memory pressure during the boot-time event self-test.
    kthread_stop() then dereferences the invalid pointer, crashing the
    kernel.

> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 0356cae0cf74e..207f47f54dbbf 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -3866,6 +3866,8 @@ static __init void event_test_stuff(void)
>  	struct task_struct *test_thread;
>  
>  	test_thread = kthread_run(event_test_thread, NULL, "test-events");
> +	if (IS_ERR(test_thread))
> +		return;

[Severity: Medium]
Does returning silently here cause the self-test framework to falsely report
success when the workload thread cannot be created?

The caller event_trace_self_tests() unconditionally prints "OK" after calling
this function:

kernel/trace/trace_events.c:event_trace_self_tests() {
        ...
		ftrace_event_enable_disable(file, 1);
		event_test_stuff();
		ftrace_event_enable_disable(file, 0);

		pr_cont("OK\n");
	}
        ...
}

Should event_test_stuff() propagate the error so that the caller can correctly
report the test failure or skip it appropriately?

>  	msleep(1);
>  	kthread_stop(test_thread);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260815190151.568893-4-sh_def@163.com?part=1

  reply	other threads:[~2026-08-15 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15 19:01 [PATCH] tracing: Fix crash passing ERR_PTR to kthread_stop() Hui Su
2026-08-15 19:10 ` sashiko-bot [this message]
2026-08-16 23:15   ` 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=20260815191034.82D8F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sh_def@163.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox