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 88A6AE9A04D for ; Wed, 18 Feb 2026 22:22:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA70F10E633; Wed, 18 Feb 2026 22:22:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="cTqtQAr9"; 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 CFB1D10E323 for ; Wed, 18 Feb 2026 22:22:14 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 527CA6185E; Wed, 18 Feb 2026 22:22:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1F6FC19421; Wed, 18 Feb 2026 22:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771453334; bh=ZHxw9mjElurFBBFJ5JXCeGqeCu/86mNjtr5wW+CUw/U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cTqtQAr94tPVsOJC9u3krItTnDDk/5NByGKEubxgdIs3mXY2vpsEbjUT5inY0oRFt 6G1ot150bG357fmIMNMluq6CER1Yn9BFXCtn4J5bsJPe/GrrewSveDyMukPpA7gNNb +vrQvQNY/NlqAbvtGuxyAihB2DSxDpAZmMfVVaxKRsfOM1xNyF4F5RWIk0+wzZGwBX Fx9QLOYn6d/f2v4igRPB4xVzRvhdni4ePHbk6JD6wspYnycMp51SEdFVE0WEOrEOE0 ZXeilo/XUEB2wzDXYBuL5skC6VT3Eb/wMyhSgX0glnNGaJgC0l5ZR16y1VcET2Go0M 85HkWvZfhd0Eg== From: "Rob Herring (Arm)" Date: Wed, 18 Feb 2026 16:21:57 -0600 Subject: [PATCH 3/3] accel: ethosu: Handle possible underflow in IFM size calculations MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260218-ethos-fixes-v1-3-be3fa3ea9a30@kernel.org> References: <20260218-ethos-fixes-v1-0-be3fa3ea9a30@kernel.org> In-Reply-To: <20260218-ethos-fixes-v1-0-be3fa3ea9a30@kernel.org> To: Tomeu Vizoso , Anders Roxell , Oded Gabbay , Thomas Zimmermann , Frank Li Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.15-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" If the command stream has larger padding sizes than the IFM and OFM diminsions, then the calculations will underflow to a negative value. The result is a very large region bounds which is caught on submit, but it's better to catch it earlier. Current mesa ethosu driver has a signedness bug which resulted in padding of 127 (the max) and triggers this issue. Signed-off-by: Rob Herring (Arm) --- drivers/accel/ethosu/ethosu_gem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethosu_gem.c index a735f860a119..d1169001c83d 100644 --- a/drivers/accel/ethosu/ethosu_gem.c +++ b/drivers/accel/ethosu/ethosu_gem.c @@ -245,11 +245,14 @@ static int calc_sizes(struct drm_device *ddev, ((st->ifm.stride_kernel >> 1) & 0x1) + 1; u32 stride_x = ((st->ifm.stride_kernel >> 5) & 0x2) + (st->ifm.stride_kernel & 0x1) + 1; - u32 ifm_height = st->ofm.height[2] * stride_y + + s32 ifm_height = st->ofm.height[2] * stride_y + st->ifm.height[2] - (st->ifm.pad_top + st->ifm.pad_bottom); - u32 ifm_width = st->ofm.width * stride_x + + s32 ifm_width = st->ofm.width * stride_x + st->ifm.width - (st->ifm.pad_left + st->ifm.pad_right); + if (ifm_height < 0 || ifm_width < 0) + return -EINVAL; + len = feat_matrix_length(info, &st->ifm, ifm_width, ifm_height, st->ifm.depth); dev_dbg(ddev->dev, "op %d: IFM:%d:0x%llx-0x%llx\n", -- 2.51.0