From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2F98C79FAF for ; Tue, 8 Sep 2026 22:05:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3597810EDC1; Tue, 8 Sep 2026 22:05:23 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Io/FoVmV"; dkim-atps=neutral Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 222C710EDB7 for ; Tue, 8 Sep 2026 22:05:12 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 9B8D66022D; Tue, 8 Sep 2026 22:05:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 196911F00A3D; Tue, 8 Sep 2026 22:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788905111; bh=uyB42ZmQyZPlt1IJ4g+w6zDkaYw4xb65yD2EjFjyBOU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Io/FoVmVXznOZYV0Ts5fPiDSlsENBvaOgtw0hiMurzAkUT2uoiL9+OppOcJy1H95L Qy0VBvNcFNXbS5LTKmLUAU8fwCFL18pnlcarY67SIaw763fSFh35iHAxj7cleIpL+T H8Tr/TnN7tKy14fHYG3Sr8Q4lw6C8v19CxxG+gRdnyct2QsgiOpSWASP9OWSiGsN16 ZIOXBCLck59wxa+1bwlx2X7nuB7kW/VGIRH0WhVSpv7HNtdXiXDh1cQujJ/65Vut4w gAAabslNO9K1f1pg/h6Kvkv+tV5TM5vczpsAOcFpbkMtufDsoxB+I4DoKC6gkA0NSU 7jnZJxRlgHK0A== From: "Rob Herring (Arm)" Date: Tue, 08 Sep 2026 17:04:52 -0500 Subject: [PATCH v3 15/22] accel: ethosu: Validate convolution parameter MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260908-ethosu-fixes-v3-15-490fe215286f@kernel.org> References: <20260908-ethosu-fixes-v3-0-490fe215286f@kernel.org> In-Reply-To: <20260908-ethosu-fixes-v3-0-490fe215286f@kernel.org> To: Tomeu Vizoso , Oded Gabbay , Frank Li , Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.16-dev X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The U65 NPU_OP_CONV command has no parameter fields, but the validator interpreted bit zero as the U85 weights_ifm2 field. A crafted U65 stream could consequently make validation skip the weight buffer that hardware accesses. Require a zero parameter on U65 and reject the reserved U85 parameter bits. Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Rob Herring (Arm) --- v2: - new patch --- drivers/accel/ethosu/ethosu_device.h | 1 + drivers/accel/ethosu/ethosu_gem.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/accel/ethosu/ethosu_device.h b/drivers/accel/ethosu/ethosu_device.h index c330048dbcca..d7e1e3c8ca12 100644 --- a/drivers/accel/ethosu/ethosu_device.h +++ b/drivers/accel/ethosu/ethosu_device.h @@ -87,6 +87,7 @@ struct gen_pool; #define PMU_EV_TYPE_IDLE 0x20 #define NPU_DMA_REGION_INDEX_MODE BIT(11) +#define NPU_OP_CONV_WEIGHTS_IFM2 BIT(0) enum ethosu_cmds { NPU_OP_STOP = 0x0, diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethosu_gem.c index 974cf562ef49..9c86f9062f55 100644 --- a/drivers/accel/ethosu/ethosu_gem.c +++ b/drivers/accel/ethosu/ethosu_gem.c @@ -764,7 +764,10 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev, st.dma.dst.region, st.dma.dst.offset, dstlen); break; case NPU_OP_CONV: - use_ifm2 = param & 0x1; // weights_ifm2 + if ((ethosu_is_u65(edev) && param) || (param & ~NPU_OP_CONV_WEIGHTS_IFM2)) + return -EINVAL; + + use_ifm2 = param & NPU_OP_CONV_WEIGHTS_IFM2; if (!cmd_state_reg_is_set(&st, NPU_SET_OFM_PRECISION)) return -EINVAL; use_scale = !(st.ofm.precision & 0x100); -- 2.53.0