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 D79C6C79FB2 for ; Tue, 8 Sep 2026 22:05:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49AA310EDC5; Tue, 8 Sep 2026 22:05:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="d1PMoXaI"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3E4D210EDBE for ; Tue, 8 Sep 2026 22:05:17 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 204FE44033; Tue, 8 Sep 2026 22:05:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB81A1F00A3F; Tue, 8 Sep 2026 22:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788905117; bh=U6w7FzzToBcqLrZZeveYx7xMc69WBjwh8N7NR4MDbeA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=d1PMoXaIpksor+CnaYLxqVc0kxzQ+XNpq9T3fkhmwXCtJd8Ex4EKXqKLH57u/TaKN b08d+xHY//I6+aZvQsXmx25YS9PVZaVqhNi3AjTkbZqxMpUd+IlS3sFH4+DSL1S0kr AjWTjBHrbGYcARWiZ5E1lv3DFTZ/X9adRZM3lp7k37JVynMdnbc7bR08uJdXF3rm7o VwmKSih6MEvq3J0JvDj5Oeilh2w1Z1cZarN2M5IermWxjmvCE2nKf6XHmqr+yUM6GM eD2V43y+uT00nWpearw5QiXrfDj1CnbfgliGKJs5pc7n4Ci/zUeD66PFiTo7AU/IDt PqIfvsooFhGlA== From: "Rob Herring (Arm)" Date: Tue, 08 Sep 2026 17:04:56 -0500 Subject: [PATCH v3 19/22] accel: ethosu: Restrict dynamic IFM2 weights MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260908-ethosu-fixes-v3-19-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 validator bounds dynamic IFM2 weights as a 1x1 weight matrix, but did not enforce the corresponding kernel shape. A larger crafted kernel could make the NPU access beyond the validated IFM2 feature map. Reject dynamic-weight convolutions whose kernel is not 1x1. 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_gem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethosu_gem.c index 632a2352491a..df26ccd50a96 100644 --- a/drivers/accel/ethosu/ethosu_gem.c +++ b/drivers/accel/ethosu/ethosu_gem.c @@ -590,6 +590,9 @@ static int calc_sizes(struct drm_device *ddev, !cmd_state_reg_is_set(st, NPU_SET_IFM_PAD_RIGHT) || !cmd_state_reg_is_set(st, NPU_SET_IFM_PAD_BOTTOM)) return -EINVAL; + /* Dynamic IFM2 weights are only supported for 1x1 convolutions. */ + if (ifm2 && (st->ifm.width || st->ifm.height[2])) + return -EINVAL; u32 stride_y = ((st->ifm.stride_kernel >> 8) & 0x2) + ((st->ifm.stride_kernel >> 1) & 0x1) + 1; u32 stride_x = ((st->ifm.stride_kernel >> 5) & 0x2) + -- 2.53.0