memcg: fix per_node_info cleanup
Subsystems (3)
Michal Hocko
maintainerPATCH 1/1 memcg: fix per_node_info cleanup
From: Michal Hocko <[email protected]>
syzbot has triggered a NULL ptr dereference when allocation fault injection enforces a failure and alloc_mem_cgroup_per_node_info initializes memcg->nodeinfo only half way through. __mem_cgroup_free still tries to free all per-node data and dereferences pn->lruvec_stat_cpu unconditioanlly even if the specific per-node data hasn't been initialized.
The bug is quite unlikely to hit because small allocations do not fail and we would need quite some numa nodes to make struct mem_cgroup_per_node large enough to cross the costly order.
---
Hi!
Previously posted [1] based on the syzkaller report [2]. I haven't heard back from syzkaller but this seems like the right fix. Andrew could you add this to the pile?
[1] http://lkml.kernel.org/r/[email protected]
[2] http://lkml.kernel.org/r/[email protected]
mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+)
mm/memcontrol.c +3 -0
@@ -4340,6 +4340,9 @@ static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) {struct mem_cgroup_per_node *pn = memcg->nodeinfo[node]; +if (!pn) +return ; +free_percpu (pn->lruvec_stat_cpu);kfree (pn); }
Signature · 1 line
2.16.3
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag, fixing commit: 00f3ca2c2d66 mm: memcontrol: per-lruvec stats infrastructure.
The bot has also determined it's probably a bug fixing patch. (score: 40.3266)
The bot has tested the following trees: v4.16.1, v4.15.16, v4.14.33.
v4.16.1: Build OK!
v4.15.16: Failed to apply! Possible dependencies:
a983b5ebee57 ("mm: memcontrol: fix excessive complexity in memory.stat reporting")
v4.14.33: Failed to apply! Possible dependencies:
a983b5ebee57 ("mm: memcontrol: fix excessive complexity in memory.stat reporting")
--
Thanks,
Sasha
Michal Hocko
maintainerQuoted 6 lines · Sasha Levin
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag, fixing commit:
00f3ca2c2d66mm: memcontrol: per-lruvec stats infrastructure.
Yes and the changelog states conditions which are quite hard to achieve to have this patch in the stable tree. So I am not really convinced it is worth backporting even though the patch itself is trivial.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 11 lines · Michal Hocko
Quoted 6 lines · Sasha Levin
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag, fixing commit:
00f3ca2c2d66mm: memcontrol: per-lruvec stats infrastructure.Yes and the changelog states conditions which are quite hard to achieve to have this patch in the stable tree. So I am not really convinced it is worth backporting even though the patch itself is trivial.
Quite hard to achieve, but the changelog also indicated that this was actually hit and is not just theoretical. Is there something that will prevent this from happening on "real" workloads?
Michal Hocko
maintainerQuoted 9 lines · Sasha Levin
Quoted 8 lines · Michal Hocko
Quoted 6 lines · Sasha Levin
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag, fixing commit:
00f3ca2c2d66mm: memcontrol: per-lruvec stats infrastructure.
Quoted 7 lines
Quoted 3 lines
Yes and the changelog states conditions which are quite hard to achieve to have this patch in the stable tree. So I am not really convinced it is worth backporting even though the patch itself is trivial.
Quite hard to achieve, but the changelog also indicated that this was actually hit and is not just theoretical. Is there something that will prevent this from happening on "real" workloads?
Well, small allocations do not really fail and it would take to configure a really large NUMA system to achieve the same. So I am skeptical.
Signature · 2 lines
Michal Hocko SUSE Labs