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=1795905445; b=z8PErtOeJx/CdQCTiD25sW9rTmmeI5GB/buA7gKMfv6ZcohdgxSh/NWjc5508Oxl+iio hDAI9g8D/OuyNZygf6PVKn2yEvdqrzMRP8d5I+i2Z8JuxN93xbOYG9kREdW/MOBKXJiLw E49KvTTMyjDmUyz0APwG+14ypYWhf5StGucB9v4dxL2bAW47E4pxeH7Efm8sYTzmu/auo kWh0ZtnD/ViBlIk5vnrrmrGLVp7wS6fAyJGTjhw0BbjpuYGvSlr/3hXtCmUbFn+0sDtwe hXJcDGh+iwvqqS91g61FkE539mPZ951rag5aSz3I4PPKXrIKaYceEtf2YePzgxisgCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795905445; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=eOawplC8ttK5hIAOGh4EOm/C9G1hDinTk4zH872v91c=; b=PuT4gQYyQ+bx0pG0cuSntfTwC/y3IDWgQSJWWgJn+CPltHd1H5Kj0HYd0zRCrjmTOfKF ge8b88w1Jyg5LfR0z1Ki1k/vKVK5nmVqNqVWYBtKJsS3WKjNWFPPhKsPYvE7kK+kwyzZf LIdTD7kINSNKdid4ofDZ/oBg0mEhUE3VetwEnbTe+qMKzNeNGfDIwxCkXpaGFTGa13p6G sMb8x0yZVdpnynM9Zk/4fXQCvQ1Z584hfPi27EWAr5axXVOxTeuq5EiIEx/uIFf+6ix9p h7fpmtnQf9fBsqMD5XgiXn274p+jKTmWq7p9mUBdZecmZiCW3pAyL6tKVRu2m9iwVWA== 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=Cs2P7nfJ; 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 07E00606A31C for ; Sat, 28 Nov 2026 22:37:24 +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=Cs2P7nfJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B0A61F000C1; Sat, 28 Nov 2026 22:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795905444; bh=eOawplC8ttK5hIAOGh4EOm/C9G1hDinTk4zH872v91c=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Cs2P7nfJsQeKQSd294TUWUr9TIcUoq8Qy7bWdm8Y70ZnVhbpMAQKibrmP57OqZSyS RTpwV0A/Yt9cuQ/Uj55hf3mJ22wmtB1FS9pkjrW//+rjZzAYv/hKR013TohGkEjWj9 djnr7PVoGwsipRcau4ZnBCUDDAI6aZ9urfRRyJiAKIOP6fd19M3ztjp0RU+CSqbEo3 KOib/PLkv6IPU4+6x4T/g/7oCeG4ieOd0cduiOa/tbwH7bl/eH9L6dEW7755lHREaj i7Iw1tMl6iMOrr7UNHhkawtwCLflFEoW+HgW5YuEDa7ORJ7lPXIzhhNRV8GsnisBgp 1c9w+SdGKv9bw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 13/17] arm64: dts: apple: t8122: 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-13-35ad7d52c842@icloud.com> References: <20261128-avd-v4-0-35ad7d52c842@icloud.com> <20261128-avd-v4-13-35ad7d52c842@icloud.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Nov 2026 22:37:24 +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 6 potential issues to consider: - [Critical] media: apple: avd: tile dimension underflow in compute_tiles_non_uniform() - [Critical] media: apple: avd: out-of-bounds access and div-by-zero in AV1 and H264 - [High] media: apple: avd: unsynchronized reset in avd_watchdog_func() vs IRQ - [Medium] media: apple: avd: wrong plane length field in stream_slice_mv() - [Low] arm64: dts: apple: t8122: undocumented apple,t8122-dart compatible string - [Low] arm64: dts: apple: t8122: undocumented dma-coherent property on video-codec -- commit 573c860e172e49f12afc5a250236593df08daaa0 Author: Sofus Forstreuter arm64: dts: apple: t8122: add avd nodes This commit adds the avd_dart IOMMU and video-codec Devicetree nodes to ena= ble the Apple Video Decoder on the Apple T8122 SoC. > diff --git a/arch/arm64/boot/dts/apple/t8122.dtsi b/arch/arm64/boot/dts/a= pple/t8122.dtsi > index 52257fa226317..5f73ad9b247ef 100644 > --- a/arch/arm64/boot/dts/apple/t8122.dtsi > +++ b/arch/arm64/boot/dts/apple/t8122.dtsi > @@ -190,6 +190,39 @@ soc { > nonposted-mmio; > #size-cells =3D <2>; > =20 > + avd_dart: iommu@289010000 { > + compatible =3D "apple,t8122-dart", "apple,t8110-dart"; [Severity: Low] Should "apple,t8122-dart" be documented in Documentation/devicetree/bindings/iommu/apple,dart.yaml? Without a binding update, make dtbs_check fails schema validation on t8122 targets. > + reg =3D <0x2 0x89010000 0x0 0x4000>; > + interrupt-parent =3D <&aic>; > + interrupts =3D ; > + #iommu-cells =3D <1>; > + power-domains =3D <&ps_avd_sys>; > + }; > + > + video-codec@289070000 { > + compatible =3D "apple,t8122-avd"; [Severity: Critical] Enabling "apple,t8122-avd" exposes HEVC decoding to userspace, but can compute_tiles_non_uniform() underflow column_width[] and row_height[] and w= alk off the end of the tile arrays on the kernel heap? drivers/media/platform/apple/avd/avd-hevc.c:compute_tiles_non_uniform() { for (i =3D 0; i < num_cols - 1; i++) { column_width[i] =3D pps->column_width_minus1[i] + 1; sum +=3D column_width[i]; } column_width[i] =3D pic_in_cts_width - sum; } When userspace submits a V4L2_CID_STATELESS_HEVC_PPS control with V4L2_HEVC_PPS_FLAG_TILES_ENABLED set and V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING clear, nothing checks that sum stays below pic_in_cts_width or pic_in_cts_height. If sum exceeds the picture dimension in CTBs, the trail= ing u16 width or height wraps up to 65535, and compute_tile_ids() reads ctb_addr_rs_to_ts[] and writes tile_ids[] out of bounds on the kernel heap. In addition, avd_hevc_validate_sps() does not reject zero pic_width_in_luma_samples or pic_height_in_luma_samples (which causes avd_hevc_compute_tiles() to allocate zero-sized buffers and dereference ZERO_SIZE_PTR in compute_tile_ids()) and does not bound log2_min_luma_coding_block_size_minus3 or log2_diff_max_min_luma_coding_block_size before avd_hevc_compute_tiles() shifts 1 by their sum and divides by max_cu_width. [Severity: Critical] This node also enables AV1 (for the first time in the series) and H264 on T8122, but can an unvalidated V4L2_CID_STATELESS_AV1_FRAME control underflow the capture buffer offsets in avd_av1_set_prob() and avd_av1_run_preamble()? 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)); } frame_width_minus_1 and frame_height_minus_1 are not checked against ctx->decoded_fmt or planes[0].length, so a frame whose computed color_size exceeds length underflows AVD_AV1_CDFS_OFFSET() and AVD_AV1_COLOR_OFFSET(), writing sizeof(struct avd_av1_cdfs) bytes before vaddr in kernel memory. Similarly, avd_h264_validate_sps() does not check SPS macroblock dimensions against ctx->coded_fmt used to size the scratch and auxiliary buffers. Two other input checks are missing in drivers/media/platform/apple/avd/avd-= av1.c: set_tiles() stores u32 tile_group->tile_row and tile_col in signed ints bef= ore checking >=3D V4L2_AV1_MAX_TILE_ROWS / COLS (allowing values >=3D 0x8000000= 0 to index tile_info arrays negatively), and calc_upscale() and set_refs() divide by upscaled_plane_w, width, and height without rejecting upscaled_width =3D= =3D 0 or frame_width_minus_1 / frame_height_minus_1 =3D=3D U32_MAX. [Severity: Medium] In the HEVC backend enabled here, does stream_slice_mv() read the wrong pla= ne length field when computing mv_color_addr? drivers/media/platform/apple/avd/avd-hevc.c:stream_slice_mv() { if (ref_valid) { dma_addr_t mv_color_addr =3D ref->dma.y + (ref->base.vb.planes[0].length - mv_color_size(fmt_width(ctx), fmt_height(ctx))); pusha(mv_color_addr, "mv_colo", 0); } } When userspace queues VB2_MEMORY_DMABUF capture buffers with v4l2_plane.len= gth set to 0, __prepare_dmabuf() populates ref->base.vb.vb2_buf.planes[0].length while leaving ref->base.vb.planes[0].length at 0. Subtracting mv_color_siz= e() then underflows in 32-bit unsigned arithmetic and programs an IOVA roughly 4 GB past ref->dma.y ( triggering a DART IOMMU fault) instead of using ref->dma.aux_start as stream_refs() does. > + reg =3D <0x2 0x89070000 0x0 0x4000>, > + <0x2 0x89080000 0x0 0x10000>, > + <0x2 0x89090000 0x0 0x14000>, > + <0x2 0x890a4000 0x0 0x4000>, > + <0x2 0x89100000 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>; [Severity: High] With mbox0 and resets =3D <&ps_avd_sys> wired up here, can avd_watchdog_fun= c() reset the ps_avd_sys domain while avd_irq_handler() is concurrently accessi= ng avd->mbox? CPU0 (kworker) CPU1 (irq/mbox0-avd) avd_watchdog_func() avd_irq_handler() writel(0, ...IRQ_ENABLE) avd_reset(avd) reset_control_reset() apple_pmgr_reset_assert() readl(...MBOX0_RETRIEVE) <-- MMIO in r= eset avd_job_finish(ctx, ERROR) ...starts next job, schedules watchdog_work cancel_delayed_work(&ctx->watchdog_work) avd_job_finish(ctx, state) <-- wrong= job avd_watchdog_func() clears AVD_REG_MBOX_IRQ_ENABLE in MMIO but does not call disable_irq() or synchronize with the threaded mbox0 handler before resetti= ng ps_avd_sys and finishing the job. On Apple SoCs, reading avd->mbox while APPLE_PMGR_DEV_DISABLE and APPLE_PMGR_RESET are asserted can trigger an SError, and the racing IRQ thread can cancel the newly scheduled watchdog a= nd finish the next decode job early. > + dma-coherent; [Severity: Low] Does Documentation/devicetree/bindings/media/apple,avd.yaml need to allow dma-coherent? The schema specifies additionalProperties: false without listing dma-coherent, causing make dtbs_check to fail on this node. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128-avd-v4-0-3= 5ad7d52c842@icloud.com?part=3D13