Skip to content

fs/dax: check for empty/zero entries before calling pfn_to_page()#1310

Open
vfsci-bot[bot] wants to merge 1 commit intovfs.base.cifrom
pw/1088703/vfs.base.ci
Open

fs/dax: check for empty/zero entries before calling pfn_to_page()#1310
vfsci-bot[bot] wants to merge 1 commit intovfs.base.cifrom
pw/1088703/vfs.base.ci

Conversation

@vfsci-bot
Copy link
Copy Markdown

@vfsci-bot vfsci-bot Bot commented May 2, 2026

Series: https://patchwork.kernel.org/project/linux-fsdevel/list/?series=1088703
Submitter: Souvik Banerjee
Version: 1
Patches: 1/1
Message-ID: <20260501233933.2614302-1-souvik@amlalabs.com>
Base: vfs.base.ci
Lore: https://lore.kernel.org/linux-fsdevel/20260501233933.2614302-1-souvik@amlalabs.com


Automated by ml2pr

Commit 98c183a ("fs/dax: don't disassociate zero page entries")
added zero/empty-entry early returns to dax_associate_entry() and
dax_disassociate_entry(), but placed them *after* the
`struct folio *folio = dax_to_folio(entry);` line.  dax_to_folio()
expands to page_folio(pfn_to_page(dax_to_pfn(entry))), and page_folio()
performs READ_ONCE(page->compound_head) -- a real dereference of the
struct page pointer derived from a bogus PFN extracted from the
empty/zero XA value.

On systems where vmemmap covers all of RAM that dereference reads
garbage and is harmless: the early return then discards the result.
On virtio-pmem with altmap (vmemmap stored inside the device), only
the real device PFN range is mapped, so the dereference triggers a
kernel paging fault from the truncate / invalidate path and from the
PMD-downgrade branch of dax_iomap_pte_fault when an entry is being
freed:

  Unable to handle kernel paging request at
  virtual address ffff_fdff_bf00_0008 (vmemmap region)
  Call trace:
   dax_disassociate_entry.isra.0+0x20/0x50
   dax_iomap_pte_fault
   dax_iomap_fault
   erofs_dax_fault

Close the residual gap by moving the dax_to_folio() call after the
zero/empty guard in dax_disassociate_entry().  Apply the same
treatment to dax_busy_page(), which has the identical pattern but
was not touched by the prior fix.

Fixes: 98c183a ("fs/dax: don't disassociate zero page entries")
Fixes: 38607c6 ("fs/dax: properly refcount fs dax pages")
Cc: stable@vger.kernel.org # v6.15+
Cc: Alistair Popple <apopple@nvidia.com>
Signed-off-by: Souvik Banerjee <souvik@amlalabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants