fix(chip-db): correct device labels and add integrity canary
This commit is contained in:
commit
e7e22fc0cc
5 changed files with 284 additions and 92 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -10,7 +10,11 @@ itr4m
|
||||||
tr4mpass
|
tr4mpass
|
||||||
tests/run_tests
|
tests/run_tests
|
||||||
tests/run_mock_tests
|
tests/run_mock_tests
|
||||||
|
<<<<<<< HEAD
|
||||||
.build-flags
|
.build-flags
|
||||||
|
=======
|
||||||
|
tests/chip_db_canary.bin
|
||||||
|
>>>>>>> agent/wf_f342a9f1-9c7-2
|
||||||
|
|
||||||
# OS files
|
# OS files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
||||||
34
Makefile
34
Makefile
|
|
@ -47,8 +47,8 @@ TARGET = tr4mpass
|
||||||
|
|
||||||
all: .build-flags $(TARGET)
|
all: .build-flags $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(OBJS)
|
$(TARGET): .chip-db-canary $(OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -Iinclude -c -o $@ $<
|
$(CC) $(CFLAGS) -Iinclude -c -o $@ $<
|
||||||
|
|
@ -62,9 +62,36 @@ $(TARGET): $(OBJS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
find src -name '*.o' -delete
|
find src -name '*.o' -delete
|
||||||
|
<<<<<<< HEAD
|
||||||
rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) .build-flags
|
rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) .build-flags
|
||||||
|
=======
|
||||||
|
rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) $(CHIP_DB_CANARY_BIN)
|
||||||
|
>>>>>>> agent/wf_f342a9f1-9c7-2
|
||||||
find tests -name '*.o' -delete 2>/dev/null || true
|
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 #
|
# Test target: compile only hardware-independent units #
|
||||||
# No mocks, no real library linkage required for the SUT code. #
|
# No mocks, no real library linkage required for the SUT code. #
|
||||||
|
|
@ -150,5 +177,8 @@ test-mocks: $(MOCK_TARGET)
|
||||||
|
|
||||||
$(MOCK_TARGET): $(MOCK_ALL_SRCS)
|
$(MOCK_TARGET): $(MOCK_ALL_SRCS)
|
||||||
$(CC) $(MOCK_CFLAGS) -o $@ $^ $(MOCK_LDFLAGS)
|
$(CC) $(MOCK_CFLAGS) -o $@ $^ $(MOCK_LDFLAGS)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
.PHONY: all clean test test-mocks .build-flags
|
.PHONY: all clean test test-mocks .build-flags
|
||||||
|
=======
|
||||||
|
>>>>>>> agent/wf_f342a9f1-9c7-2
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,16 @@
|
||||||
* chip_db_table.h -- static chip table with real gaster offsets (part 1).
|
* chip_db_table.h -- static chip table with real gaster offsets (part 1).
|
||||||
*
|
*
|
||||||
* Included by chip_db.c only. Do not include this file elsewhere.
|
* Included by chip_db.c only. Do not include this file elsewhere.
|
||||||
* All values sourced from gaster (github.com/0x7ff/gaster).
|
* All CPIDs, iBoot SRTG strings and memory offsets are sourced from
|
||||||
|
* gaster (github.com/0x7ff/gaster) -- specifically the SecureROM
|
||||||
|
* SRTG -> offset dispatch block in gaster.c:519-808. Each row carries
|
||||||
|
* a "gaster.c:NNN" marker pointing at the SRTG string check that
|
||||||
|
* assigns its offsets, so future audits can grep the source of truth.
|
||||||
|
*
|
||||||
|
* Marketing / .name strings are the human-readable identity of the
|
||||||
|
* SoC and are cross-checked against theiphonewiki.com/wiki/CHIP. They
|
||||||
|
* are the fields the operator sees on stdout, so they must match the
|
||||||
|
* physical device -- see issue #53 for the historical mislabel bug.
|
||||||
*
|
*
|
||||||
* Part 2 (ROP-capable chips and A12+ entries) is in chip_db_table_rop.h,
|
* Part 2 (ROP-capable chips and A12+ entries) is in chip_db_table_rop.h,
|
||||||
* which is included at the end of the array below.
|
* which is included at the end of the array below.
|
||||||
|
|
@ -15,38 +24,15 @@
|
||||||
static const chip_info_t g_chip_table[] = {
|
static const chip_info_t g_chip_table[] = {
|
||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
/* ARMv7 chips (32-bit) */
|
/* ARMv7 chips (32-bit) and 32-bit S-series watch SoCs */
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
/* CPID 0x8947 -- A7, iPhone 5s / iPad Air */
|
/* CPID 0x8950 -- S5L8950 = A6 (APL0598), iPhone 5 / iPhone 5c.
|
||||||
/* gaster: iBoot-1458.2 */
|
* SRTG:[iBoot-1145.3]. gaster.c:519 */
|
||||||
/* A7 is Apple's first ARM64 SoC, but gaster's checkm8 path uses */
|
|
||||||
/* payload_dest_armv7 / notA9_armv7 header -- treat as ARMv7 here. */
|
|
||||||
{
|
|
||||||
.cpid = 0x8947,
|
|
||||||
.name = "A7",
|
|
||||||
.marketing = "iPhone 5s / iPad Air",
|
|
||||||
.checkm8_vulnerable = 1,
|
|
||||||
.config_large_leak = 626,
|
|
||||||
.config_overwrite_pad = 0x660,
|
|
||||||
.insecure_memory_base = 0x34000000,
|
|
||||||
.memcpy_addr = 0x9A3C,
|
|
||||||
.aes_crypto_cmd = 0x7061,
|
|
||||||
.gUSBSerialNumber = 0x3402DDF8,
|
|
||||||
.dfu_handle_request = 0x3402D92C,
|
|
||||||
.usb_core_do_transfer = 0x79ED,
|
|
||||||
.dfu_handle_bus_reset = 0x3402D944,
|
|
||||||
.handle_interface_request = 0x7BC9,
|
|
||||||
.usb_create_string_descriptor = 0x72A9,
|
|
||||||
.usb_serial_number_string_descriptor = 0x3402C2DA,
|
|
||||||
.payload_dest_armv7 = 0x34039800,
|
|
||||||
},
|
|
||||||
|
|
||||||
/* CPID 0x8950 -- S5L8950 (A5-class), Apple TV 3rd gen, iBoot-1145.3 */
|
|
||||||
{
|
{
|
||||||
.cpid = 0x8950,
|
.cpid = 0x8950,
|
||||||
.name = "S5L8950",
|
.name = "A6",
|
||||||
.marketing = "Apple TV (3rd gen) (A5-class)",
|
.marketing = "iPhone 5 / iPhone 5c",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_large_leak = 659,
|
.config_large_leak = 659,
|
||||||
.config_overwrite_pad = 0x640,
|
.config_overwrite_pad = 0x640,
|
||||||
|
|
@ -63,11 +49,12 @@ static const chip_info_t g_chip_table[] = {
|
||||||
.payload_dest_armv7 = 0x10079800,
|
.payload_dest_armv7 = 0x10079800,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8955 -- S5L8955 (A5-class), Apple TV 3rd gen rev A, iBoot-1145.3.3 */
|
/* CPID 0x8955 -- S5L8955 = A6X (APL5598), iPad 4th gen.
|
||||||
|
* SRTG:[iBoot-1145.3.3]. gaster.c:534 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8955,
|
.cpid = 0x8955,
|
||||||
.name = "S5L8955",
|
.name = "A6X",
|
||||||
.marketing = "Apple TV (3rd gen, rev A) (A5-class)",
|
.marketing = "iPad (4th gen)",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_large_leak = 659,
|
.config_large_leak = 659,
|
||||||
.config_overwrite_pad = 0x640,
|
.config_overwrite_pad = 0x640,
|
||||||
|
|
@ -84,12 +71,35 @@ static const chip_info_t g_chip_table[] = {
|
||||||
.payload_dest_armv7 = 0x10079800,
|
.payload_dest_armv7 = 0x10079800,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x7002 -- S1P/S2, Apple Watch Series 1/2 */
|
/* CPID 0x8947 -- S5L8947 = A5 Rev B (APL2498), Apple TV 3rd gen rev A
|
||||||
/* gaster: iBoot-2098.0.0.2.4 */
|
* (AppleTV3,2). Single-core 32 nm die shrink of A5.
|
||||||
|
* SRTG:[iBoot-1458.2]. gaster.c:549 */
|
||||||
|
{
|
||||||
|
.cpid = 0x8947,
|
||||||
|
.name = "S5L8947",
|
||||||
|
.marketing = "Apple TV 3rd gen (rev A) (A5 Rev B)",
|
||||||
|
.checkm8_vulnerable = 1,
|
||||||
|
.config_large_leak = 626,
|
||||||
|
.config_overwrite_pad = 0x660,
|
||||||
|
.insecure_memory_base = 0x34000000,
|
||||||
|
.memcpy_addr = 0x9A3C,
|
||||||
|
.aes_crypto_cmd = 0x7061,
|
||||||
|
.gUSBSerialNumber = 0x3402DDF8,
|
||||||
|
.dfu_handle_request = 0x3402D92C,
|
||||||
|
.usb_core_do_transfer = 0x79ED,
|
||||||
|
.dfu_handle_bus_reset = 0x3402D944,
|
||||||
|
.handle_interface_request = 0x7BC9,
|
||||||
|
.usb_create_string_descriptor = 0x72A9,
|
||||||
|
.usb_serial_number_string_descriptor = 0x3402C2DA,
|
||||||
|
.payload_dest_armv7 = 0x34039800,
|
||||||
|
},
|
||||||
|
|
||||||
|
/* CPID 0x7002 -- S1P (APL0778), Apple Watch Series 1 / Series 2.
|
||||||
|
* SRTG:[iBoot-2098.0.0.2.4]. gaster.c:610 */
|
||||||
{
|
{
|
||||||
.cpid = 0x7002,
|
.cpid = 0x7002,
|
||||||
.name = "S1P",
|
.name = "S1P",
|
||||||
.marketing = "Apple Watch Series 1/2",
|
.marketing = "Apple Watch Series 1 / Series 2",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_overwrite_pad = 0x500,
|
.config_overwrite_pad = 0x500,
|
||||||
.insecure_memory_base = 0x46018000,
|
.insecure_memory_base = 0x46018000,
|
||||||
|
|
@ -105,12 +115,13 @@ static const chip_info_t g_chip_table[] = {
|
||||||
.payload_dest_armv7 = 0x46007800,
|
.payload_dest_armv7 = 0x46007800,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8002 -- S3, Apple Watch Series 3 */
|
/* CPID 0x8002 -- T8002. Shared package family used by S1P/S2 (Watch
|
||||||
/* gaster: iBoot-2651.0.0.1.31 */
|
* Series 1/2) and T1 (MacBook Pro Touch Bar controller).
|
||||||
|
* SRTG:[iBoot-2651.0.0.1.31]. gaster.c:682 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8002,
|
.cpid = 0x8002,
|
||||||
.name = "S3",
|
.name = "S1P/S2/T1",
|
||||||
.marketing = "Apple Watch Series 3",
|
.marketing = "Watch Series 1/2 / MacBook Pro Touch Bar (T1)",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_overwrite_pad = 0x5C0,
|
.config_overwrite_pad = 0x5C0,
|
||||||
.config_hole = 5,
|
.config_hole = 5,
|
||||||
|
|
@ -127,12 +138,13 @@ static const chip_info_t g_chip_table[] = {
|
||||||
.payload_dest_armv7 = 0x48806E00,
|
.payload_dest_armv7 = 0x48806E00,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8004 -- S3, Apple Watch Series 3 (GPS+Cellular) */
|
/* CPID 0x8004 -- T8004 = S3, Apple Watch Series 3 (both GPS and
|
||||||
/* gaster: iBoot-2651.0.0.3.3 */
|
* GPS+Cellular variants share this CPID).
|
||||||
|
* SRTG:[iBoot-2651.0.0.3.3]. gaster.c:697 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8004,
|
.cpid = 0x8004,
|
||||||
.name = "S3",
|
.name = "S3",
|
||||||
.marketing = "Apple Watch Series 3 (GPS+Cellular)",
|
.marketing = "Apple Watch Series 3",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_overwrite_pad = 0x5C0,
|
.config_overwrite_pad = 0x5C0,
|
||||||
.config_hole = 5,
|
.config_hole = 5,
|
||||||
|
|
@ -150,11 +162,36 @@ static const chip_info_t g_chip_table[] = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
/* ARM64 chips (A8 - A9 era, no ROP gadgets needed) */
|
/* ARM64 chips (A7 - A9 era, no ROP gadgets needed) */
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
/* CPID 0x7000 -- A8 variant */
|
/* CPID 0x8960 -- S5L8960 = A7 (APL0698), iPhone 5s / iPad Air /
|
||||||
/* gaster: iBoot-1992.0.0.1.19 */
|
* iPad mini 2 / iPad mini 3. Apple's first ARM64 SoC.
|
||||||
|
* SRTG:[iBoot-1704.10]. gaster.c:564 */
|
||||||
|
{
|
||||||
|
.cpid = 0x8960,
|
||||||
|
.name = "A7",
|
||||||
|
.marketing = "iPhone 5s / iPad Air / iPad mini 2 / iPad mini 3",
|
||||||
|
.checkm8_vulnerable = 1,
|
||||||
|
.config_large_leak = 7936,
|
||||||
|
.config_overwrite_pad = 0x5C0,
|
||||||
|
.insecure_memory_base = 0x180380000,
|
||||||
|
.patch_addr = 0x100005CE0,
|
||||||
|
.memcpy_addr = 0x10000ED50,
|
||||||
|
.aes_crypto_cmd = 0x10000B9A8,
|
||||||
|
.boot_tramp_end = 0x1800E1000,
|
||||||
|
.gUSBSerialNumber = 0x180086CDC,
|
||||||
|
.dfu_handle_request = 0x180086C70,
|
||||||
|
.usb_core_do_transfer = 0x10000CC78,
|
||||||
|
.dfu_handle_bus_reset = 0x180086CA0,
|
||||||
|
.handle_interface_request = 0x10000CFB4,
|
||||||
|
.usb_create_string_descriptor = 0x10000BFEC,
|
||||||
|
.usb_serial_number_string_descriptor = 0x180080562,
|
||||||
|
},
|
||||||
|
|
||||||
|
/* CPID 0x7000 -- S5L8960-derived A8 variant (APL1011), iPod touch 6G
|
||||||
|
* / iPad mini 4.
|
||||||
|
* SRTG:[iBoot-1992.0.0.1.19]. gaster.c:595 */
|
||||||
{
|
{
|
||||||
.cpid = 0x7000,
|
.cpid = 0x7000,
|
||||||
.name = "A8",
|
.name = "A8",
|
||||||
|
|
@ -175,8 +212,8 @@ static const chip_info_t g_chip_table[] = {
|
||||||
.usb_serial_number_string_descriptor = 0x18008062A,
|
.usb_serial_number_string_descriptor = 0x18008062A,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x7001 -- A8X, iPad Air 2 */
|
/* CPID 0x7001 -- A8X (APL1012), iPad Air 2.
|
||||||
/* gaster: iBoot-1991.0.0.2.16 */
|
* SRTG:[iBoot-1991.0.0.2.16]. gaster.c:580 */
|
||||||
{
|
{
|
||||||
.cpid = 0x7001,
|
.cpid = 0x7001,
|
||||||
.name = "A8X",
|
.name = "A8X",
|
||||||
|
|
@ -197,35 +234,13 @@ static const chip_info_t g_chip_table[] = {
|
||||||
.usb_serial_number_string_descriptor = 0x180080C2A,
|
.usb_serial_number_string_descriptor = 0x180080C2A,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8960 -- A10 Fusion (early iBoot) */
|
/* CPID 0x8000 -- S8000 = A9 Samsung 14 nm (APL0898), iPhone 6s /
|
||||||
/* gaster: iBoot-1704.10 */
|
* iPhone 6s Plus / iPhone SE (1st gen).
|
||||||
{
|
* SRTG:[iBoot-2234.0.0.3.3]. gaster.c:641 */
|
||||||
.cpid = 0x8960,
|
|
||||||
.name = "A10 (iBoot-1704)",
|
|
||||||
.marketing = "iPhone 7 / iPhone 7 Plus",
|
|
||||||
.checkm8_vulnerable = 1,
|
|
||||||
.config_large_leak = 7936,
|
|
||||||
.config_overwrite_pad = 0x5C0,
|
|
||||||
.insecure_memory_base = 0x180380000,
|
|
||||||
.patch_addr = 0x100005CE0,
|
|
||||||
.memcpy_addr = 0x10000ED50,
|
|
||||||
.aes_crypto_cmd = 0x10000B9A8,
|
|
||||||
.boot_tramp_end = 0x1800E1000,
|
|
||||||
.gUSBSerialNumber = 0x180086CDC,
|
|
||||||
.dfu_handle_request = 0x180086C70,
|
|
||||||
.usb_core_do_transfer = 0x10000CC78,
|
|
||||||
.dfu_handle_bus_reset = 0x180086CA0,
|
|
||||||
.handle_interface_request = 0x10000CFB4,
|
|
||||||
.usb_create_string_descriptor = 0x10000BFEC,
|
|
||||||
.usb_serial_number_string_descriptor = 0x180080562,
|
|
||||||
},
|
|
||||||
|
|
||||||
/* CPID 0x8000 -- A9 (TSMC), iPhone 6s */
|
|
||||||
/* gaster: same offsets as 0x8003, iBoot-2234.0.0.2.22 */
|
|
||||||
{
|
{
|
||||||
.cpid = 0x8000,
|
.cpid = 0x8000,
|
||||||
.name = "A9",
|
.name = "A9",
|
||||||
.marketing = "iPhone 6s / iPhone SE",
|
.marketing = "iPhone 6s / 6s Plus / SE (Samsung 14 nm, APL0898)",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_overwrite_pad = 0x500,
|
.config_overwrite_pad = 0x500,
|
||||||
.insecure_memory_base = 0x180380000,
|
.insecure_memory_base = 0x180380000,
|
||||||
|
|
@ -244,12 +259,14 @@ static const chip_info_t g_chip_table[] = {
|
||||||
.ttbr0_vrom_off = 0x400,
|
.ttbr0_vrom_off = 0x400,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8003 -- A9 (Samsung), iPhone 6s variant */
|
/* CPID 0x8003 -- S8003 = A9 TSMC 16 nm (APL1022), iPhone 6s /
|
||||||
/* gaster: iBoot-2234.0.0.2.22 */
|
* iPhone 6s Plus / iPhone SE (1st gen). Offset payload matches
|
||||||
|
* 0x8000; only the foundry-identifying CPID differs.
|
||||||
|
* SRTG:[iBoot-2234.0.0.2.22]. gaster.c:624 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8003,
|
.cpid = 0x8003,
|
||||||
.name = "A9",
|
.name = "A9",
|
||||||
.marketing = "iPhone 6s (Samsung variant)",
|
.marketing = "iPhone 6s / 6s Plus / SE (TSMC 16 nm, APL1022)",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_overwrite_pad = 0x500,
|
.config_overwrite_pad = 0x500,
|
||||||
.insecure_memory_base = 0x180380000,
|
.insecure_memory_base = 0x180380000,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
* chip_db_table_rop.h -- chip table part 2: ROP-capable chips + A12+ stubs.
|
* chip_db_table_rop.h -- chip table part 2: ROP-capable chips + A12+ stubs.
|
||||||
*
|
*
|
||||||
* Included by chip_db_table.h inside the g_chip_table[] array.
|
* Included by chip_db_table.h inside the g_chip_table[] array.
|
||||||
* Do not include this file directly. All values from gaster.
|
* Do not include this file directly. All offsets from gaster.c
|
||||||
|
* (github.com/0x7ff/gaster). Each row carries a "gaster.c:NNN" marker
|
||||||
|
* pointing at the SRTG string check that owns those offsets.
|
||||||
*/
|
*/
|
||||||
#ifndef CHIP_DB_TABLE_ROP_H
|
#ifndef CHIP_DB_TABLE_ROP_H
|
||||||
#define CHIP_DB_TABLE_ROP_H
|
#define CHIP_DB_TABLE_ROP_H
|
||||||
|
|
@ -11,8 +13,8 @@
|
||||||
/* ARM64 chips with ROP gadgets (A9X, A10, A10X, A11, T2) */
|
/* ARM64 chips with ROP gadgets (A9X, A10, A10X, A11, T2) */
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
/* CPID 0x8001 -- A9X, iPad Pro (1st gen) */
|
/* CPID 0x8001 -- S8001 = A9X (APL1021), iPad Pro (1st gen).
|
||||||
/* gaster: iBoot-2481.0.0.2.1 */
|
* SRTG:[iBoot-2481.0.0.2.1]. gaster.c:658 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8001,
|
.cpid = 0x8001,
|
||||||
.name = "A9X",
|
.name = "A9X",
|
||||||
|
|
@ -42,12 +44,13 @@
|
||||||
.ttbr0_sram_off = 0x600,
|
.ttbr0_sram_off = 0x600,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8010 -- A10 Fusion (ROP path) */
|
/* CPID 0x8010 -- T8010 = A10 Fusion (APL1W24), iPhone 7 / iPhone 7
|
||||||
/* gaster: iBoot-2696.0.0.1.33 */
|
* Plus / iPod touch 7 / iPad (6th gen) / iPad (7th gen).
|
||||||
|
* SRTG:[iBoot-2696.0.0.1.33]. gaster.c:712 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8010,
|
.cpid = 0x8010,
|
||||||
.name = "A10 (iBoot-2696)",
|
.name = "A10",
|
||||||
.marketing = "iPhone 7 / iPod touch 7G",
|
.marketing = "iPhone 7/7+ / iPod touch 7 / iPad 6 / iPad 7",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_overwrite_pad = 0x5C0,
|
.config_overwrite_pad = 0x5C0,
|
||||||
.config_hole = 5,
|
.config_hole = 5,
|
||||||
|
|
@ -73,12 +76,13 @@
|
||||||
.ttbr0_sram_off = 0x600,
|
.ttbr0_sram_off = 0x600,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8011 -- A10X Fusion, iPad Pro 10.5 / Apple TV 4K */
|
/* CPID 0x8011 -- T8011 = A10X Fusion (APL1071), iPad Pro 10.5" /
|
||||||
/* gaster: iBoot-3135.0.0.2.3 */
|
* iPad Pro 12.9" (2nd gen) / Apple TV 4K (1st gen).
|
||||||
|
* SRTG:[iBoot-3135.0.0.2.3]. gaster.c:736 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8011,
|
.cpid = 0x8011,
|
||||||
.name = "A10X",
|
.name = "A10X",
|
||||||
.marketing = "iPad Pro 10.5\" / Apple TV 4K",
|
.marketing = "iPad Pro 10.5\" / iPad Pro 12.9\" (2nd gen) / Apple TV 4K",
|
||||||
.checkm8_vulnerable = 1,
|
.checkm8_vulnerable = 1,
|
||||||
.config_overwrite_pad = 0x540,
|
.config_overwrite_pad = 0x540,
|
||||||
.config_hole = 6,
|
.config_hole = 6,
|
||||||
|
|
@ -104,8 +108,9 @@
|
||||||
.ttbr0_sram_off = 0x600,
|
.ttbr0_sram_off = 0x600,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8015 -- A11 Bionic, iPhone 8/X */
|
/* CPID 0x8015 -- T8015 = A11 Bionic (APL1W72), iPhone 8 /
|
||||||
/* gaster: iBoot-3332.0.0.1.23 */
|
* iPhone 8 Plus / iPhone X.
|
||||||
|
* SRTG:[iBoot-3332.0.0.1.23]. gaster.c:760 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8015,
|
.cpid = 0x8015,
|
||||||
.name = "A11",
|
.name = "A11",
|
||||||
|
|
@ -135,8 +140,9 @@
|
||||||
.ttbr0_sram_off = 0x600,
|
.ttbr0_sram_off = 0x600,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* CPID 0x8012 -- T2 Security Chip */
|
/* CPID 0x8012 -- T8012 = T2 Security Chip (APL1027), Mac T2 SoC
|
||||||
/* gaster: iBoot-3401.0.0.1.16 */
|
* (iBridge2, based on A10 Fusion).
|
||||||
|
* SRTG:[iBoot-3401.0.0.1.16]. gaster.c:784 */
|
||||||
{
|
{
|
||||||
.cpid = 0x8012,
|
.cpid = 0x8012,
|
||||||
.name = "T2",
|
.name = "T2",
|
||||||
|
|
@ -168,6 +174,9 @@
|
||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
/* A12 and later: NOT checkm8-vulnerable. All offsets zeroed. */
|
/* A12 and later: NOT checkm8-vulnerable. All offsets zeroed. */
|
||||||
|
/* Marketing/name entries only exist so runtime identification and */
|
||||||
|
/* --print-chip-db can honestly report "unsupported chip" rather */
|
||||||
|
/* than "unknown CPID". Not present in gaster (out of scope: T12). */
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
{ .cpid = 0x8020, .name = "A12", .marketing = "iPhone XS / iPhone XR" },
|
{ .cpid = 0x8020, .name = "A12", .marketing = "iPhone XS / iPhone XR" },
|
||||||
|
|
|
||||||
132
tests/chip_db_canary.c
Normal file
132
tests/chip_db_canary.c
Normal file
|
|
@ -0,0 +1,132 @@
|
||||||
|
/*
|
||||||
|
* chip_db_canary.c -- build-time integrity probe for the chip database.
|
||||||
|
*
|
||||||
|
* Compiled and run by the Makefile's .chip-db-canary target, which
|
||||||
|
* is a prerequisite of the main tr4mpass binary when
|
||||||
|
* STRICT_CHIP_DB=1 (default). If any well-known row diverges from
|
||||||
|
* the expected (name substring, marketing substring), the probe
|
||||||
|
* exits non-zero and the build fails.
|
||||||
|
*
|
||||||
|
* The expected substrings are intentionally short and stable so a
|
||||||
|
* legitimate marketing rewrite (e.g. spelling change, added SKU)
|
||||||
|
* does not spuriously break the build. The intent is to catch a
|
||||||
|
* repeat of issue #53 -- where 0x8947 was labeled "A7" and 0x8960
|
||||||
|
* "A10" -- not to freeze every character of every string.
|
||||||
|
*
|
||||||
|
* If a distro-packaged chip table has legitimately diverged from
|
||||||
|
* this file's expectations, `make STRICT_CHIP_DB=0` bypasses the
|
||||||
|
* probe entirely (T5 "Chip-DB canary strictness" note).
|
||||||
|
*
|
||||||
|
* All rows must remain traceable to gaster.c line numbers -- see
|
||||||
|
* include/device/chip_db_table.h and chip_db_table_rop.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "device/chip_db.h"
|
||||||
|
#include "device/chip_db_table.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
struct expected_row {
|
||||||
|
uint32_t cpid;
|
||||||
|
int checkm8_vulnerable;
|
||||||
|
const char *name_substr;
|
||||||
|
const char *marketing_substr;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct expected_row g_expected[] = {
|
||||||
|
/* A5 Rev B -- historically mislabeled as "A7 / iPhone 5s" (issue #53). */
|
||||||
|
{ 0x8947, 1, "S5L8947", "A5 Rev B" },
|
||||||
|
/* A6 / A6X -- historically mislabeled as "Apple TV (A5-class)". */
|
||||||
|
{ 0x8950, 1, "A6", "iPhone 5" },
|
||||||
|
{ 0x8955, 1, "A6X", "iPad" },
|
||||||
|
/* Watch S-series and T1. 0x8002 was mislabeled "S3 Series 3". */
|
||||||
|
{ 0x7002, 1, "S1P", "Watch Series 1" },
|
||||||
|
{ 0x8002, 1, "S1P", "T1" },
|
||||||
|
{ 0x8004, 1, "S3", "Watch Series 3" },
|
||||||
|
/* A7 / A8 / A8X -- 0x8960 was mislabeled as "A10 / iPhone 7" (issue #53). */
|
||||||
|
{ 0x8960, 1, "A7", "iPhone 5s" },
|
||||||
|
{ 0x7000, 1, "A8", "iPod touch 6G" },
|
||||||
|
{ 0x7001, 1, "A8X", "iPad Air 2" },
|
||||||
|
/* A9 foundry variants -- Samsung/TSMC were historically swapped. */
|
||||||
|
{ 0x8000, 1, "A9", "Samsung" },
|
||||||
|
{ 0x8003, 1, "A9", "TSMC" },
|
||||||
|
/* A9X / A10 / A10X / A11 / T2. */
|
||||||
|
{ 0x8001, 1, "A9X", "iPad Pro" },
|
||||||
|
{ 0x8010, 1, "A10", "iPhone 7" },
|
||||||
|
{ 0x8011, 1, "A10X", "iPad Pro" },
|
||||||
|
{ 0x8015, 1, "A11", "iPhone" },
|
||||||
|
{ 0x8012, 1, "T2", "T2" },
|
||||||
|
/* A12+ must be present but explicitly not checkm8-vulnerable. */
|
||||||
|
{ 0x8020, 0, "A12", "iPhone" },
|
||||||
|
{ 0x8101, 0, "A14", "iPhone" },
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef STRICT_CHIP_DB
|
||||||
|
#define STRICT_CHIP_DB 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
#if STRICT_CHIP_DB
|
||||||
|
size_t failed = 0;
|
||||||
|
size_t i;
|
||||||
|
const size_t n = sizeof(g_expected) / sizeof(g_expected[0]);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
const struct expected_row *exp = &g_expected[i];
|
||||||
|
const chip_info_t *row = NULL;
|
||||||
|
const chip_info_t *p;
|
||||||
|
|
||||||
|
for (p = g_chip_table; p->name != NULL; p++) {
|
||||||
|
if (p->cpid == exp->cpid) {
|
||||||
|
row = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (row == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"[chip-db-canary] FAIL: CPID 0x%04X missing from g_chip_table\n",
|
||||||
|
exp->cpid);
|
||||||
|
failed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (row->checkm8_vulnerable != exp->checkm8_vulnerable) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"[chip-db-canary] FAIL: CPID 0x%04X checkm8_vulnerable=%d expected %d\n",
|
||||||
|
exp->cpid, row->checkm8_vulnerable, exp->checkm8_vulnerable);
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
if (strstr(row->name, exp->name_substr) == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"[chip-db-canary] FAIL: CPID 0x%04X .name=\"%s\" missing \"%s\"\n",
|
||||||
|
exp->cpid, row->name, exp->name_substr);
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
if (strstr(row->marketing, exp->marketing_substr) == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"[chip-db-canary] FAIL: CPID 0x%04X .marketing=\"%s\" missing \"%s\"\n",
|
||||||
|
exp->cpid, row->marketing, exp->marketing_substr);
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed != 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"[chip-db-canary] FAIL: %zu divergence(s). Rebuild chip_db_table*.h\n"
|
||||||
|
" from gaster.c:519-808 (0x7ff/gaster) or\n"
|
||||||
|
" bypass with `make STRICT_CHIP_DB=0`.\n",
|
||||||
|
failed);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "[chip-db-canary] OK: %zu rows verified\n", n);
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
(void)g_expected;
|
||||||
|
(void)g_chip_table;
|
||||||
|
fprintf(stderr, "[chip-db-canary] SKIPPED (STRICT_CHIP_DB=0)\n");
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue