|
| 1 | +mm: memcg: fix NULL pointer in mem_cgroup_track_foreign_dirty_slowpath() |
| 2 | + |
| 3 | +jira LE-4623 |
| 4 | +Rebuild_History Non-Buildable kernel-4.18.0-553.81.1.el8_10 |
| 5 | +commit-author Kefeng Wang <wangkefeng.wang@huawei.com> |
| 6 | +commit ac86f547ca1002aec2ef66b9e64d03f45bbbfbb9 |
| 7 | +Empty-Commit: Cherry-Pick Conflicts during history rebuild. |
| 8 | +Will be included in final tarball splat. Ref for failed cherry-pick at: |
| 9 | +ciq/ciq_backports/kernel-4.18.0-553.81.1.el8_10/ac86f547.failed |
| 10 | + |
| 11 | +As commit 18365225f044 ("hwpoison, memcg: forcibly uncharge LRU pages"), |
| 12 | +hwpoison will forcibly uncharg a LRU hwpoisoned page, the folio_memcg |
| 13 | +could be NULl, then, mem_cgroup_track_foreign_dirty_slowpath() could |
| 14 | +occurs a NULL pointer dereference, let's do not record the foreign |
| 15 | +writebacks for folio memcg is null in mem_cgroup_track_foreign_dirty() to |
| 16 | +fix it. |
| 17 | + |
| 18 | +Link: https://lkml.kernel.org/r/20230129040945.180629-1-wangkefeng.wang@huawei.com |
| 19 | +Fixes: 97b27821b485 ("writeback, memcg: Implement foreign dirty flushing") |
| 20 | + Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> |
| 21 | + Reported-by: Ma Wupeng <mawupeng1@huawei.com> |
| 22 | + Tested-by: Miko Larsson <mikoxyzzz@gmail.com> |
| 23 | + Acked-by: Michal Hocko <mhocko@suse.com> |
| 24 | + Cc: Jan Kara <jack@suse.cz> |
| 25 | + Cc: Jens Axboe <axboe@kernel.dk> |
| 26 | + Cc: Kefeng Wang <wangkefeng.wang@huawei.com> |
| 27 | + Cc: Ma Wupeng <mawupeng1@huawei.com> |
| 28 | + Cc: Naoya Horiguchi <naoya.horiguchi@nec.com> |
| 29 | + Cc: Shakeel Butt <shakeelb@google.com> |
| 30 | + Cc: Tejun Heo <tj@kernel.org> |
| 31 | + Cc: <stable@vger.kernel.org> |
| 32 | + Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| 33 | +(cherry picked from commit ac86f547ca1002aec2ef66b9e64d03f45bbbfbb9) |
| 34 | + Signed-off-by: Jonathan Maple <jmaple@ciq.com> |
| 35 | + |
| 36 | +# Conflicts: |
| 37 | +# include/linux/memcontrol.h |
| 38 | +diff --cc include/linux/memcontrol.h |
| 39 | +index 2b9c6b1b713c,85dc9b88ea37..000000000000 |
| 40 | +--- a/include/linux/memcontrol.h |
| 41 | ++++ b/include/linux/memcontrol.h |
| 42 | +@@@ -1609,17 -1660,20 +1609,25 @@@ void mem_cgroup_wb_stats(struct bdi_wri |
| 43 | + unsigned long *pheadroom, unsigned long *pdirty, |
| 44 | + unsigned long *pwriteback); |
| 45 | + |
| 46 | + -void mem_cgroup_track_foreign_dirty_slowpath(struct folio *folio, |
| 47 | + +void mem_cgroup_track_foreign_dirty_slowpath(struct page *page, |
| 48 | + struct bdi_writeback *wb); |
| 49 | + |
| 50 | + -static inline void mem_cgroup_track_foreign_dirty(struct folio *folio, |
| 51 | + +static inline void mem_cgroup_track_foreign_dirty(struct page *page, |
| 52 | + struct bdi_writeback *wb) |
| 53 | + { |
| 54 | ++ struct mem_cgroup *memcg; |
| 55 | ++ |
| 56 | + if (mem_cgroup_disabled()) |
| 57 | + return; |
| 58 | + |
| 59 | +++<<<<<<< HEAD |
| 60 | + + if (unlikely(&page_memcg(page)->css != wb->memcg_css)) |
| 61 | + + mem_cgroup_track_foreign_dirty_slowpath(page, wb); |
| 62 | +++======= |
| 63 | ++ memcg = folio_memcg(folio); |
| 64 | ++ if (unlikely(memcg && &memcg->css != wb->memcg_css)) |
| 65 | ++ mem_cgroup_track_foreign_dirty_slowpath(folio, wb); |
| 66 | +++>>>>>>> ac86f547ca10 (mm: memcg: fix NULL pointer in mem_cgroup_track_foreign_dirty_slowpath()) |
| 67 | + } |
| 68 | + |
| 69 | + void mem_cgroup_flush_foreign(struct bdi_writeback *wb); |
| 70 | +* Unmerged path include/linux/memcontrol.h |
0 commit comments