linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: memcg/slab: Fix return child memcg objcg for root memcg
@ 2020-10-28  3:50 Muchun Song
  2020-10-28  3:50 ` [PATCH v2] mm: memcg/slab: Fix use after free in obj_cgroup_charge Muchun Song
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Muchun Song @ 2020-10-28  3:50 UTC (permalink / raw)
  To: hannes, mhocko, vdavydov.dev, akpm, shakeelb, guro,
	iamjoonsoo.kim, laoar.shao, chris, christian.brauner, peterz,
	mingo, keescook, tglx, esyr, surenb, areber, elver
  Cc: linux-kernel, cgroups, linux-mm, Muchun Song

Consider the following memcg hierarchy.

                    root
                   /    \
                  A      B

If we get the objcg of memcg A failed, the get_obj_cgroup_from_current
can return the wrong objcg for the root memcg.

Fixes: bf4f059954dc ("mm: memcg/slab: obj_cgroup API")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 changelog in v2:
 1. Do not use a comparison with the root_mem_cgroup

 mm/memcontrol.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1337775b04f3..8c8b4c3ed5a0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2961,6 +2961,7 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void)
 		objcg = rcu_dereference(memcg->objcg);
 		if (objcg && obj_cgroup_tryget(objcg))
 			break;
+		objcg = NULL;
 	}
 	rcu_read_unlock();
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-11-10  3:20 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28  3:50 [PATCH v2] mm: memcg/slab: Fix return child memcg objcg for root memcg Muchun Song
2020-10-28  3:50 ` [PATCH v2] mm: memcg/slab: Fix use after free in obj_cgroup_charge Muchun Song
2020-10-29 15:52   ` Shakeel Butt
2020-11-10  3:19   ` Muchun Song
2020-10-28  3:50 ` [PATCH v2] mm: memcg/slab: Rename *_lruvec_slab_state to *_lruvec_kmem_state Muchun Song
2020-10-29 15:52   ` Shakeel Butt
2020-10-28  3:50 ` [PATCH v2] mm: memcontrol: Simplify the mem_cgroup_page_lruvec Muchun Song
2020-10-29  9:08   ` Michal Hocko
2020-10-29 16:01     ` Shakeel Butt
2020-10-29 16:13       ` Michal Hocko
2020-10-29  0:16 ` [PATCH v2] mm: memcg/slab: Fix return child memcg objcg for root memcg Roman Gushchin
2020-10-29 15:48 ` Shakeel Butt
2020-10-29 16:08   ` [External] " Muchun Song
2020-10-29 16:18     ` Shakeel Butt
2020-10-29 16:32       ` Muchun Song
2020-10-29 17:09   ` Roman Gushchin
2020-10-29 20:34     ` Shakeel Butt
2020-10-29 21:25       ` Roman Gushchin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).