projects/linux·commit a80abfbb

Merge tag 'slab-for-6.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab

a80abfbb · Linus Torvalds <[email protected]> · 2025-11-07 08:01:58 -08:00

Pull slab fix from Vlastimil Babka:

 - Fix for potential infinite loop in kmalloc_nolock() when debugging
   is enabled for the cache (Vlastimil Babka)

* tag 'slab-for-6.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab:
  slab: prevent infinite loop in kmalloc_nolock() with debugging
Commit
a80abfbb1013ffec7aa7e574b5ba9bcf02bd5462
Parents
9dc52063 · c379b745

Merge commit. Changes below are compared with the first parent: 9dc52063.

Changes

1 files changed · +5 −1

FileStatusAddDelContent
mm/slub.cmodified+5−1View file

mm/slub.c

View file
diff --git a/mm/slub.c b/mm/slub.c
index d4367f2..f1a5373 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4666,8 +4666,12 @@ new_objects:
if (kmem_cache_debug(s)) {
freelist = alloc_single_from_new_slab(s, slab, orig_size, gfpflags);
- if (unlikely(!freelist))
+ if (unlikely(!freelist)) {
+ /* This could cause an endless loop. Fail instead. */
+ if (!allow_spin)
+ return NULL;
goto new_objects;
+ }
if (s->flags & SLAB_STORE_USER)
set_track(s, freelist, TRACK_ALLOC, addr,