mm-memcg-slab-fix-use-after-free-in-obj_cgroup_charge.patch removed from -mm tree
The patch titled
Subject: mm: memcg/slab: fix use after free in obj_cgroup_charge
has been removed from the -mm tree. Its filename was
mm-memcg-slab-fix-use-after-free-in-obj_cgroup_charge.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Muchun Song <[email protected]>
Subject: mm: memcg/slab: fix use after free in obj_cgroup_charge
The rcu_read_lock/unlock only can guarantee that the memcg will not be freed, but it cannot guarantee the success of css_get to memcg.
If the whole process of a cgroup offlining is completed between reading a objcg->memcg pointer and bumping the css reference on another CPU, and there are exactly 0 external references to this memory cgroup (how we get to the obj_cgroup_charge() then?), css_get() can change the ref counter from 0 back to 1.
---
mm/memcontrol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/memcontrol.c renamed from mm/memcontrol.c~mm-memcg-slab-fix-use-after-free-in-obj_cgroup_charge +3 -1
@@ -3235,8 +3235,10 @@ int obj_cgroup_charge(struct obj_cgroup* independently later. */ rcu_read_lock (); +retry: memcg =obj_cgroup_memcg (objcg); -css_get (&memcg->css); +if (unlikely (!css_tryget (&memcg->css))) + goto retry;rcu_read_unlock (); nr_pages = size >>PAGE_SHIFT ;
_
Patches currently in -mm which might be from [email protected] are