⬢ DragonFlyBSD Kernel Audit
DF-5036 / analysis.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-5036 evidence: prove the callee-static line tables, the caller-supplied
# bound, and that all five in-tree callers pass exactly 6.
R=/home/maxx/dfbsd/dfbsd
D="$R/sys/dev/drm/amd/display/dc/i2caux"
echo '== the callee-static 6-entry line tables (i2caux_dce110.c:127-143) =='
sed -n '127,143p' "$D/dce110/i2caux_dce110.c"
echo
echo '== the loops: static tables indexed with caller count (:231-232, :271, :278-279, :292) =='
sed -n '231,232p;270,272p;278,280p;291,293p' "$D/dce110/i2caux_dce110.c"
echo
echo '== caller inventory: num passed by each sibling (should be 5 x ARRAY_SIZE of 6-entry tables) =='
for f in dce100/i2caux_dce100.c dce110/i2caux_dce110.c dce112/i2caux_dce112.c dce120/i2caux_dce120.c dcn10/i2caux_dcn10.c; do
  n_aux=$(grep -c 'aux_regs([0-9])' "$D/$f")
  n_hw=$(grep -c 'hw_engine_regs([1-6])' "$D/$f")
  printf '%-28s aux_regs entries=%s  hw_engine_regs entries=%s\n' "$f" "$n_aux" "$n_hw"
done
echo
echo '== each caller computes num = ARRAY_SIZE(its aux_regs) =='
grep -n 'ARRAY_SIZE(.*aux_regs)' "$D"/dce*/i2caux_dce*.c "$D"/dcn10/i2caux_dcn10.c