Page MenuHomeFreeBSD

linuxkpi: gracefully handle page lookup failure in lkpi_vmf_insert_pfn_prot_locked
ClosedPublic

Authored by ashafer on Oct 28 2025, 6:11 PM.
Tags
None
Referenced Files
F140972433: D53412.diff
Tue, Dec 30, 6:45 AM
Unknown Object (File)
Mon, Dec 29, 9:24 PM
Unknown Object (File)
Fri, Dec 19, 6:37 AM
Unknown Object (File)
Wed, Dec 10, 10:50 PM
Unknown Object (File)
Fri, Dec 5, 4:56 AM
Unknown Object (File)
Nov 24 2025, 9:52 AM
Unknown Object (File)
Nov 23 2025, 11:32 AM
Unknown Object (File)
Nov 2 2025, 9:10 PM

Details

Summary

Currently lkpi_vmf_insert_pfn_prot_locked will check the page iter to
find a usage of the page. If no page was found, it continues on to
try using PHYS_TO_VM_PAGE() to get a page. Currently it does not check
if a valid page was found before passing it to vm_page_busy_acquire,
which can cause a kernel page fault as vm_page_busy_acquire expects
a valid page pointer.

This can easily be triggered while starting KDE6 in wayland mode, which
many users have been reporting. With this change plasma6 starts properly
in wayland mode.

Sponsored by: NVIDIA

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Oct 28 2025, 7:01 PM

+kbowling (mentor) to confirm I can submit this myself.

alc added inline comments.
sys/compat/linuxkpi/common/src/linux_page.c
349

I just saw the MFC of this change. Since the iterator, pages, is a local variable within this function that will go out of scope when the function returns, there is no need to reset it immediately before that return.

sys/compat/linuxkpi/common/src/linux_page.c
349

Sorry I had thought this was a cleanup function that did more, I was matching the teardown before the goto statement below. Is this something worth removing then or leave as-is since it's a noop?

sys/compat/linuxkpi/common/src/linux_page.c
349

Sorry I missed this. It would be better to remove it, just to avoid setting a confusing example.