]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
slab: Avoid race on slab->obj_exts in alloc_slab_obj_exts
authorHao Ge <gehao@kylinos.cn>
Tue, 21 Oct 2025 01:03:53 +0000 (09:03 +0800)
committerVlastimil Babka <vbabka@suse.cz>
Tue, 21 Oct 2025 13:25:39 +0000 (15:25 +0200)
commit6ed8bfd24ce1cb31742b09a3eb557cd008533eec
treef0810ef66185707c7a1fa1014b87906069775810
parent86f54f9b6c17d6567c69e3a6fed52fdf5d7dbe93
slab: Avoid race on slab->obj_exts in alloc_slab_obj_exts

If two competing threads enter alloc_slab_obj_exts() and one of them
fails to allocate the object extension vector, it might override the
valid slab->obj_exts allocated by the other thread with
OBJEXTS_ALLOC_FAIL. This will cause the thread that lost this race and
expects a valid pointer to dereference a NULL pointer later on.

Update slab->obj_exts atomically using cmpxchg() to avoid
slab->obj_exts overrides by racing threads.

Thanks for Vlastimil and Suren's help with debugging.

Fixes: f7381b911640 ("slab: mark slab->obj_exts allocation failures unconditionally")
Cc: <stable@vger.kernel.org>
Suggested-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Hao Ge <gehao@kylinos.cn>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Link: https://patch.msgid.link/20251021010353.1187193-1-hao.ge@linux.dev
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c