summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin
diff options
context:
space:
mode:
authorShakeel Butt <shakeel.butt@linux.dev>2026-11-11 22:12:31 -0800
committerAndrew Morton <akpm@linux-foundation.org>2026-11-22 22:24:12 -0800
commitf6ed0f2a03045e4a059a9e6c14befa40c88e68fb (patch)
treef6164c9a57376233522880bf284d60705c598bcb /tools/perf/scripts/python/bin
parent391f7207cb876b1f68368f2f7aed5abfb242a5ea (diff)
mm: list_lru: fix NULL deref when a folio moves to the root memcg
folio_memcg_list_lru_alloc() makes sure that a folio's memcg has its own lists in a list_lru, such as the THP deferred split queue. It looks up the folio's memcg twice: a fast path under RCU checks if the lists exist, and a slow path takes a reference and allocates them. The fast path returns early for the root memcg, which uses the global lists. The slow path does not check for the root. The memcg can change between the two lookups: when a cgroup is removed, its folios are moved to the parent memcg. If the folio is moved up to the root in between, the slow path gets the root, and __memcg_list_lru_alloc() dereferences the root's parent, which is NULL. Users see a NULL pointer dereference oops while a THP is allocated, such as in a page fault, in khugepaged or at swap-in. tmpfs huge pages are affected too, and for them the oops can also happen in reclaim, for example in kswapd. The task that hits the oops is killed, or the machine panics if panic_on_oops is set. The race is narrow: the folio has to be moved up to the root right between the two lookups. For example, its cgroup is directly below the root and is removed, or has its memory controller disabled, at that moment. Fix it by checking memcg_list_lru_allocated() again in the slow path, like the fast path does. It returns true for the root, which needs no lists of its own. Link: https://patch.msgid.link/20261112061231.2469026-1-shakeel.butt@linux.dev Fixes: ae64f07a6a40 ("mm: list_lru: introduce folio_memcg_list_lru_alloc()") Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reported-by: Chris Mason <mason@kernel.org> Acked-by: Muchun Song (ByteDance) <muchun.song@linux.dev> Reviewed-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Harry Yoo (Meta) <harry@kernel.org> Cc: Dave Chinner <david@fromorbit.com> Cc: David Hildenbrand <david@kernel.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Qi Zheng <qi.zheng@linux.dev> Cc: <stable@vger.kernel.org> mm/list_lru.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions