Repository navigation
media: apple: fix the ISP IPC fortify warning and AVD test sparse casts - #2829
Conversation
chan_write_msg_index() copies arg1..arg7 with one memcpy() starting at &msg->arg1. With W=1, FORTIFY_SOURCE flags this as a read beyond the arg1 field (__read_overflow2_field). Wrap arg1..arg7 in struct_group(payload, ...) and copy sizeof(msg->payload). The message layout, its size and the bytes written are unchanged. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The PM test backs the code, mailbox and PIODMA apertures with kunit_kzalloc() memory cast to __iomem. Asserting those pointers against NULL makes sparse warn about comparing different address spaces. Cast them back with __force for the check, as for the allocation. Test-only change. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Review at 28bf9f1.
Looks good. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial pre-PR checklist (§1–§6) review at 28bf9f1a800d4d39efbff25b20bbe6975d5b7226:
- Technical / ABI & semantics check:
media: apple: isp(1442df56): wrappingarg1..arg7instruct_group(payload, ...)insidestruct isp_message { ... } __packed;(isp-drv.h:102-114) preserves ABI, layout, alignment, and size: all 7 fields areu64(zero internal padding),offsetof(struct isp_message, payload) == offsetof(struct isp_message, arg1) == 8,sizeof(msg->payload) == 56 == sizeof(*msg) - 8, andstatic_assert(sizeof(struct isp_message) == ISP_IPC_MESSAGE_SIZE)still enforces 64 bytes.chan_write_msg_index()(isp-ipc.c:100-106) preserves the exact destination (p0 + 1), 56-byte copy length, and ordering (payloadcopy ->dma_wmb()->*p0 = msg->arg0->dma_wmb()). This is the canonical kernel pattern forCONFIG_FORTIFY_SOURCEmulti-field copies rather than masking an overflow. Direct member accesses and designated initializers remain valid via the anonymous mirror struct.media: apple: avd(28bf9f1a):avd-pm-test.c:291-296backs the test apertures withkunit_kzalloc()RAM cast to(__force void __iomem *)on the three lines immediately preceding theKUNIT_ASSERT_NOT_NULL()checks. Casting back to(__force void *)strictly for those test assertions does not mask any real MMIO address-space bug and produces identical object code.
- §1 No model gating / §2 Production-ready / §3 Safety: Pass — no model gates, no hacks, IPC write barrier ordering untouched.
- §4 Clean-room & attribution: Pass — both commits carry human author/committer (
Ryan Murray <ryan@aurorasilicon.org>), humanSigned-off-by, zero AI trailers in commits, andAssisted-by:in the PR body. - §5 Evidence: Pass — W=1 C=2 targeted warnings gone, objdump verified, arm64 qemu KUnit ISP/AVD suites 99/100 (single pre-existing
isp_test_sensor_sysfsfailure verified identical on unmodified tip and tracked in #2827),Host tests/host-testsCI green, mergeable (clean). - §6 Naming: Pass.
Verdict: APPROVE — ready for MERGETRAIN-LINUX4.
Assisted-by: LLM (Gemini 4 Neon)
|
Merge-train adversarial review (MERGETRAIN-LINUX4) at 28bf9f1: no blockers. Merges clean on integration/aurora, alone and together with #2828-#2832. Full reviewVERDICT: NO BLOCKERS Blockers: none. Checked:
Nits: none. Assisted-by: LLM (Claude:Opus 5.5) |
|
Post-merge check at cdce3146 (#2828-#2831 merged onto integration/aurora 120d6aa, fleet79 config, LLVM arm64). pahole on isp-ipc.o shows struct isp_message is still 64 bytes with arg0..arg7 at offsets 0, 8, ..., 56 on both sides, and the copy is 56 bytes on both. isp-ipc.o, isp-drv.o, isp-cmd.o and avd-pm-test.o disassemble identically before and after. The two W=1 __read_overflow2_field warnings in isp-ipc.c and the three avd-pm-test.c sparse address-space errors are gone. |
Problem
With W=1 on the integration/aurora tip:
isp-ipc.c: FORTIFY_SOURCE reports__read_overflow2_field, becausechan_write_msg_index()does onememcpy()of arg1..arg7 starting at&msg->arg1.avd-pm-test.c. The test backs MMIO apertures withkunit_kzalloc()memory cast to__iomem, then checks those pointers withKUNIT_ASSERT_NOT_NULL().Change
struct isp_message: wrap arg1..arg7 instruct_group(payload, ...)and copysizeof(msg->payload). The layout, the size (static_assert unchanged) and the bytes written stay the same.avd-pm-test.c: cast back with__force void *for the NULL checks. Test-only.Testing
drivers/media/platform/apple/with the fleet79 config: the fortify and avd-pm-test warnings are gone.isp-ipc.ocalls the same functions as before, andavd-pm-test.ogenerates identical code. Inisp-ipc.oonly register allocation and scheduling around the inlined 56-byte copy changed.apple-isp-hw.isp_test_sensor_sysfs, fails the same way on the unmodified tip (it callssysfs_emit()with a 32-byte stack buffer, andsysfs_emit()requires a page-aligned one). It is listed in Code health: W=1, sparse, checkpatch and DT schema findings in the Apple drivers (integration/aurora 37106688) #2827.struct_group()member indentation, which is the usual layout for that macro.Still to run
A camera stream on any ISP Mac (the IPC write path is byte-identical, so this is a sanity check).
Details
Remaining W=1/sparse output for the directory after this change:
KUnit config and logs (lab store):
traces/ci/20261123-code-health/kunit-media.config,logs/kunit-media.log,logs/kunit-media-tip.log.Assisted-by: LLM (Claude:Opus 5.5)