Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD5A1606A329 for ; Sat, 28 Nov 2026 14:13:46 +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=nuodmeEu Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1879E10E0B1; Sat, 28 Nov 2026 14:13:41 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4F3310E0B1 for ; Sat, 28 Nov 2026 14:13:35 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 77F374393F; Sat, 28 Nov 2026 14:13:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45EC41F00893; Sat, 28 Nov 2026 14:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795875215; bh=UGYTDbs7jsSDM1JddkOhWAY/9NLD7RtUAEhpPKOZiI0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=nuodmeEuiyU/SH2v213J4tkGiGH49bEC94Q9eD2ej+9PS0dHeN3M+MnBGrVCqPnIR cqoLWlpzaJ7VcH4JX1db6vFb/JZvxNVQdOhJ8vJK7JBEpHw6i3G10Y9a1GF8X06CtN 3VomZT4dDeFOe6sZXWNuDXoaxBu9uJeFiNPLVde+efTEPFvaEmNg4xlgyCrPSSgBHg +v95m40toRBmT7lEuLaGKXkZtEh4d560+rNo8cyxYz+9sNA3caScrUnLPlb4Qhqinx yrzMU0JtRIMmzLyluwIhX1gu3smi0rOhT1r8fdyHb+LyXpI9rJ4fcF7IbHZbzps+A5 np2RziaDnvc8Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] accel/amdxdna: Fix NULL pointer dereference and u32 underflow in aie2_message To: "Bilal Hashim" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261128140537.1325-1-AeeSec@126.com> References: <20261128140537.1325-1-AeeSec@126.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Nov 2026 14:13:34 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] accel/amdxdna: missing Fixes trailers for 71829d7f2f70 and 3a0ff7b98af4 -- commit 9793e7703171a10921840797a04510b39e48e1d3 Author: Bilal Hashim > accel/amdxdna: Fix NULL pointer dereference and u32 underflow in aie2_mes= sage > > amdxdna_cmd_get_payload() returns NULL and sets *size =3D 0 when the > user-supplied command header in the shared command BO has an invalid > AMDXDNA_CMD_COUNT (for example, count <=3D num_masks or exceeding the BO > size), or if amdxdna_gem_vmap() fails. > > However, the eight command payload helpers in aie2_message.c do not > check the return value of amdxdna_cmd_get_payload() for NULL before > dereferencing it or passing it to memcpy(): > > 1. In aie2_init_exec_dpu_req(): > - `if (cmd_len - sizeof(*sn) > sizeof(dpu_req->payload))` performs an > unsigned 32-bit subtraction (`u32 cmd_len - sizeof(*sn)`). If > `cmd_len < sizeof(*sn)` (for instance, `cmd_len =3D=3D 4`), on 64-bit > architectures `sizeof(*sn)` is `size_t`, so `(size_t)cmd_len - > sizeof(*sn)` wraps around and is rejected, unless `cmd_len` is 0 > (when `sn =3D=3D NULL`) or if `sn` is dereferenced when `cmd_len` is > valid for the check on 32-bit platforms. More importantly, when > `cmd_len < sizeof(*sn)` or `sn =3D=3D NULL`, `cmd_len < sizeof(*sn)` > is not explicitly checked first. > 2. In aie2_init_exec_cu_req(), aie2_cmdlist_fill_cf(), and > aie2_cmdlist_fill_npu_cf(): > - When `amdxdna_cmd_get_payload()` returns `NULL` with `cmd_len =3D=3D= 0`, > the size check (`cmd_len > ...` or `*size < sizeof(...) + cmd_len`) > passes, and if `amdxdna_cmd_get_cu_idx()` succeeds (because the CU > mask word in the command BO is non-zero), `cmd` (`NULL`) is passed > to `memcpy()`, or in future/non-zero paths dereferenced directly. > 3. Similarly, in aie2_cmdlist_fill_dpu(), aie2_cmdlist_fill_npu_dpu(), > aie2_cmdlist_fill_npu_preempt(), and aie2_cmdlist_fill_npu_elf(), > checking `!sn` / `!pd` right after `amdxdna_cmd_get_payload()` makes > the error handling explicit and consistent with > aie2_cmdlist_multi_execbuf(). > > Add explicit NULL checks after every amdxdna_cmd_get_payload() call and > check `cmd_len < sizeof(*sn)` in aie2_init_exec_dpu_req() before > subtracting `sizeof(*sn)`. > > Signed-off-by: Bilal Hashim [Severity: Low] 71829d7f2f70 ("accel/amdxdna: Use MSG_OP_CHAIN_EXEC_NPU when supported") dropped the NULL payload checks when refactoring the CF, DPU, and NPU helpers, and 3a0ff7b98af4 ("accel/amdxdna: Support preemption requests") added aie2_cmdlist_fill_npu_preempt() and aie2_cmdlist_fill_npu_elf() without them. Should this include: Fixes: 71829d7f2f70 ("accel/amdxdna: Use MSG_OP_CHAIN_EXEC_NPU when suppo= rted") Fixes: 3a0ff7b98af4 ("accel/amdxdna: Support preemption requests") --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128140537.1325= -1-AeeSec@126.com?part=3D1