From mboxrd@z Thu Jan 1 00:00:00 1970 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 109D0606A322 for ; Fri, 4 Dec 2026 20:48: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=cDOSM9/U Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C93610E7FA; Fri, 4 Dec 2026 20:48:40 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8278510E7FA for ; Fri, 4 Dec 2026 20:48:34 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 95D0561207; Fri, 4 Dec 2026 20:48:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AEA41F00A06; Fri, 4 Dec 2026 20:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796417313; bh=yTwr1V567Nd7MSTLI5WX2CHur5iC8yufIJc9ASwrWnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=cDOSM9/UyAZ7LH5hWXptV8yM4tE5pBWKqq6RfiKMN0Yvoujq7kXYhlgPe34hioKH8 KWV69v/rSEcVImWbcaogcXM6bm78SlA2rZJdw7ULu84NLYjAUnYTpbwEuwx9qmZe8W Ea9f8RKcqdrdm7DEuwR8p9bFp3oqX18MlmN4Nq7e9bmLaP6JKh1/6PjtHnTMk/TDQ2 73iKuwdJR34nDwTe0+VgldCQELIy0Z00YAwni6/8ifN8SI7yS2XjX0gZ3l10BUAbXB vj+pyA9G9XCch+Di31cksGZzEWhQGyfaE2ugq4WTCm7mhuQW/IK4SIkUnQDYyHHf2I Mac1w0j6EjHpg== Date: Fri, 4 Dec 2026 14:48:31 -0600 From: Rob Herring To: Bilal Hashim Cc: Tomeu Vizoso , Oded Gabbay , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] accel/ethosu: validate strides, format, and overflow in feat_matrix_length() Message-ID: <20261204204831.GA1201682-robh@kernel.org> References: <20261128140630.1172-1-AeeSec@126.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261128140630.1172-1-AeeSec@126.com> 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: , Sender: "dri-devel" X-Spam-Status: No, score=-6.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Sat, Nov 28, 2026 at 10:06:30PM +0800, Bilal Hashim wrote: > In ethosu_gem_cmdstream_copy_and_validate(), `cmd_state_init()` fills > `struct cmd_state` with `0xff` so that missing setup commands can be > detected (leaving `s64 stride_x`, `stride_y`, and `stride_c` equal to > `-1`). > > However, `feat_matrix_length()` never checks whether `fm->stride_y`, > `fm->stride_x`, or `fm->stride_c` are negative (uninitialized), does not > reject invalid format values `(fm->precision >> 6) & 0x3` greater than 1, > and performs unchecked arithmetic on `addr` and `addr + 1`. If a command > stream omits a stride setup command, multiplying by `-1` shrinks `addr` > below `fm->base[tile]`, underestimating `info->region_size[fm->region]` > and weakening the BO bounds check in `ethosu_ioctl_submit_job()`. > > Reject negative strides and unknown formats, and use `check_mul_overflow` > and `check_add_overflow` when computing `addr` and `end = addr + 1`. This is not complete. See v5 of my validation fixes series. Rob