From: sashiko-bot@kernel.org
To: "Harry Yoo (Meta)" <harry@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Hocko" <mhocko@kernel.org>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Muchun Song" <muchun.song@linux.dev>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Hao Li" <hao.li@linux.dev>, "Christoph Lameter" <cl@gentwo.org>,
"David Rientjes" <rientjes@google.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Clark Williams" <clrkwllms@kernel.org>,
"Steven Rostedt" <rostedt@goodmis.org>
Cc: kernel-team@meta.com, linux-mm@kvack.org,
linux-rt-devel@lists.linux.dev, tj@kernel.org, mkoutny@suse.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH for-next v3 3/7] mm/slab: handle SLAB_FREE_NOLOCK in slab_free_hook() instead of open coding
Date: Mon, 16 Nov 2026 08:26:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-216530@kernel.org> (raw)
In-Reply-To: <20261115-kmalloc-nolock-fixes-v3-3-9034dd4ecaab@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm/slab: kfree_nolock() leaves KASAN free_meta in init_on_free
objects
--
commit f5f03c7c446bcbe50fa191f0cf60accc8ad01ac9
Author: Harry Yoo (Meta) <harry@kernel.org>
mm/slab: handle SLAB_FREE_NOLOCK in slab_free_hook() instead of open coding
This commit moves SLAB_FREE_NOLOCK handling into slab_free_hook() and replaces
the open-coded free hooks in kfree_nolock() with a call to slab_free_hook(),
enabling SLAB_FREE_INIT when slab_want_init_on_free() is true.
> diff --git a/mm/slub.c b/mm/slub.c
> index 761dc2affea27..7c0adc1049880 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
[ ... ]
> @@ -2775,8 +2790,11 @@ bool slab_free_hook(struct kmem_cache *s, void *x, unsigned int free_flags)
> set_orig_size(s, x, orig_size);
>
> }
> - /* KASAN might put x into memory quarantine, delaying its reuse. */
> - return !kasan_slab_free(s, x, init, still_accessible, false);
> + /*
> + * KASAN might put x into memory quarantine, delaying its reuse.
> + * Skip quarantine when spinning is not allowed as it uses a spinlock.
> + */
> + return !kasan_slab_free(s, x, init, still_accessible, !allow_spin);
> }
[ ... ]
> @@ -6949,33 +6968,12 @@ void kfree_nolock(const void *object)
>
> memcg_slab_free_hook(s, slab, &x, 1);
> alloc_tagging_slab_free_hook(s, slab, &x, 1);
[ ... ]
> +
> + if (slab_want_init_on_free(s))
> + free_flags |= SLAB_FREE_INIT;
> +
> + if (unlikely(!slab_free_hook(s, x, free_flags)))
> return;
[Severity: Low]
When CONFIG_KASAN_GENERIC and init_on_free are enabled, does kfree_nolock()
leave non-zero KASAN free_meta in the object after slab_free_hook() zeroes it?
After slab_free_hook() zeroes the object for SLAB_FREE_INIT, it calls
kasan_slab_free() with no_quarantine set to true (!allow_spin):
mm/kasan/common.c:__kasan_slab_free() {
...
poison_slab_object(cache, object, init);
if (no_quarantine)
return false;
...
}
In Generic KASAN, poison_slab_object() -> kasan_save_free_info() writes
struct kasan_free_meta at offset 0 of the object when free_meta_offset == 0.
Normal frees clear this in-object metadata upon quarantine eviction in
qlink_free(), but returning early for no_quarantine skips quarantine and
never zeroes free_meta before the object is reused.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115-kmalloc-nolock-fixes-v3-0-9034dd4ecaab@kernel.org?part=3
next prev parent reply other threads:[~2026-11-16 8:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 15:09 [PATCH for-next v3 0/7] memcg,slab: kmalloc_nolock() fixes Harry Yoo (Meta)
2026-11-15 15:09 ` [PATCH for-next v3 1/7] mm/memcontrol: defer obj_cgroup_release() to irq_work Harry Yoo (Meta)
2026-11-15 15:09 ` [PATCH for-next v3 2/7] mm/slab: pass free_flags to slab_free_hook() Harry Yoo (Meta)
2026-11-15 15:09 ` [PATCH for-next v3 3/7] mm/slab: handle SLAB_FREE_NOLOCK in slab_free_hook() instead of open coding Harry Yoo (Meta)
2026-11-16 8:26 ` sashiko-bot [this message]
2026-11-15 15:09 ` [PATCH for-next v3 4/7] mm/slab: fix a deadlock in memcg_alloc_abort_single() Harry Yoo (Meta)
2026-11-15 15:09 ` [PATCH for-next v3 5/7] mm/slab: serialize deferred_work_barrier() Harry Yoo (Meta)
2026-11-15 15:09 ` [PATCH for-next v3 6/7] mm/slab: refactor free_to_pcs() Harry Yoo (Meta)
2026-11-15 15:09 ` [PATCH for-next v3 7/7] mm/slab: call debug_locks and KCSAN checks in kfree_nolock() Harry Yoo (Meta)
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=sashiko-outbox-216530@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=cl@gentwo.org \
--cc=clrkwllms@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
--cc=vbabka@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®