⬢ DragonFlyBSD Kernel Audit
DF-2343 / run1_baseline.sh
← back to finding ↓ download raw
#!/bin/sh
# run1_baseline.sh -- DF-2343/DF-2344 baseline on the UMCSH harness
# kernel with STOCK codegen (gcc80 -O2, exactly the shipping build).
# Non-fatal scenarios only; nothing here should panic.  The -O0
# semantics variant (run0.sh) demonstrates the source-level defect.
set -e
cd /root/umcs
echo "=== DF-2343/DF-2344 baseline (stock -O2 codegen) ==="
uname -a
sysctl hw.usb.ucom.cons_unit hw.usb.ucom.cons_baud

./umcshctl 1				# layout + divisors[9] instrumentation
./umcshctl 2 1				# calc: rate=1   (bucket (0,115200])
./umcshctl 2 9600
./umcshctl 2 115200
./umcshctl 2 460800
./umcshctl 2 3145728			# max
echo "--- calc via the REAL dispatch (pre_param inlines the range guard) ---"
./umcshctl 3 0				# rate=0: source says div0/OOB; -O2 folds it
./umcshctl 3 9600			# sanity: accepted
./umcshctl 3 3145729			# > max: EINVAL

echo "--- DF-2344: sanity attach (GPIO read OK) ---"
./umcshctl 4 0x01 0			# gpio=0x01 -> 4 ports
ls -l /dev/ttyU* /dev/cuaU* 2>/dev/null || true
./umcshctl 5
./umcshctl 4 0x00 0			# gpio=0x00 -> 2 ports
./umcshctl 5

echo "--- DF-2344: GPIO control transfer FAILS, stack groomed below the frame ---"
./umcshctl 4 0xA5 3			# fail + groom 0xA5 (bit0 set) -> 4?
./umcshctl 5
./umcshctl 4 0x00 3			# fail + groom 0x00 (bit0 clear) -> 2?
./umcshctl 5
./umcshctl 4 0x01 3			# fail + groom 0x01 (bit0 set) -> 4?
./umcshctl 5
./umcshctl 4 0x42 3			# fail + groom 0x42 (bit0 clear) -> 2?
./umcshctl 5

echo "--- DF-2343 claim (c): TIOCSETA with c_ospeed==0 is blocked ---"
./umcshctl 4 0x01 0
./umcshctl 6 9600 2			# seed it_in + it_out = 9600 (harness-only)
./tioc0 tioc /dev/ttyU0.0
./tioc0 tioc /dev/cuaU0.0
./umcshctl 5

echo "--- DF-2343 trigger (1): unprivileged first open of cuaU0 (stock -O2) ---"
./umcshctl 4 0x01 0
pw groupmod dialer -m maxx 2>/dev/null || true
id maxx
ls -l /dev/cuaU0.0 /dev/ttyU0.0
echo "ABOUT TO: su maxx -c firstopen /dev/cuaU0 (stock -O2: folded, expect NO panic)"
su -m maxx -c '/root/umcs/tioc0 firstopen /dev/cuaU0.0' || echo "su rc=$?"
./umcshctl 5
echo "RUN1_BASELINE_DONE"