From 1442df5626f5bc7af79d0cd01cdf6d3af392b3d4 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 02:42:29 +1100 Subject: [PATCH 1/2] media: apple: isp: group the IPC message payload for memcpy() 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 --- drivers/media/platform/apple/isp/isp-drv.h | 17 ++++++++++------- drivers/media/platform/apple/isp/isp-ipc.c | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/apple/isp/isp-drv.h b/drivers/media/platform/apple/isp/isp-drv.h index 411041d8e82fc..b3dccaf9a7508 100644 --- a/drivers/media/platform/apple/isp/isp-drv.h +++ b/drivers/media/platform/apple/isp/isp-drv.h @@ -101,13 +101,16 @@ struct isp_surf { struct isp_message { u64 arg0; - u64 arg1; - u64 arg2; - u64 arg3; - u64 arg4; - u64 arg5; - u64 arg6; - u64 arg7; + /* Written before arg0, which marks the message valid. */ + struct_group(payload, + u64 arg1; + u64 arg2; + u64 arg3; + u64 arg4; + u64 arg5; + u64 arg6; + u64 arg7; + ); } __packed; static_assert(sizeof(struct isp_message) == ISP_IPC_MESSAGE_SIZE); diff --git a/drivers/media/platform/apple/isp/isp-ipc.c b/drivers/media/platform/apple/isp/isp-ipc.c index 77ef0016a34de..922e990010487 100644 --- a/drivers/media/platform/apple/isp/isp-ipc.c +++ b/drivers/media/platform/apple/isp/isp-ipc.c @@ -97,7 +97,7 @@ static inline void chan_write_msg_index(struct apple_isp *isp, struct isp_message *msg, u32 index) { u64 *p0 = chan_msg_virt(chan, index); - memcpy(p0 + 1, &msg->arg1, sizeof(*msg) - 8); + memcpy(p0 + 1, &msg->payload, sizeof(msg->payload)); /* Make sure we write arg0 last, since that indicates message validity. */ From 28bf9f1a800d4d39efbff25b20bbe6975d5b7226 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 02:42:29 +1100 Subject: [PATCH 2/2] media: apple: avd: drop __iomem before KUNIT_ASSERT_NOT_NULL() 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 --- drivers/media/platform/apple/avd/avd-pm-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/apple/avd/avd-pm-test.c b/drivers/media/platform/apple/avd/avd-pm-test.c index 61b911e51c119..36efb30e83c4b 100644 --- a/drivers/media/platform/apple/avd/avd-pm-test.c +++ b/drivers/media/platform/apple/avd/avd-pm-test.c @@ -291,9 +291,9 @@ static void avd_pm_open_boot_replay_test(struct kunit *test) avd->code = (__force void __iomem *)kunit_kzalloc(test, 0x100, GFP_KERNEL); avd->mbox = (__force void __iomem *)kunit_kzalloc(test, 0x100, GFP_KERNEL); avd->pm.piodma = (__force void __iomem *)kunit_kzalloc(test, 0x28, GFP_KERNEL); - KUNIT_ASSERT_NOT_NULL(test, avd->code); - KUNIT_ASSERT_NOT_NULL(test, avd->mbox); - KUNIT_ASSERT_NOT_NULL(test, avd->pm.piodma); + KUNIT_ASSERT_NOT_NULL(test, (__force void *)avd->code); + KUNIT_ASSERT_NOT_NULL(test, (__force void *)avd->mbox); + KUNIT_ASSERT_NOT_NULL(test, (__force void *)avd->pm.piodma); avd->pm.sram_phys = 0x123456780ULL; for (i = 0; i < 2; i++) { /* Model loss of both ITCM and PIODMA configuration between boots. */