
From: Liu Shixin <liushixin2@huawei.com> hulk inclusion category: bugfix bugzilla: 47240 CVE: NA ------------------------------------------------- Change struct mem_cgroup directly will causes the kabi broken. So add a new struct mem_cgroup_extension for new variables. Signed-off-by: Liu Shixin <liushixin2@huawei.com> Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Cheng Jian <cj.chengjian@huawei.com> --- include/linux/memcontrol.h | 4 ++++ mm/memcontrol.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 9afd655ff646..7da3f6c660f5 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -318,6 +318,10 @@ struct mem_cgroup { /* WARNING: nodeinfo must be the last member here */ }; +struct mem_cgroup_extension { + struct mem_cgroup memcg; +}; + /* * size of first charge trial. "32" comes from vmscan.c's magic value. * TODO: maybe necessary to use big numbers in big irons. diff --git a/mm/memcontrol.c b/mm/memcontrol.c index dca37f310b7b..ea67a63a4e71 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4508,11 +4508,14 @@ static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) static void __mem_cgroup_free(struct mem_cgroup *memcg) { int node; + struct mem_cgroup_extension *memcg_ext; for_each_node(node) free_mem_cgroup_per_node_info(memcg, node); free_percpu(memcg->stat_cpu); - kfree(memcg); + + memcg_ext = container_of(memcg, struct mem_cgroup_extension, memcg); + kfree(memcg_ext); } static void mem_cgroup_free(struct mem_cgroup *memcg) @@ -4524,13 +4527,15 @@ static void mem_cgroup_free(struct mem_cgroup *memcg) static struct mem_cgroup *mem_cgroup_alloc(void) { struct mem_cgroup *memcg; + struct mem_cgroup_extension *memcg_ext; size_t size; int node; - size = sizeof(struct mem_cgroup); + size = sizeof(struct mem_cgroup_extension); size += nr_node_ids * sizeof(struct mem_cgroup_per_node *); - memcg = kzalloc(size, GFP_KERNEL); + memcg_ext = kzalloc(size, GFP_KERNEL); + memcg = &memcg_ext->memcg; if (!memcg) return NULL; -- 2.25.1