You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mm: cachestat: fix folio read-after-free in cache walk
In cachestat, we access the folio from the page cache's xarray to compute
its page offset, and check for its dirty and writeback flags. However, we
do not hold a reference to the folio before performing these actions,
which means the folio can concurrently be released and reused as another
folio/page/slab.
Get around this altogether by just using xarray's existing machinery for
the folio page offsets and dirty/writeback states.
This changes behavior for tmpfs files to now always report zeroes in their
dirty and writeback counters. This is okay as tmpfs doesn't follow
conventional writeback cache behavior: its pages get "cleaned" during
swapout, after which they're no longer resident etc.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: cf264e1 ("cachestat: implement cachestat syscall")
Reported-by: Jann Horn <[email protected]>
Suggested-by: Matthew Wilcox <[email protected]>
Signed-off-by: Nhat Pham <[email protected]>
Signed-off-by: Johannes Weiner <[email protected]>
Tested-by: Jann Horn <[email protected]>
Cc: <[email protected]> [6.4+]
Signed-off-by: Andrew Morton <[email protected]>
0 commit comments