⬢ DragonFlyBSD Kernel Audit
DF-5774 / run5774.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-5774 run driver (on the guest, as root).
#
# `kernel.debug -n :` (or -n '') -> strtok(optarg, ":") returns NULL ->
# strtol(NULL, NULL, 0) (init.c:394-395) -> SIGSEGV of the vkernel child
# during option parsing, before writepid/any boot output.
#
# CONTROL: `-n 2` parses fine and the boot proceeds ("Using anonymous
# memory" appears).
VK=/usr/obj/usr/src/sys/VKERNEL64/kernel.debug
cd /usr/obj/usr/src/sys/VKERNEL64
pkill -9 -f kernel.debug 2>/dev/null; sleep 1
rm -f /tmp/vk5774.ktrace /tmp/vk5774.log

echo "== vulnerable run: -n : =="
ktrace -i -f /tmp/vk5774.ktrace ./kernel.debug -m 512m -n : > /tmp/vk5774.log 2>&1
echo "monitor rc=$?"
sleep 1
echo "-- kdump signals:"
kdump -f /tmp/vk5774.ktrace 2>/dev/null | grep -E "PSIG|SIGSEGV|SIGILL|exit" | tail -5
echo "-- output was:"; cat /tmp/vk5774.log

echo ""
echo "== control run: -n 2 =="
./kernel.debug -m 512m -n 2 -r /vkroot.img -s > /tmp/vk5774.ctl.log 2>&1 &
CTL=$!
sleep 6
pkill -9 -f kernel.debug 2>/dev/null
grep -a "Using anonymous memory\|KVM mapped" /tmp/vk5774.ctl.log | head -3
exit 0