fix(chip-db): rebuild chip_db_table*.h from gaster canonical + strict canary

Rewrite the .name / .marketing fields and banner comments in
include/device/chip_db_table.h and chip_db_table_rop.h from gaster's
canonical SecureROM SRTG -> offset table (gaster.c:519-808), so the
CLI announces the physical chip that is actually plugged in. Each
row carries a "gaster.c:NNN" comment marker traceable to the source
of truth. Offsets, CPIDs and struct layout are unchanged.

Relabels: 0x8947 (was "A7 / iPhone 5s", now S5L8947 = A5 Rev B /
Apple TV 3rd gen rev A); 0x8950 / 0x8955 (were "A5-class Apple TV",
now A6 / A6X); 0x8960 (was "A10 / iPhone 7", now A7 / iPhone 5s);
0x8002 (was "S3 / Watch Series 3", now S1P/S2/T1 covering Watch
Series 1/2 and MacBook Pro Touch Bar T1); 0x8004 GPS+Cellular
qualifier dropped; 0x8000 / 0x8003 A9 Samsung/TSMC labels swapped
to match APL0898 / APL1022; 0x8010 / 0x8011 marketing broadened to
cover the full ship list.

Add tests/chip_db_canary.c, wired as a build-time prerequisite of
tr4mpass via the new Makefile .chip-db-canary target. The probe
walks a golden expected (cpid, name-substr, marketing-substr,
checkm8) table and fails the build on drift, defeating a repeat of
issue #53. STRICT_CHIP_DB=1 by default; make STRICT_CHIP_DB=0
bypasses the probe for distro-package chip-table update races
(T5 "Chip-DB canary strictness" note).

Files modified:
- include/device/chip_db_table.h
- include/device/chip_db_table_rop.h
- Makefile
- .gitignore
- tests/chip_db_canary.c (new)

Closes: #53
This commit is contained in:
Moussa Ouallaf 2026-07-17 02:30:01 +02:00
parent d18b57a66f
commit 54c0ad652c
5 changed files with 275 additions and 95 deletions

View file

@ -18,17 +18,40 @@ TARGET = tr4mpass
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(TARGET): .chip-db-canary $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -Iinclude -c -o $@ $<
clean:
find src -name '*.o' -delete
rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET)
rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) $(CHIP_DB_CANARY_BIN)
find tests -name '*.o' -delete 2>/dev/null || true
# ------------------------------------------------------------------ #
# Chip DB integrity canary (T5, issue #53). #
# #
# Rebuilt and re-run on every $(TARGET) build. If any well-known #
# row in include/device/chip_db_table*.h diverges from tests/ #
# chip_db_canary.c's expected (name, marketing, checkm8) tuple, the #
# probe exits non-zero and the whole build fails -- guarding against #
# a repeat of the 0x8947/0x8960 mislabel bug where the CLI announced #
# the wrong device family. Bypass with STRICT_CHIP_DB=0 only when a #
# distro-packaged chip table has legitimately diverged. #
# ------------------------------------------------------------------ #
STRICT_CHIP_DB ?= 1
CHIP_DB_CANARY_BIN = tests/chip_db_canary.bin
.chip-db-canary: tests/chip_db_canary.c include/device/chip_db_table.h \
include/device/chip_db_table_rop.h include/device/chip_db.h
@$(CC) -Wall -Wextra -std=c99 -D_GNU_SOURCE -O2 -Iinclude \
-DSTRICT_CHIP_DB=$(STRICT_CHIP_DB) \
tests/chip_db_canary.c -o $(CHIP_DB_CANARY_BIN)
@./$(CHIP_DB_CANARY_BIN)
.PHONY: all clean test test-mocks .chip-db-canary
# ------------------------------------------------------------------ #
# Test target: compile only hardware-independent units #
# No mocks, no real library linkage required for the SUT code. #
@ -99,5 +122,3 @@ test-mocks: $(MOCK_TARGET)
$(MOCK_TARGET): $(MOCK_ALL_SRCS)
$(CC) $(MOCK_CFLAGS) -o $@ $^ $(MOCK_LDFLAGS)
.PHONY: all clean test test-mocks