* [merged mm-nonmm-hotfixes-stable] panic-zero-the-dynamically-allocated-taint-buffer.patch removed from -mm tree
@ 2026-11-03 3:19 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-11-03 3:19 UTC (permalink / raw)
To: mm-commits, stable, rioo.tsukatsukii, pmladek, brads, nickolai,
akpm
The quilt patch titled
Subject: panic: zero the dynamically allocated taint buffer
has been removed from the -mm tree. Its filename was
panic-zero-the-dynamically-allocated-taint-buffer.patch
This patch was dropped because it was merged into the mm-nonmm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Nickolai Zeldovich <nickolai@csail.mit.edu>
Subject: panic: zero the dynamically allocated taint buffer
Date: Fri, 23 Oct 2026 22:01:52 -0400
A %s read of print_tainted()'s string can run past the end of the taint
buffer while another CPU rebuilds a longer string in it, reading slab
memory out of bounds into the kernel log (a KASAN slab-out-of-bounds
report at taint_buf + size). A warning or an unhandled-signal dump on
another CPU reaches print_tainted() through dump_stack_print_info().
alloc_taint_buf() sizes the buffer for the longest taint string and
allocates it with kmalloc(), so the bytes past that string are never
written and the object holds no permanent NUL terminator.
_print_tainted() rebuilds the string in place without locking and writes
the terminator last, so a reader that overtakes a writer extending the
string past the previous high-water mark finds no terminator inside the
object and walks off its end. print_tainted()'s kernel-doc promises the
string is "always NULL terminated", a guarantee the previous zero-filled
static buffer kept.
Allocate the buffer with kzalloc() so its trailing bytes stay NUL and
every reader stops inside the object.
Reproduced on QEMU riscv64 under KASAN by growing the taint set while
processes took unhandled-signal dumps on several CPUs: the unpatched
kernel reports a slab-out-of-bounds read at taint_buf + size, the patched
one is clean.
Link: https://lore.kernel.org/20261024020153.830459-1-nickolai@csail.mit.edu
Fixes: a9dff0d0d11c ("kernel/panic: allocate taint string buffer dynamically")
Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Bradley Morgan <brads@mainlining.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Rio <rioo.tsukatsukii@gmail.com>
Cc: <stable@vger.kernel.org>
---
kernel/panic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/panic.c~panic-zero-the-dynamically-allocated-taint-buffer
+++ a/kernel/panic.c
@@ -884,7 +884,7 @@ static __init int alloc_taint_buf(void)
size += 1; /* For NULL terminator */
- buf = kmalloc(size, GFP_KERNEL);
+ buf = kzalloc(size, GFP_KERNEL);
if (!buf) {
panic("Failed to allocate taint string buffer");
_
Patches currently in -mm which might be from nickolai@csail.mit.edu are
xarray-clear-the-new-heads-parent-before-freeing-the-old-head.patch
lib-plist-add-a-plist_test-case-for-plist_requeue-on-the-last-priority-bucket.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-03 3:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 3:19 [merged mm-nonmm-hotfixes-stable] panic-zero-the-dynamically-allocated-taint-buffer.patch removed from -mm tree Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox