Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 078DF3D7D70; Mon, 17 Aug 2026 15:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786980557; cv=none; b=N9wkliCRrSyalydWHmjBFcXPaqwFCDVBmEDD04Pbo6wSa348gT/d3lX9HhcZse0o0K2oDoceDBczr1uaD6JFMMslFUP4G09WZX83fCjSkqqRKAq6aSiz/T3heJbjRXZUIsiULMHe61QICLvO8Opgg0HN7gTMm8UqJZbjbqrU7xY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786980557; c=relaxed/simple; bh=IMJdR0pjb+VtgjhK0HWCA8luQE9308Iv1YbLyziwRzY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S0sgdJCn616H3+33pGbb31FVsTs6qSSOnU/uQC3CzwhIqJ79UbVpHYDY0GtbGBgdADf1VTlPXMxK9lv6bVaWHCc5CGOaxMmas/MV0pqwwOYR886xCOrpynVx2HR0Xlk+IMJDm9BcK8Bs6Vz+LJzIgA6Ysd5V8z1RaKTxySxN3sY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=c9/jrbCI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="c9/jrbCI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C27E1F000E9; Mon, 17 Aug 2026 15:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786980555; bh=rhz5y+vIXppPgi913oMGfWb+iijedvp06waIbJRpNY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=c9/jrbCIFU+iAIh3DzBzoPVicVxePO+uYyYRKdXWFkxfyEubUnvFdlaXZx/ETFze9 w+wcaU6FUYQgolJyv8aeXItT33JwI6gUUJFbVVXlx7n4JmUpEglc5STmUdq/5Vpk93 5/oVwoSVGX5NYVnXi8W/TWic1Q/awRpLgzcWgItc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hui Su , Vincent Donnefort , "Masami Hiramatsu (Google)" , Steven Rostedt Subject: [PATCH 6.1 576/609] ring-buffer: Fix crash passing ERR_PTR to kthread_stop() Date: Mon, 17 Aug 2026 15:34:32 +0200 Message-ID: <20260817132602.985616644@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132543.039278408@linuxfoundation.org> References: <20260817132543.039278408@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hui Su commit 91542863abade2fd4f2b361991f5386ad9d19c8c upstream. In test_ringbuffer()'s out_free cleanup loop, the check `!rb_threads[cpu]` only catches NULL entries and misses entries that hold an ERR_PTR. rb_threads[] is static, so unassigned slots are NULL. But when kthread_run_on_cpu() fails for a cpu, it stores ERR_PTR(-ENOMEM) (or -EINTR) in rb_threads[cpu] before the creation loop jumps to out_free. That entry is non-NULL, so the old `!ptr` check does not break, and the cleanup proceeds to call kthread_stop() on the ERR_PTR. kthread_stop() then dereferences the bogus pointer, crashing the kernel during the late_initcall self-test. crash logs: BUG: kernel NULL pointer dereference, address: 000000000000001c Oops: 0002 [#1] SMP NOPTI CPU: 1 PID: 1 Comm: swapper/0 Not tainted 7.2.0-rc6-dirty #7 PREEMPT(lazy) RIP: 0010:kthread_stop+0x2e/0x220 RBX: fffffffffffffff4 CR2: 000000000000001c Call Trace: test_ringbuffer+0x1ec/0x650 do_one_initcall+0x6c/0x2c0 kernel_init_freeable+0x21d/0x420 kernel_init+0x15/0x1c0 ret_from_fork+0x21b/0x320 Kernel panic - not syncing: Fatal exception Cc: stable@vger.kernel.org Fixes: 64ed3a049e3e ("ring-buffer: make use of the helper function kthread_run_on_cpu()") Link: https://patch.msgid.link/20260807154145.2846521-2-sh_def@163.com Signed-off-by: Hui Su Reviewed-by: Vincent Donnefort Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ring_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -6089,7 +6089,7 @@ static __init int test_ringbuffer(void) out_free: for_each_online_cpu(cpu) { - if (!rb_threads[cpu]) + if (IS_ERR_OR_NULL(rb_threads[cpu])) break; kthread_stop(rb_threads[cpu]); }