[PATCH] printk: Don't WARN on kthread_run failure.

Tetsuo Handa posted 1 patch 1 month, 4 weeks ago
kernel/printk/nbcon.c  | 2 +-
kernel/printk/printk.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[PATCH] printk: Don't WARN on kthread_run failure.
Posted by Tetsuo Handa 1 month, 4 weeks ago
Since __kthread_create_on_node() returns -EINTR upon SIGKILL,
we should not use WARN_ON() in order to catch kthread_run() failure.

Reported-by: syzbot+1ebbc20f223b99446034@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1ebbc20f223b99446034
Fixes: 5f53ca3ff83b ("printk: Implement legacy printer kthread for PREEMPT_RT")
Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 kernel/printk/nbcon.c  | 2 +-
 kernel/printk/printk.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 4b03b019cd5e..a5921a84a80e 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1382,7 +1382,7 @@ bool nbcon_kthread_create(struct console *con)
 		return true;
 
 	kt = kthread_run(nbcon_kthread_func, con, "pr/%s%d", con->name, con->index);
-	if (WARN_ON(IS_ERR(kt))) {
+	if (IS_ERR(kt)) {
 		con_printk(KERN_ERR, con, "failed to start printing thread\n");
 		return false;
 	}
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 2fe9a963c823..cf15ed75fd26 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3725,7 +3725,7 @@ static bool legacy_kthread_create(void)
 	lockdep_assert_console_list_lock_held();
 
 	kt = kthread_run(legacy_kthread_func, NULL, "pr/legacy");
-	if (WARN_ON(IS_ERR(kt))) {
+	if (IS_ERR(kt)) {
 		pr_err("failed to start legacy printing thread\n");
 		return false;
 	}
-- 
2.52.0
Re: [PATCH] printk: Don't WARN on kthread_run failure.
Posted by Petr Mladek 1 month, 1 week ago
On Tue 2026-08-04 22:52:19, Tetsuo Handa wrote:
> Since __kthread_create_on_node() returns -EINTR upon SIGKILL,
> we should not use WARN_ON() in order to catch kthread_run() failure.
> 
> Reported-by: syzbot+1ebbc20f223b99446034@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1ebbc20f223b99446034
> Fixes: 5f53ca3ff83b ("printk: Implement legacy printer kthread for PREEMPT_RT")
> Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

JFYI, the patch has been committed into printk/linux.git,
branch for-7.4-trivial.

Best Regards,
Petr
Re: [PATCH] printk: Don't WARN on kthread_run failure.
Posted by Petr Mladek 1 month, 1 week ago
On Tue 2026-08-04 22:52:19, Tetsuo Handa wrote:
> Since __kthread_create_on_node() returns -EINTR upon SIGKILL,
> we should not use WARN_ON() in order to catch kthread_run() failure.
> 
> Reported-by: syzbot+1ebbc20f223b99446034@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1ebbc20f223b99446034
> Fixes: 5f53ca3ff83b ("printk: Implement legacy printer kthread for PREEMPT_RT")
> Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

Makes sense.

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

PS: We are in the middle of the merge window. I am going to
    push this into printk tree on top of the pending merge
    request once it gets accepted.
Re: [PATCH] printk: Don't WARN on kthread_run failure.
Posted by John Ogness 1 month, 1 week ago
On 2026-08-04, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:

> Since __kthread_create_on_node() returns -EINTR upon SIGKILL,
> we should not use WARN_ON() in order to catch kthread_run() failure.

For historical context, the WARN_ON() was suggested here [0].

But since a kthread_run() failure also prints a dedicated failure
message, the WARN_ON is overkill.

> Reported-by: syzbot+1ebbc20f223b99446034@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1ebbc20f223b99446034
> Fixes: 5f53ca3ff83b ("printk: Implement legacy printer kthread for PREEMPT_RT")
> Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

Reviewed-by: John Ogness <john.ogness@linutronix.de>

[0] https://lore.kernel.org/lkml/87ed95j8yh.fsf@jogness.linutronix.de