Latent 32-bit block arithmetic in the stick's growth and the GPT reader #182

Open
opened 2026-11-11 21:34:09 +00:00 by rajames · 0 comments
Owner

Found

kernel/src/v4/sk_v4_grow.c dev_rw4k: (uint32_t)devblock * 4u; kernel/src/gpt.c: (uint32_t)(ent_lba / 2u) + i, st->first_fblock. Each truncates past 4 TiB of 1 KiB blocks. Unreachable today (Artemis is capped at 256 GiB, STICK_ARTEMIS_CAP_GIB; the block layer's total_blocks is 32-bit), so consistent -- but nothing says so where the casts are.

Done when

  • A compile-time check that the cap fits the 32-bit block numbers, beside the casts

🤖 Filed with Claude Code -- the code review of 2026-11-11, at 4d42d25c (Captain Bob, 2026-11-11: "File the review findings as issues"). Read, not run: each is to be confirmed by a test written first and seen to fail.

### Found `kernel/src/v4/sk_v4_grow.c` `dev_rw4k`: `(uint32_t)devblock * 4u`; `kernel/src/gpt.c`: `(uint32_t)(ent_lba / 2u) + i`, `st->first_fblock`. Each truncates past 4 TiB of 1 KiB blocks. Unreachable today (Artemis is capped at 256 GiB, `STICK_ARTEMIS_CAP_GIB`; the block layer's `total_blocks` is 32-bit), so consistent -- but nothing says so where the casts are. ### Done when - [ ] A compile-time check that the cap fits the 32-bit block numbers, beside the casts 🤖 Filed with [Claude Code](https://claude.com/claude-code) -- the code review of 2026-11-11, at `4d42d25c` (Captain Bob, 2026-11-11: "File the review findings as issues"). Read, not run: each is to be confirmed by a test written first and seen to fail.
rajames added the area/kernel
kind
chore
priority
nice
status
backlog
labels 2026-11-11 21:34:10 +00:00
Sign in to join this conversation.