DragonFlyBSD Kernel Audit
DF-2879 / trigger.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-2879 trigger: register a swap device whose page count is NOT a
# multiple of SWB_DMMAX (64 pages).  swaponvp() rounds the device size
# UP to a stripe multiple and frees the whole last stripe into the blist
# -- including pages beyond the real end of the device.
#
# Run as root on the DragonFly guest.
set -e
echo "== before =="
swapctl -l
sysctl vm.swap_size vm.swap_free

# 266240 bytes = 65 pages of 4096 bytes (520 512-blocks).
truncate -s 266240 /tmp/swapodd
vnconfig -c vn1 /tmp/swapodd
echo "== real device geometry (520 512-blocks = 65 pages) =="
diskinfo /dev/vn1 | head -1

swapctl -a /dev/vn1
echo "== after swapon: kernel registers vn1 with 1024 512-blocks"
echo "   (128 pages -- 63 pages beyond the device end) =="
swapctl -l
sysctl vm.swap_size vm.swap_free