]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/slab-fix-a-crash-by-reading-proc-slab_allocators.patch
Linux 4.19.42
[thirdparty/kernel/stable-queue.git] / queue-5.0 / slab-fix-a-crash-by-reading-proc-slab_allocators.patch
1 From 26dbb49dd6414012e56311cf7d5d0e9fa37d3d75 Mon Sep 17 00:00:00 2001
2 From: Qian Cai <cai@lca.pw>
3 Date: Sat, 6 Apr 2019 18:59:01 -0400
4 Subject: slab: fix a crash by reading /proc/slab_allocators
5
6 [ Upstream commit fcf88917dd435c6a4cb2830cb086ee58605a1d85 ]
7
8 The commit 510ded33e075 ("slab: implement slab_root_caches list")
9 changes the name of the list node within "struct kmem_cache" from "list"
10 to "root_caches_node", but leaks_show() still use the "list" which
11 causes a crash when reading /proc/slab_allocators.
12
13 You need to have CONFIG_SLAB=y and CONFIG_MEMCG=y to see the problem,
14 because without MEMCG all slab caches are root caches, and the "list"
15 node happens to be the right one.
16
17 Fixes: 510ded33e075 ("slab: implement slab_root_caches list")
18 Signed-off-by: Qian Cai <cai@lca.pw>
19 Reviewed-by: Tobin C. Harding <tobin@kernel.org>
20 Cc: Tejun Heo <tj@kernel.org>
21 Cc: Andrew Morton <akpm@linux-foundation.org>
22 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 ---
25 mm/slab.c | 3 ++-
26 1 file changed, 2 insertions(+), 1 deletion(-)
27
28 diff --git a/mm/slab.c b/mm/slab.c
29 index 2f2aa8eaf7d98..188c4b65255dc 100644
30 --- a/mm/slab.c
31 +++ b/mm/slab.c
32 @@ -4297,7 +4297,8 @@ static void show_symbol(struct seq_file *m, unsigned long address)
33
34 static int leaks_show(struct seq_file *m, void *p)
35 {
36 - struct kmem_cache *cachep = list_entry(p, struct kmem_cache, list);
37 + struct kmem_cache *cachep = list_entry(p, struct kmem_cache,
38 + root_caches_node);
39 struct page *page;
40 struct kmem_cache_node *n;
41 const char *name;
42 --
43 2.20.1
44