Commit 6ed8bfd2 authored by Hao Ge's avatar Hao Ge Committed by Vlastimil Babka
Browse files

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: f7381b91 ("slab: mark slab->obj_exts allocation failures unconditionally")
Cc: <stable@vger.kernel.org>
Suggested-by: default avatarSuren Baghdasaryan <surenb@google.com>
Signed-off-by: default avatarHao Ge <gehao@kylinos.cn>
Reviewed-by: default avatarHarry Yoo <harry.yoo@oracle.com>
Reviewed-by: default avatarSuren Baghdasaryan <surenb@google.com>
Link: https://patch.msgid.link/20251021010353.1187193-1-hao.ge@linux.dev


Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
parent 86f54f9b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment