Skip to content

Commit 8111292

Browse files
committed
Merge tag 'slab-for-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab
Pull slab fixes from Vlastimil Babka: - Stable fixes for CONFIG_SMP=n where _nolock() allocations in NMI both at kmalloc and page allocator levels are not properly protected by the spin_trylock() semantics on !SMP (Harry Yoo) * tag 'slab-for-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab: mm/slab: return NULL early from kmalloc_nolock() in NMI on UP mm/page_alloc: return NULL early from alloc_frozen_pages_nolock() in NMI on UP
2 parents cffcf52 + 5b31044 commit 8111292

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

mm/page_alloc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7737,6 +7737,11 @@ struct page *alloc_frozen_pages_nolock_noprof(gfp_t gfp_flags, int nid, unsigned
77377737
*/
77387738
if (IS_ENABLED(CONFIG_PREEMPT_RT) && (in_nmi() || in_hardirq()))
77397739
return NULL;
7740+
7741+
/* On UP, spin_trylock() always succeeds even when it is locked */
7742+
if (!IS_ENABLED(CONFIG_SMP) && in_nmi())
7743+
return NULL;
7744+
77407745
if (!pcp_allowed_order(order))
77417746
return NULL;
77427747

mm/slub.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5339,6 +5339,10 @@ void *kmalloc_nolock_noprof(size_t size, gfp_t gfp_flags, int node)
53395339
if (IS_ENABLED(CONFIG_PREEMPT_RT) && (in_nmi() || in_hardirq()))
53405340
return NULL;
53415341

5342+
/* On UP, spin_trylock() always succeeds even when it is locked */
5343+
if (!IS_ENABLED(CONFIG_SMP) && in_nmi())
5344+
return NULL;
5345+
53425346
retry:
53435347
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
53445348
return NULL;

0 commit comments

Comments
 (0)