opnsense-src/sys/vm
Mark Johnston 92cf7227a1 posixshm: Fix handling of sendfile() with largepage objects
sendfile(2) can transmit POSIX shared memory objects.  Typically it will
look up and wire each page before sending it to a socket; once
transmission is complete, the page is unwired and typically released
back into the page queues.  sendfile() has an advisory flag, SF_NOCACHE,
which means, "try to free the page once transmission is complete."  This
is implemented in vm_page_release(), which expects to operate on managed
pages.

Pages belonging a largepage object are de-facto wired not explicitly so.
Thus, vm_page_release() will unwire and, having found no additional
references, free the page.  Because mappings of largepage objects are
unmanaged, userspace can still access the now freed page.

Fix the problem by explicitly wiring largepage pages.  Make the VM
object destructor responsible for unwiring and freeing them.

Add a regression test.

Approved by:	so
Security:	FreeBSD-SA-26:44.posixshm
Security:	CVE-2026-49427
Reported by:	Chris Jarrett-Davies <chrisjd@openai.com>
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57832
2026-06-30 23:16:49 +02:00
..
_vm_phys.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
_vm_radix.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
device_pager.c device_pager: Avoid double-insertion of pages into the pager list 2026-06-30 23:16:24 +02:00
memguard.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
memguard.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
phys_pager.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
pmap.h pmap: move the smp_targeted_tlb_shutdown pointer stuff to amd64 pmap.h 2024-07-01 13:07:38 +00:00
redzone.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
redzone.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sg_pager.c Add sysctl kern.proc.kqueue 2025-04-07 04:28:20 +03:00
swap_pager.c swap_pager: Ensure that swapoff puts swapped-in pages in page queues 2024-11-28 14:38:17 +00:00
swap_pager.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
uma.h uma: Permit specifying max of cache line and some custom alignment 2023-11-16 10:07:18 -05:00
uma_align_mask.h uma: Make the cache alignment mask unsigned 2023-11-16 10:07:16 -05:00
uma_core.c uma: Avoid excessive per-CPU draining 2025-03-31 18:35:33 +00:00
uma_dbg.c uma: Micro-optimize memory trashing 2023-12-08 21:32:43 -05:00
uma_dbg.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
uma_int.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_domainset.c Avoid waiting on physical allocations that can't possibly be satisfied 2025-10-23 08:18:48 +02:00
vm_domainset.h Avoid waiting on physical allocations that can't possibly be satisfied 2025-10-23 08:18:48 +02:00
vm_dumpset.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_extern.h vm: Add kva_alloc_aligned 2024-09-02 08:43:18 +00:00
vm_fault.c vm_fault: Reset m_needs_zeroing properly 2026-04-29 22:12:52 +02:00
vm_glue.c thread: Simplify sanitizer integration with thread creation 2025-02-07 14:46:53 +00:00
vm_init.c Adjust comments referencing vm_mem_init() 2024-06-06 11:23:01 -03:00
vm_kern.c Avoid waiting on physical allocations that can't possibly be satisfied 2025-10-23 08:18:48 +02:00
vm_kern.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_map.c pkru: Fix handling of 1GB largepage mappings 2026-04-29 22:12:56 +02:00
vm_map.h pkru: Fix handling of 1GB largepage mappings 2026-04-29 22:12:56 +02:00
vm_meter.c vm_meter: Fix laundry accounting 2024-10-29 13:04:25 +00:00
vm_mmap.c vm_object: do not assume that un_pager.devp.dev is cdev 2024-11-13 01:19:18 +02:00
vm_object.c vm_object_page_remove(): clear pager even if there is no resident pages 2026-01-28 07:36:21 +01:00
vm_object.h device_pager: Avoid double-insertion of pages into the pager list 2026-06-30 23:16:24 +02:00
vm_page.c posixshm: Fix handling of sendfile() with largepage objects 2026-06-30 23:16:49 +02:00
vm_page.h Avoid waiting on physical allocations that can't possibly be satisfied 2025-10-23 08:18:48 +02:00
vm_pageout.c vm_pageout: Disallow invalid values for act_scan_laundry_weight 2025-05-03 20:22:08 +00:00
vm_pageout.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_pagequeue.h vm_pageout: Add a chicken switch for multithreaded PQ_INACTIVE scanning 2025-01-23 13:58:07 +00:00
vm_pager.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_pager.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
vm_param.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_phys.c vm_phys_early_startup(): Panic if phys_avail[] is empty 2025-04-08 15:38:22 +02:00
vm_phys.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_radix.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_radix.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_reserv.c vm_reserv_reclaim_contig: Return NULL not false 2024-04-17 10:33:26 -04:00
vm_reserv.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_swapout.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_swapout_dummy.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_unix.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vnode_pager.c buf: Add a runningbufclaim() helper 2024-12-06 14:51:09 +00:00
vnode_pager.h Add vnode_pager_clean_{a,}sync(9) 2024-01-18 02:51:33 +02:00