From: sashiko-bot@kernel.org
To: "Sofus Forstreuter" <sofus.c@icloud.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
media-ci@linuxtv.org
Subject: Re: [PATCH v4 16/17] arm64: dts: apple: t6030: add avd nodes
Date: Sat, 28 Nov 2026 22:42:39 +0000 [thread overview]
Message-ID: <sashiko-outbox-239116@kernel.org> (raw)
In-Reply-To: <20261128-avd-v4-16-35ad7d52c842@icloud.com>
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 <sofus.c@icloud.com>
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/apple/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 */
> };
>
> + avd_dart: iommu@30b010000 {
> + compatible = "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 = <0x3 0x0b010000 0x0 0x4000>;
> + interrupt-parent = <&aic>;
> + interrupts = <AIC_IRQ 795 IRQ_TYPE_LEVEL_HIGH>;
> + #iommu-cells = <1>;
> + power-domains = <&ps_avd_sys>;
> + };
> +
> + video-codec@30b070000 {
> + compatible = "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 = NULL;
}
After VIDIOC_STREAMON allocates a fresh h264_ctx with slice_num = 0,
queuing slices with first_mb_in_slice != 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 <threaded-irq>
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 = <0x3 0x0b070000 0x0 0x4000>,
> + <0x3 0x0b080000 0x0 0x10000>,
> + <0x3 0x0b090000 0x0 0x14000>,
> + <0x3 0x0b0a4000 0x0 0x4000>,
> + <0x3 0x0b100000 0x0 0x10000>;
> + reg-names = "piodma", "code", "sram", "mbox", "ctrl";
> + interrupt-parent = <&aic>;
> + interrupts = <AIC_IRQ 788 IRQ_TYPE_LEVEL_HIGH>,
> + <AIC_IRQ 789 IRQ_TYPE_LEVEL_HIGH>,
> + <AIC_IRQ 790 IRQ_TYPE_LEVEL_HIGH>,
> + <AIC_IRQ 791 IRQ_TYPE_LEVEL_HIGH>,
> + <AIC_IRQ 792 IRQ_TYPE_LEVEL_HIGH>,
> + <AIC_IRQ 793 IRQ_TYPE_LEVEL_HIGH>,
> + <AIC_IRQ 794 IRQ_TYPE_LEVEL_HIGH>;
> + interrupt-names = "mbox0", "mbox1", "mbox2", "mbox3",
> + "flag0", "flag1", "piodma";
> + iommus = <&avd_dart 0>, <&avd_dart 1>;
> + power-domains = <&ps_avd_sys>;
> + resets = <&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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-avd-v4-0-35ad7d52c842@icloud.com?part=16
next prev parent reply other threads:[~2026-11-28 22:42 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 22:02 [PATCH v4 00/17] media: apple: add avd driver Sofus Forstreuter
2026-11-28 22:02 ` [PATCH v4 01/17] dt-bindings: media: add apple,avd Sofus Forstreuter
2026-11-28 22:08 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 02/17] media: v4l2: Add P210 pixel format Sofus Forstreuter
2026-11-28 22:02 ` [PATCH v4 03/17] media: v4l2: Add Apple interchange pixel formats Sofus Forstreuter
2026-11-28 22:02 ` [PATCH v4 04/17] media: v4l2-ctrls: validate AV1 context_update_tile_id Sofus Forstreuter
2026-11-28 22:39 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 05/17] media: v4l2-ctrls: validate vp9 tile_rows_log2 Sofus Forstreuter
2026-11-28 22:08 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 06/17] media: apple: add avd driver Sofus Forstreuter
2026-11-28 22:42 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 07/17] media: apple: avd: add h264 support Sofus Forstreuter
2026-11-28 22:43 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 08/17] media: apple: avd: add vp9 support Sofus Forstreuter
2026-11-28 22:49 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 09/17] media: apple: avd: add hevc support Sofus Forstreuter
2026-11-28 22:46 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 10/17] media: apple: avd: add av1 support Sofus Forstreuter
2026-11-28 22:39 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 11/17] arm64: dts: apple: t8103: add avd nodes Sofus Forstreuter
2026-11-28 22:36 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 12/17] arm64: dts: apple: t8112: " Sofus Forstreuter
2026-11-28 22:21 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 13/17] arm64: dts: apple: t8122: " Sofus Forstreuter
2026-11-28 22:37 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 14/17] arm64: dts: apple: t600x: " Sofus Forstreuter
2026-11-28 22:35 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 15/17] arm64: dts: apple: t602x: " Sofus Forstreuter
2026-11-28 22:20 ` sashiko-bot
2026-11-28 22:02 ` [PATCH v4 16/17] arm64: dts: apple: t6030: " Sofus Forstreuter
2026-11-28 22:42 ` sashiko-bot [this message]
2026-11-28 22:02 ` [PATCH v4 17/17] arm64: dts: apple: t6031: " Sofus Forstreuter
2026-11-28 22:42 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-239116@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sofus.c@icloud.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox