]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
swap_pager: Handle large swap_pager_reserve() requests
authorMark Johnston <markj@FreeBSD.org>
Tue, 7 Sep 2021 18:03:52 +0000 (14:03 -0400)
committerMark Johnston <markj@FreeBSD.org>
Tue, 21 Sep 2021 13:38:03 +0000 (09:38 -0400)
commitca85fb7e0bac9ef5f50c79520e3fd8a6e8a26b72
tree3767a2b444138ad65ae70a2c24a5a85af9d77205
parentbcc7e68fcf2c34b5f090f55923adc4debc7cc91d
swap_pager: Handle large swap_pager_reserve() requests

This interface is used solely by md(4) when the MD_RESERVE flag is
specified, as in `mdconfig -a -t swap -s 1G -o reserve`.  It
pre-allocates swap blocks for the entire object.

The number of blocks to be reserved is specified as a vm_size_t, but
swp_pager_getswapspace() can allocate at most INT_MAX blocks.  vm_size_t
also seems like the incorrect type to use here it refers only to the
size of the VM object, not the size of a mapping.  So:
- change the type of "size" in swap_pager_reserve() to vm_pindex_t, and
- clamp the requested number of blocks for a single
  swp_pager_getswapspace() call to INT_MAX.

Reported by: syzkaller
Reviewed by: dougm, alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 686aa9287c6b3658daa2ca0ef1917f2e70a6c07e)
sys/vm/swap_pager.c
sys/vm/swap_pager.h