DragonFlyBSD Kernel Audit
DF-2640 / mkbase2640.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-2640: build the base image.  PFS "testvol" with:
#   /pub            (mode 777, unprivileged users can rm inside it)
#   /pub/<80 x 'p'> (long name > 64 bytes -> DIRENT chain with a data block)
#   /pub/f2         (short name, control entry)
#   /<80 x 'g'>     (long name at PFS root level, root-side trigger)
# Stock, never-corrupted.
set -e
vnconfig -u vn0 2>/dev/null || true
mkdir -p /root/poc/df2640
cd /root/poc/df2640
rm -f base2640.img
truncate -s 64M base2640.img
newfs_hammer2 -L testvol base2640.img >/dev/null
vnconfig -c vn0 /root/poc/df2640/base2640.img
mkdir -p /mnt/h2
mount -t hammer2 /dev/vn0@testvol /mnt/h2
LN1=$(printf '%.0sp' $(seq 1 80))
LN2=$(printf '%.0sg' $(seq 1 80))
mkdir /mnt/h2/pub
chmod 777 /mnt/h2/pub
printf "DF2640BASE-longp" > "/mnt/h2/pub/$LN1"
printf "DF2640BASE-f2"    > /mnt/h2/pub/f2
printf "DF2640BASE-longg" > "/mnt/h2/$LN2"
sync
ls -l /mnt/h2 /mnt/h2/pub
umount /mnt/h2
vnconfig -u vn0
echo BASE2640_OK