On Tue, Oct 21, 2025 at 09:03:53AM +0800, Hao Ge wrote:
From: Hao Ge gehao@kylinos.cn
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
v3: According to Suren's suggestion, simplify the commit message and the code comments. Thanks for Suren.
v2: Incorporate handling for the scenario where, if mark_failed_objexts_alloc wins the race, the other process (that previously succeeded in allocation) will lose the race, based on Suren's suggestion. Add Suggested-by: Suren Baghdasaryan surenb@google.com
Looks good to me, thanks for fixing this!
Reviewed-by: Harry Yoo harry.yoo@oracle.com