freebsd-dev/sys/vm
Mark Johnston e123264e4d vm: Fix racy checks for swap objects
Commit 4b8365d752 introduced the ability to dynamically register
VM object types, for use by tmpfs, which creates swap-backed objects.
As a part of this, checks for such objects changed from

  object->type == OBJT_DEFAULT || object->type == OBJT_SWAP

to

  object->type == OBJT_DEFAULT || (object->flags & OBJ_SWAP) != 0

In particular, objects of type OBJT_DEFAULT do not have OBJ_SWAP set;
the swap pager sets this flag when converting from OBJT_DEFAULT to
OBJT_SWAP.

A few of these checks are done without the object lock held.  It turns
out that this can result in false negatives since the swap pager
converts objects like so:

  object->type = OBJT_SWAP;
  object->flags |= OBJ_SWAP;

Fix the problem by adding explicit tests for OBJT_SWAP objects in
unlocked checks.

PR:		258932
Fixes:		4b8365d752 ("Add OBJT_SWAP_TMPFS pager")
Reported by:	bdrewery
Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35470
2022-06-20 12:48:14 -04:00
..
_vm_phys.h vm_phys: Try to clean up NUMA KPIs 2020-11-19 03:59:21 +00:00
_vm_radix.h
default_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-13 20:10:35 +03:00
device_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-13 20:10:35 +03:00
memguard.c memguard(9): Fix two typos in source code comments 2022-04-02 13:51:27 +02:00
memguard.h LinuxKPI: Implement ksize() function. 2020-08-29 19:26:31 +00:00
phys_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-13 20:10:35 +03:00
pmap.h Add pmap_enter(9) PMAP_ENTER_LARGEPAGE flag and implement it on amd64. 2020-09-09 21:50:24 +00:00
redzone.c redzone: Raise a compile error if KASAN is configured 2021-07-23 10:47:13 -04:00
redzone.h
sg_pager.c vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops 2021-05-13 20:10:35 +03:00
swap_pager.c vm: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:20 -07:00
swap_pager.h swapoff: add one more variant of the syscall 2021-12-09 02:48:46 +02:00
uma_core.c uma: Mark zeroed slabs as initialized for KMSAN 2022-06-20 12:48:13 -04:00
uma_dbg.c
uma_dbg.h
uma_int.h Improve UMA cache reclamation. 2021-05-02 19:45:23 -04:00
uma.h uma: Add UMA_ZONE_UNMANAGED 2022-02-15 09:25:34 -05:00
vm_domainset.c Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_domainset.h Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_dumpset.h minidump: Use the provided dump bitset 2021-11-19 15:05:52 -04:00
vm_extern.h vm/vm_extern.h, vm/vm_page.h: use sys/kassert.h 2022-02-01 05:55:35 +02:00
vm_fault.c vm_fault: Avoid unnecessary object relocking in vm_fault_copy_entry() 2022-06-14 18:19:07 -04:00
vm_glue.c Remove special kstack allocation code for mips. 2022-01-06 04:43:56 +02:00
vm_init.c vm: Initialize the transient buffer mapping arena with M_WAITOK 2022-04-14 15:46:14 -04:00
vm_kern.c vm_kern: Update KMSAN shadow maps when allocating kmem memory 2022-06-20 12:48:13 -04:00
vm_kern.h
vm_map.c vm: Fix racy checks for swap objects 2022-06-20 12:48:14 -04:00
vm_map.h exec: Reimplement stack address randomization 2022-01-17 16:12:36 -05:00
vm_meter.c vmmeter(): Fix detection of the named swap objects 2022-02-02 11:39:58 +02:00
vm_mmap.c vm: Fix racy checks for swap objects 2022-06-20 12:48:14 -04:00
vm_object.c vm_object: Use the vm_object_(set|clear)_flag() helpers 2022-06-14 12:00:59 -04:00
vm_object.h vm_object: Use the vm_object_(set|clear)_flag() helpers 2022-06-14 12:00:59 -04:00
vm_page.c vm_page: Fix a typo in a source code comment 2022-06-04 12:52:22 +02:00
vm_page.h vm/vm_extern.h, vm/vm_page.h: use sys/kassert.h 2022-02-01 05:55:35 +02:00
vm_pageout.c vm: Fix racy checks for swap objects 2022-06-20 12:48:14 -04:00
vm_pageout.h Add interruptible variant of vm_wait(9), vm_wait_intr(9). 2020-09-08 23:28:09 +00:00
vm_pagequeue.h vm_phys: Try to clean up NUMA KPIs 2020-11-19 03:59:21 +00:00
vm_pager.c pbuf_ctor(): lock the buffer with LK_NOWAIT 2022-02-07 10:05:20 -09:00
vm_pager.h vm/vm_pager.h: use sys/systm.h header 2022-02-01 05:55:35 +02:00
vm_param.h
vm_phys.c vm_phys: avoid waste in multipage allocation 2022-04-26 02:56:23 -05:00
vm_phys.h vm_phys: hide vm_phys_set_pool 2021-12-29 11:17:33 -06:00
vm_radix.c vm: clean up empty lines in .c and .h files 2020-09-01 21:20:45 +00:00
vm_radix.h
vm_reserv.c vm_reserv: use enhanced bitstring for popmaps 2022-01-12 11:03:53 -06:00
vm_reserv.h vm: alloc pages from reserv before breaking it 2021-12-24 12:59:16 -06:00
vm_swapout_dummy.c
vm_swapout.c vm: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:20 -07:00
vm_unix.c Prepare to handle non-trivial errors from vm_map_delete(). 2020-09-09 21:34:31 +00:00
vm.h vm: Fix a common typo in a source code comment 2022-06-05 09:52:32 +02:00
vnode_pager.c vm: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:20 -07:00
vnode_pager.h