Revision 757fed1d0898b893d7daa84183947c70f27632f3 authored by Wang Hai on 28 January 2021, 11:32:50 UTC, committed by Linus Torvalds on 28 January 2021, 17:05:44 UTC
This reverts commit dde3c6b72a16c2db826f54b2d49bdea26c3534a2.

syzbot report a double-free bug. The following case can cause this bug.

 - mm/slab_common.c: create_cache(): if the __kmem_cache_create() fails,
   it does:

	out_free_cache:
		kmem_cache_free(kmem_cache, s);

 - but __kmem_cache_create() - at least for slub() - will have done

	sysfs_slab_add(s)
		-> sysfs_create_group() .. fails ..
		-> kobject_del(&s->kobj); .. which frees s ...

We can't remove the kmem_cache_free() in create_cache(), because other
error cases of __kmem_cache_create() do not free this.

So, revert the commit dde3c6b72a16 ("mm/slub: fix a memory leak in
sysfs_slab_add()") to fix this.

Reported-by: syzbot+d0bd96b4696c1ef67991@syzkaller.appspotmail.com
Fixes: dde3c6b72a16 ("mm/slub: fix a memory leak in sysfs_slab_add()")
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 76c057c
History
File Mode Size
Kconfig -rw-r--r-- 287 bytes
Makefile -rw-r--r-- 991 bytes
af_llc.c -rw-r--r-- 31.4 KB
llc_c_ac.c -rw-r--r-- 35.5 KB
llc_c_ev.c -rw-r--r-- 21.3 KB
llc_c_st.c -rw-r--r-- 151.9 KB
llc_conn.c -rw-r--r-- 27.4 KB
llc_core.c -rw-r--r-- 4.1 KB
llc_if.c -rw-r--r-- 4.5 KB
llc_input.c -rw-r--r-- 5.9 KB
llc_output.c -rw-r--r-- 2.0 KB
llc_pdu.c -rw-r--r-- 10.6 KB
llc_proc.c -rw-r--r-- 6.0 KB
llc_s_ac.c -rw-r--r-- 5.9 KB
llc_s_ev.c -rw-r--r-- 3.5 KB
llc_s_st.c -rw-r--r-- 5.7 KB
llc_sap.c -rw-r--r-- 11.3 KB
llc_station.c -rw-r--r-- 3.2 KB
sysctl_net_llc.c -rw-r--r-- 1.8 KB

back to top