HomeFreeBSD

linuxkpi: Handle direct-mapped addresses in linux_free_kmem()

Description

linuxkpi: Handle direct-mapped addresses in linux_free_kmem()

See the analysis in PR 271333. It is possible for driver code to
allocate a page, store its address as returned by page_address(), then
call free_page() on that address. On most systems that'll result in the
LinuxKPI calling kmem_free() with a direct-mapped address, which is not
legal.

Fix the problem by making linux_free_kmem() check the address to see
whether it's direct-mapped or not, and handling it appropriately.

Approved by: re (gjb)
PR: 271333, 274515
Reviewed by: hselasky, bz
Tested by: trasz
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40028

(cherry picked from commit 6223d0b67af923f53d962a9bf594dc37004dffe8)
(cherry picked from commit 4862eb8604d503b52e7c3aa7ff32155b75a1ff93)

Details

Provenance
markjAuthored on Oct 17 2023, 2:26 PM
Reviewer
hselasky
Differential Revision
D40028: linuxkpi: Handle direct-mapped addresses in linux_free_kmem()
Parents
rG952196961fe7: bhyve: Use VMIO_SIOCSIFFLAGS instead of SIOCGIFFLAGS
Branches
Unknown
Tags
Unknown