slab: fix a crash by reading /proc/slab_allocators
authorQian Cai <cai@lca.pw>
Sat, 6 Apr 2019 22:59:01 +0000 (18:59 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 May 2019 15:54:08 +0000 (17:54 +0200)
commit78bc98235e843dd904aa8d0ea0111a5511cf41b9
treef6acc87a5827f1d3913c55f2922c032ec41ed344
parentcf6cb79d57b049fbf2385bf79a34c651101615f0
slab: fix a crash by reading /proc/slab_allocators

[ Upstream commit fcf88917dd435c6a4cb2830cb086ee58605a1d85 ]

The commit 510ded33e075 ("slab: implement slab_root_caches list")
changes the name of the list node within "struct kmem_cache" from "list"
to "root_caches_node", but leaks_show() still use the "list" which
causes a crash when reading /proc/slab_allocators.

You need to have CONFIG_SLAB=y and CONFIG_MEMCG=y to see the problem,
because without MEMCG all slab caches are root caches, and the "list"
node happens to be the right one.

Fixes: 510ded33e075 ("slab: implement slab_root_caches list")
Signed-off-by: Qian Cai <cai@lca.pw>
Reviewed-by: Tobin C. Harding <tobin@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mm/slab.c