From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796417313; b=EGJpQIUhA5ELR2dy2radjY6CyNwu1hvoUsA7ran0ZxVYQ23rkOj6tcVURvoYB2GRaGzh abSgJQDNK4jnclQyeZrjKXL+X6UoKOquf07JKctPPnihSyPOReAwPDGg2DyoYYf3HbR+r CV9o2PS6beuz599lWQz6tTDFCL1aD63p2gBiG4/mIRgQgmBHl01dx0wjkFOTjcjREAzCv LnIndj2QQPCFytznGkovU1ZLqkyRNR1Cie/cTOsE9AwYPrndxRZB+q+Rqlg6S18rk5Mph imh9fM9DGppxMSJ9pGN3I8TxajE/3rwv5MkeRp8qPpc3PbbMwsrM1G6/FL4PeYbqIXg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796417313; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=yTwr1V567Nd7MSTLI5WX2CHur5iC8yufIJc9ASwrWnU=; b=d2rg3rmGkI7mHO9Js1DBDGHQhWJ+/hn1uBY++D5pUTUQW2V1ArGh3hfW2YdCcgXkILEk 0yirUQvfVo0A2haWVyBcaLkcx8TJUQRqbeOerpzSrwa9m9+YPTWve7JUMXp1AMOuSSXOi T5QDJZbSjB6BuuZ82jnhG0hn7sr5v0J9xdEZxM/prrkBgWTqkfHA3ZcyjK0NWvBKbFias lNJrwcyLjul0b/ed2QNsGURLGinDSGPY7ZivVd5oi7tZkddD8iK8KZOyvIXfuUWExGOpf S5dW9S8i8pEFCDZZuWNCYWOOo4XbUSEhyI2hxzyFsNCYTH71J9+Ehr7z32nn8J4jrLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="cDOSM9/U"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6434606A32C for ; Fri, 4 Dec 2026 20:48:33 +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: 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261128140630.1172-1-AeeSec@126.com> 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