⬢ DragonFlyBSD Kernel Audit
DF-5224 / verify.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-5224 mechanical reachability audit: prove no caller of bios_get_image /
# GET_IMAGE can produce an offset+size that wraps uint32.
# Runs from repo root (or pass the repo root as $1).
ROOT="${1:-/home/maxx/dfbsd/dfbsd}"
B="$ROOT/sys/dev/drm/amd/display/dc/bios"

echo "== direct bios_get_image call sites (besides the GET_IMAGE macro) =="
rg -n "bios_get_image\(" "$B" --type c

echo
echo "== every GET_IMAGE offset expression (callers) =="
rg -n "GET_IMAGE\(" "$B" --type c | wc -l
echo "-- offset expressions involving 32-bit-running sums (expect NONE):"
rg -n "GET_IMAGE" "$B" --type c -B4 | rg "offset \+=|offset = [^l]|uint32 offset" || true
echo "-- all offsets derive from le16 fields / fixed macros / + object_info_tbl_offset:"

echo
echo "== struct sizes fed via sizeof(type) (largest atom structs, bytes):"
for t in atom_integrated_system_info_v1_11 atom_firmware_info_v3_2 atom_display_controller_info_v4_2 lcd_info_v2_1; do
	rg -n "struct $t \{" "$ROOT/sys/dev/drm/amd/include/atomfirmware.h" | head -1
done

echo
echo "== uint16_t provenance of master data table offsets =="
rg -n -A3 "struct atom_master_list_of_data_tables_v2_1\{" "$ROOT/sys/dev/drm/amd/include/atomfirmware.h" | head -4

echo
echo "== bios_size ceiling: bios[2]*512 (BIOS_IMAGE_SIZE_OFFSET=2, UNIT=512) =="
rg -n "BIOS_IMAGE_SIZE_OFFSET|BIOS_IMAGE_SIZE_UNIT|OFFSET_TO_ATOM_ROM_IMAGE_SIZE" "$B/bios_parser.c" "$B/bios_parser2.c" | head -6

echo
echo "== SCRATCH_6 defined nonzero on every constructible DC =="
rg -n "\.BIOS_SCRATCH_6 = |NBIO_SR\(BIOS_SCRATCH_6\)" "$ROOT/sys/dev/drm/amd/display/dc"/dce*/dce*_resource.c "$ROOT/sys/dev/drm/amd/display/dc"/dcn10/dcn10_resource.c