From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795905759; b=vNXB42PXqMs7bvBITMv+9sN6V3lLQtm17CpfXYcZOjSjO8wXZAK/Qj2tH6z1YuGojwE7 O7j9wB/bwgqqIjH0ZJlEX1g6DlizfAY3lfQc65s6zTl2ZFwFe7AdDgyuYXj9pdBbIXyZL TlkM9AxLvzrUya7619uaI3udO/zILvlhxBx1pMl5e18xzxmxC3G5CPXe0fSHpEBBXLPtK uEoHTsV8znixWZP2bCIbZRlGJfaKewzbmb5mItXJVZlZqRS7nAVhVB0m/yXYnK5RX4oQ5 Y2i2juPW+HOKP3YzrfrTShsYliSPcpzhBIb/2IefUdhq87go8Rbs+0FB50ZHoaefaug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795905759; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=NY9XcD97b+mjdMrTe7v6cVpdqnC3Y9+0g46oXugGL3I=; b=rHWJSYh7hTxED23VmLxV+aRoX1DL8t+cNPNFa/WqpRpiDafa1h0EKcHQikRuaWnO+oKh zdyOG0UMgJhPmZxjXBvW5gRCC5ntLBfHE7HOKxQrRC5dZVqbbbKcSrlRxiDH+olVYxeIq WqZcbNv+uko16Ev9Gb4FVVa8erSiH8dV/G9d7c5iwOfQB1EltHv1lxvuQO2TGwRhMKloP DzuA8qw4aSVgOx7BuQtzXBh2JZZCT/a5bjdirABGFAj3CiwQNnMV+hV9jygmLPMgzvrcp RBuiZIqoqkJCpzwhKRyExe+8GbXwhp3myGB6Rfuyx4yEGUPmAbqv/BzXx4GosrNhTwA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WvxOQtzx; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6F4B606A325 for ; Sat, 28 Nov 2026 22:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WvxOQtzx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63A161F0089A; Sat, 28 Nov 2026 22:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795905759; bh=NY9XcD97b+mjdMrTe7v6cVpdqnC3Y9+0g46oXugGL3I=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=WvxOQtzxU7I5PjIwv2boi723nbrA3YmnUDsZ4EHICINUwcdGfckWmT8sBM5oT4Rks RT8fRYIcc4q0toA9M7xLvXgHBq8fygAFODxvtJKWmKR0MML5HW9XWg5ixNtsTwG3uT HrGCd9g8Z+c01tbmnuYesYTgkN2ckNMOMa7GW6SflS5ly1WlASPYVjX0OD88VDReF5 XZwE73PVRqCv9SxrZAv7wpw+Rc90UErTMattouIMI15fFY4Zkl6k9PR8Dn5i5zbIxe aqnDu6dizgX4pADYwpUKs+hUaZr5seVNfYVefZK9bKEBW82uZebE+GWWqx+G3fXXbW Et9nnuHimazSg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 16/17] arm64: dts: apple: t6030: add avd nodes Reply-To: sashiko-reviews@lists.linux.dev To: "Sofus Forstreuter" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org In-Reply-To: <20261128-avd-v4-16-35ad7d52c842@icloud.com> References: <20261128-avd-v4-0-35ad7d52c842@icloud.com> <20261128-avd-v4-16-35ad7d52c842@icloud.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Nov 2026 22:42:39 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Critical] media: apple: avd: unvalidated AV1 frame dimensions cause OOB write and div-by-0 - [High] media: apple: avd: stale job segments and num_alloc in avd_h264_run() - [High] media: apple: avd: IRQ/watchdog race and unsafe m2m_dev IRQ lifetime - [Low] arm64: dts: apple: undocumented apple,t6030-dart compatible in t6030.dtsi - [Low] arm64: dts: apple: undeclared dma-coherent property on video-codec in t6030.dtsi -- commit 951d171bac144253a801bdaf4450cc32e932132a Author: Sofus Forstreuter arm64: dts: apple: t6030: add avd nodes This commit adds the Apple Video Decoder (AVD) and its associated DART IOMMU device tree nodes to the T6030 SoC devicetree. > diff --git a/arch/arm64/boot/dts/apple/t6030.dtsi b/arch/arm64/boot/dts/a= pple/t6030.dtsi > index 524e532830e20..327074092821c 100644 > --- a/arch/arm64/boot/dts/apple/t6030.dtsi > +++ b/arch/arm64/boot/dts/apple/t6030.dtsi > @@ -380,6 +380,39 @@ pmgr_gfx: power-management@290e80000 { > /* child nodes are added in t6030-pmgr.dtsi */ > }; > =20 > + avd_dart: iommu@30b010000 { > + compatible =3D "apple,t6030-dart", "apple,t8110-dart"; [Severity: Low] Does "apple,t6030-dart" need to be added to Documentation/devicetree/bindings/iommu/apple,dart.yaml? Without it, dtbs_check fails on T6030 board device trees because compatible only lists apple,t6020-dart paired with apple,t8110-dart. > + reg =3D <0x3 0x0b010000 0x0 0x4000>; > + interrupt-parent =3D <&aic>; > + interrupts =3D ; > + #iommu-cells =3D <1>; > + power-domains =3D <&ps_avd_sys>; > + }; > + > + video-codec@30b070000 { > + compatible =3D "apple,t6030-avd", "apple,t8122-avd"; [Severity: Critical] Does enabling the AVD node expose unvalidated AV1 frame dimensions in the AVD driver that allow userspace to trigger a kernel out-of-bounds write or a divide-by-zero panic? Neither validate_av1_frame() in the V4L2 core nor the AVD driver validates frame->upscaled_width, frame->frame_width_minus_1, or frame->frame_height_minus_1 from V4L2_CID_STATELESS_AV1_FRAME: drivers/media/platform/apple/avd/avd-av1.c:avd_av1_set_prob() { ... memcpy(vaddr + AVD_AV1_CDFS_OFFSET(length, dst->av1.color_size), av1_ctx->bufs.probs.cpu, sizeof(struct avd_av1_cdfs)); ... } When userspace submits a frame whose dimensions make dst->av1.color_size larger than the capture buffer length, AVD_AV1_CDFS_OFFSET() underflows and memcpy() writes sizeof(struct avd_av1_cdfs) bytes before vaddr. In addition, calc_upscale() divides by upscaled_plane_w (which is 0 when frame->upscaled_width is 0), and set_refs() divides by frame_width_minus_1 + 1 and frame_height_minus_1 + 1 (which wrap to 0 when set to U32_MAX). [Severity: High] Can enabling the AVD node allow userspace to write out of bounds past ctx->job.segments in the H.264 decoder? When userspace queues a slice with V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF set and then issues VIDIOC_STREAMOFF, avd_h264_stop() frees h264_ctx without clearing ctx->job.segments or resetting ctx->job.num: drivers/media/platform/apple/avd/avd-h264.c:avd_h264_stop() { ... kfree(h264_ctx->slices); kfree(h264_ctx); ctx->priv =3D NULL; } After VIDIOC_STREAMON allocates a fresh h264_ctx with slice_num =3D 0, queuing slices with first_mb_in_slice !=3D 0 skips avd_init_job() and appends segments at the stale ctx->job.num index without reallocating, writing past the end of ctx->job.buf.cpu. In addition, avd_h264_done() does not reset slice_num or ctx->job.segments on VB2_BUF_STATE_ERROR when V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF is set, and avd_h264_realloc_slices() skips updating job->num_alloc when reusing an existing buffer. [Severity: High] Does enabling this device expose a race between avd_watchdog_func() and avd_irq_handler(), as well as an unsafe avd->m2m_dev lifetime across IRQ registration? kworker avd_watchdog_func() writel(0, ...MBOX_IRQ_ENABLE) avd_irq_handler() avd_reset(avd) avd_job_finish(ctx, ..._ERROR) ...schedules next job, re-arms watchdog_work cancel_delayed_work(&ctx->watchdog_work) avd_job_finish(ctx, state) <-- corrupts next active job Because avd_watchdog_func() does not synchronize with the threaded IRQ handler before resetting the hardware and finishing the timed-out job, an in-flight avd_irq_handler() can cancel the newly re-armed watchdog_work and complete the next job prematurely. Separately, avd_probe() requests the threaded IRQ and boots the firmware (enabling AVD_REG_MBOX_IRQ_ENABLE) before avd_v4l2_init() allocates avd->m2m_dev, and avd_remove() frees avd->m2m_dev before devm unregisters the IRQ, so an interrupt during probe or remove dereferences NULL or freed memory in v4l2_m2m_get_curr_priv(avd->m2m_dev). Finally, avd_boot() loads firmware with relaxed MMIO stores in avd_memcpy_toio() and starts the Cortex-M3 via writel_relaxed(AVD_RUN_CTRL_UNK_RUN, ...) without a write barrier to order the firmware image writes before CPU startup. > + reg =3D <0x3 0x0b070000 0x0 0x4000>, > + <0x3 0x0b080000 0x0 0x10000>, > + <0x3 0x0b090000 0x0 0x14000>, > + <0x3 0x0b0a4000 0x0 0x4000>, > + <0x3 0x0b100000 0x0 0x10000>; > + reg-names =3D "piodma", "code", "sram", "mbox", "ctrl"; > + interrupt-parent =3D <&aic>; > + interrupts =3D , > + , > + , > + , > + , > + , > + ; > + interrupt-names =3D "mbox0", "mbox1", "mbox2", "mbox3", > + "flag0", "flag1", "piodma"; > + iommus =3D <&avd_dart 0>, <&avd_dart 1>; > + power-domains =3D <&ps_avd_sys>; > + resets =3D <&ps_avd_sys>; > + dma-coherent; [Severity: Low] Should Documentation/devicetree/bindings/media/apple,avd.yaml declare "dma-coherent: true"? Because the binding sets "additionalProperties: false" without listing dma-coherent, dtbs_check rejects this property on video-codec@30b070000. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128-avd-v4-0-3= 5ad7d52c842@icloud.com?part=3D16