⬢ DragonFlyBSD Kernel Audit
DF-3132 / run_guest.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-3132 run: RW mount of FAT32 with bpbFATs=1 / extflags=0x8F
# (active FAT 15, FATMIRROR bit set -> pm_curfat=15, pm_FATs=1, never
# cross-validated at msdosfs_vfsops.c:409-410).  Every FAT update is
# displaced 15*FATsecs sectors past the real FAT (fatblock(),
# msdosfs_fat.c:87) into the data area (sectors 152.. = CANARY.BIN
# clusters).  After unmount the on-disk image shows the FAT writes at the
# wrong place and the canary clusters corrupted.
echo "===== DF-3132: RW mount, kernel-mediated cross-region writes"
vnconfig -c -S 64m /dev/vn0 /root/w/curfat.img
mkdir -p /mnt/df3132
mount_msdos /dev/vn0 /mnt/df3132 || { echo MOUNT-FAIL; exit 1; }
mount | grep df3132
echo "--- CANARY.BIN head bytes BEFORE any modification:"
dd if=/mnt/df3132/CANARY.BIN bs=512 count=1 2>/dev/null | hexdump -C | head -3
echo hi > /mnt/df3132/NEW.TXT
sync
echo "--- CANARY.BIN head bytes AFTER creating NEW.TXT (FAT writes land here):"
dd if=/mnt/df3132/CANARY.BIN bs=512 count=1 2>/dev/null | hexdump -C | head -3
sync
umount /mnt/df3132
vnconfig -u vn0
echo "--- FAT region (sectors 32..40) after umount: should hold NEW.TXT chain if correct"
dd if=/root/w/curfat.img bs=512 skip=32 count=1 2>/dev/null | hexdump -C | head -4
echo "--- misplaced-FAT landing zone (sectors 152..160): should be 0xAA canary if correct"
dd if=/root/w/curfat.img bs=512 skip=152 count=1 2>/dev/null | hexdump -C | head -4
echo "--- canary file content area (clusters 30..33 = sectors 152..167) md5:"
dd if=/root/w/curfat.img bs=512 skip=152 count=64 2>/dev/null | md5
echo "DONE-DF3132"