[folded-merged] mm-rework-non-root-kmem_cache-lifecycle-management-fix.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm/slab: fix an use-after-free in kmemcg_workfn()
has been removed from the -mm tree.  Its filename was
     mm-rework-non-root-kmem_cache-lifecycle-management-fix.patch

This patch was dropped because it was folded into mm-rework-non-root-kmem_cache-lifecycle-management.patch

------------------------------------------------------
From: Qian Cai <cai@xxxxxx>
Subject: mm/slab: fix an use-after-free in kmemcg_workfn()

The linux-next commit "mm: rework non-root kmem_cache lifecycle
management" [1] introduced an use-after-free below because kmemcg_workfn()
may call slab_kmem_cache_release() which has already freed the whole
kmem_cache.  Fix it by removing the bogus NULL assignment and checkings
that will not work with SLUB_DEBUG poisoning anyway.

[1] https://lore.kernel.org/patchwork/patch/1087376/

BUG kmem_cache (Tainted: G    B   W        ): Poison overwritten
INFO: 0x(____ptrval____)-0x(____ptrval____). First byte 0x0 instead of
0x6b
INFO: Allocated in create_cache+0x6c/0x1bc age=2653 cpu=154 pid=1599
	kmem_cache_alloc+0x514/0x568
	create_cache+0x6c/0x1bc
	memcg_create_kmem_cache+0xfc/0x11c
	memcg_kmem_cache_create_func+0x40/0x170
	process_one_work+0x4e0/0xa54
	worker_thread+0x498/0x650
	kthread+0x1b8/0x1d4
	ret_from_fork+0x10/0x18
INFO: Freed in slab_kmem_cache_release+0x3c/0x48 age=255 cpu=7 pid=1505
	slab_kmem_cache_release+0x3c/0x48
	kmem_cache_release+0x1c/0x28
	kobject_cleanup+0x134/0x288
	kobject_put+0x5c/0x68
	sysfs_slab_release+0x2c/0x38
	shutdown_cache+0x190/0x234
	kmemcg_cache_shutdown_fn+0x1c/0x34
	kmemcg_workfn+0x44/0x68
	process_one_work+0x4e0/0xa54
	worker_thread+0x498/0x650
	kthread+0x1b8/0x1d4
	ret_from_fork+0x10/0x18
INFO: Slab 0x(____ptrval____) objects=64 used=64 fp=0x(____ptrval____)
flags=0x17ffffffc000200
INFO: Object 0x(____ptrval____) @offset=11601272640106456192
fp=0x(____ptrval____)
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
bb  ................
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 00 00 00 00 00 00 00 00
kkkkkkkk........
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
kkkkkkkkkkkkkkkk
Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b a5
kkkkkkk.
Redzone (____ptrval____): bb bb bb bb bb bb bb bb
........
Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a  ZZZZZZZZZZZZZZZZ
Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a  ZZZZZZZZZZZZZZZZ
Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a  ZZZZZZZZZZZZZZZZ
Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a
5a  ZZZZZZZZZZZZZZZZ
Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a
ZZZZZZZZ
CPU: 193 PID: 1557 Comm: kworker/193:1 Tainted: G    B   W
5.2.0-rc5-next-20190619+ #8
Hardware name: HPE Apollo 70             /C01_APACHE_MB         , BIOS
L50_5.13_1.0.9 03/01/2019
Workqueue: memcg_kmem_cache memcg_kmem_cache_create_func
Call trace:
 dump_backtrace+0x0/0x268
 show_stack+0x20/0x2c
 dump_stack+0xb4/0x108
 print_trailer+0x274/0x298
 check_bytes_and_report+0xc4/0x118
 check_object+0x2fc/0x36c
 alloc_debug_processing+0x154/0x240
 ___slab_alloc+0x710/0xa68
 kmem_cache_alloc+0x514/0x568
 create_cache+0x6c/0x1bc
 memcg_create_kmem_cache+0xfc/0x11c
 memcg_kmem_cache_create_func+0x40/0x170
 process_one_work+0x4e0/0xa54
 worker_thread+0x498/0x650
 kthread+0x1b8/0x1d4
 ret_from_fork+0x10/0x18
FIX kmem_cache: Restoring 0x(____ptrval____)-0x(____ptrval____)=0x6b

FIX kmem_cache: Marking all objects used

Link: http://lkml.kernel.org/r/1560977573-10715-1-git-send-email-cai@xxxxxx
Signed-off-by: Qian Cai <cai@xxxxxx>
Acked-by: Roman Gushchin <guro@xxxxxx>
Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
Cc: Christoph Lameter <cl@xxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Shakeel Butt <shakeelb@xxxxxxxxxx>
Cc: Waiman Long <longman@xxxxxxxxxx>
Cc: David Rientjes <rientjes@xxxxxxxxxx>
Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
Cc: Pekka Enberg <penberg@xxxxxxxxxx>
Cc: Andrei Vagin <avagin@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/slab_common.c |    5 -----
 1 file changed, 5 deletions(-)

--- a/mm/slab_common.c~mm-rework-non-root-kmem_cache-lifecycle-management-fix
+++ a/mm/slab_common.c
@@ -713,10 +713,7 @@ static void kmemcg_workfn(struct work_st
 	get_online_mems();
 
 	mutex_lock(&slab_mutex);
-
 	s->memcg_params.work_fn(s);
-	s->memcg_params.work_fn = NULL;
-
 	mutex_unlock(&slab_mutex);
 
 	put_online_mems();
@@ -752,7 +749,6 @@ static void kmemcg_cache_shutdown(struct
 	if (s->memcg_params.root_cache->memcg_params.dying)
 		goto unlock;
 
-	WARN_ON(s->memcg_params.work_fn);
 	s->memcg_params.work_fn = kmemcg_cache_shutdown_fn;
 	INIT_WORK(&s->memcg_params.work, kmemcg_workfn);
 	queue_work(memcg_kmem_cache_wq, &s->memcg_params.work);
@@ -783,7 +779,6 @@ static void kmemcg_cache_deactivate(stru
 	if (s->memcg_params.root_cache->memcg_params.dying)
 		goto unlock;
 
-	WARN_ON_ONCE(s->memcg_params.work_fn);
 	s->memcg_params.work_fn = kmemcg_cache_deactivate_after_rcu;
 	call_rcu(&s->memcg_params.rcu_head, kmemcg_rcufn);
 unlock:
_

Patches currently in -mm which might be from cai@xxxxxx are

iommu-replace-single-char-identifiers-in-macros.patch
mm-rework-non-root-kmem_cache-lifecycle-management.patch
arm64-switch-to-generic-version-of-pte-allocation-fix.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux