summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNhat Pham <nphamcs@gmail.com>2024-02-20 06:01:21 +0300
committerAndrew Morton <akpm@linux-foundation.org>2024-02-24 04:27:13 +0300
commit3a75cb05d53f4a6823a32deb078de1366954a804 (patch)
tree2d12f8e19830acaa0e611ea370561d1b8cb3d946 /lib
parent00130266f67fcf67d8a721f241e90a4b7b1f4cfc (diff)
downloadlinux-3a75cb05d53f4a6823a32deb078de1366954a804.tar.xz
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/20240220153409.GA216065@cmpxchg.org Fixes: cf264e1329fb ("cachestat: implement cachestat syscall") Reported-by: Jann Horn <jannh@google.com> Suggested-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Nhat Pham <nphamcs@gmail.com> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Tested-by: Jann Horn <jannh@google.com> Cc: <stable@vger.kernel.org> [6.4+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
0 files changed, 0 insertions, 0 deletions