Since commit 8625147cafaa ("hugetlbfs: don't delete error page from pagecache"), a poisoned hugetlb folio stays in the page cache, and we must not access its poisoned pages. However, hugetlbfs_zero_partial_page() zeroes the partial folio of an unaligned hole punch without checking for poison, which can cause issues like machine-checks. Let's fix it by simply not zeroing poisoned folios. We don't really care about their content: the folio can no longer be mapped, and read() only returns data up to the first poisoned page. Only zeroing the pages that are not poisoned would need more thought, as we cannot reliably identify the poisoned pages; that is future work. Note that a folio that gets poisoned concurrently, after we checked it, can still be zeroed, and sync'ing with memory failure handling is also left as future work. This has low urgency, as it requires a hole punch on a poisoned folio. Fixes: 8625147cafaa ("hugetlbfs: don't delete error page from pagecache") Cc: Reported-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) --- fs/hugetlbfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 2e8672ae2fd52..5437a55d14f1c 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -656,7 +656,8 @@ static void hugetlbfs_zero_partial_page(struct hstate *h, if (!end) end = huge_page_size(h); - folio_zero_segment(folio, (size_t)start, (size_t)end); + if (!folio_test_hwpoison(folio)) + folio_zero_segment(folio, (size_t)start, (size_t)end); folio_unlock(folio); folio_put(folio); -- 2.56.1