From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24CFA304BDF for ; Wed, 18 Feb 2026 22:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771453334; cv=none; b=uf2QtHdXFq+5Hnsufp7Ox2pWPQPqJQT2rbZKLq8eQGR4SWlITc+zs23WjGPHrj68xFOUrecbAhcFrh/RRCtdafqJmZYwHWpvnTPX+BpPfZJk6JpnkzI90mvylj2c2XveSOR94r/VTArCwTLbAzchMnZLC9fN19CPiVR/HnXlScM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771453334; c=relaxed/simple; bh=ZHxw9mjElurFBBFJ5JXCeGqeCu/86mNjtr5wW+CUw/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y0/tTkfGuQljEZl2CFDhsE+s4Pa6wacs0n2H0JsR5xi9IDQTQ4zArA4UaBfYLgJ449Uzc8aty7mBV3k9PQunLyyCEdYE+UnDEw4FQ7f9oZGa6nc1AwtjoFhJt+PXR1N+3an5sOCdJV4pu/QzSVXMwzoUUwhzk6zprmZu+XLdMpk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cTqtQAr9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cTqtQAr9" 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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