From: sashiko-bot@kernel.org
Cc: tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, bpf@vger.kernel.org
Subject: Re: [PATCH RFC 2/4] mm/slab: handle allow_spin in slab_free_hook() instead of open coding
Date: Wed, 24 Jun 2026 13:24:14 +0000 [thread overview]
Message-ID: <20260624132415.1C9391F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260624-kmalloc-nolock-fixes-v1-2-fdf4d17351dd@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] slab_free_hook() proceeds with an unsafe GFP_NOWAIT allocation after VM_WARN_ON_ONCE(!allow_spin) for SLAB_TYPESAFE_BY_RCU caches, deadlocking NMI callers.
--
commit b732dfb9de7b44943319ed866b71dd254fecb07a
Author: Harry Yoo (Oracle) <harry@kernel.org>
mm/slab: handle allow_spin in slab_free_hook() instead of open coding
This commit refactors slab_free_hook() to accept an allow_spin parameter,
replacing the open-coded hook logic in memcg_alloc_abort_single() and
kfree_nolock(). It ensures that spinlock-acquiring free hooks and KASAN
quarantine operations are bypassed when allow_spin is false.
> diff --git a/mm/slub.c b/mm/slub.c
> index 32672a92581b0..85760c8ff2e29 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
[ ... ]
> @@ -2654,6 +2665,7 @@ bool slab_free_hook(struct kmem_cache *s, void *x, bool init,
> if (still_accessible) {
> struct rcu_delayed_free *delayed_free;
>
> + VM_WARN_ON_ONCE(!allow_spin);
> delayed_free = kmalloc_obj(*delayed_free, GFP_NOWAIT);
[Severity: High]
If allow_spin is false (e.g., when called from kfree_nolock() in NMI or
atomic context), this triggers the warning but still proceeds to call
kmalloc_obj() with GFP_NOWAIT.
Since GFP_NOWAIT does not prevent the slab allocator from acquiring spinlocks
(such as pcp->lock or node->list_lock), and it does not strip
__GFP_KSWAPD_RECLAIM which can wake kswapd and acquire scheduler locks, could
this lead to a deadlock if called in NMI context?
Should this path explicitly skip the allocation or return early when
allow_spin is false?
> if (delayed_free) {
> /*
> * Let KASAN track our call stack as a "related work
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624-kmalloc-nolock-fixes-v1-0-fdf4d17351dd@kernel.org?part=2
next prev parent reply other threads:[~2026-06-24 13:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 13:11 [PATCH RFC 0/4] memcg,slab: kmalloc_nolock() fixes Harry Yoo (Oracle)
2026-06-24 13:11 ` [PATCH RFC 1/4] mm/memcontrol: do not drain objcg stock when spinning is not allowed Harry Yoo (Oracle)
2026-06-24 13:28 ` sashiko-bot
2026-06-24 13:11 ` [PATCH RFC 2/4] mm/slab: handle allow_spin in slab_free_hook() instead of open coding Harry Yoo (Oracle)
2026-06-24 13:24 ` sashiko-bot [this message]
2026-06-24 13:11 ` [PATCH RFC 3/4] mm/slab: fix a deadlock in memcg_alloc_abort_single() Harry Yoo (Oracle)
2026-06-24 13:11 ` [PATCH RFC 4/4] mm/slab: serialize defer_free_barrier() Harry Yoo (Oracle)
2026-06-24 13:25 ` sashiko-bot
2026-06-24 16:30 ` [PATCH RFC 0/4] memcg,slab: kmalloc_nolock() fixes Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260624132415.1C9391F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.