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=1796454166; b=ygFscd2+T7/EboKUvf385PL0f0zwwlVMaSZRPuJ3hWxmwxMXftt3FJSAp3NicMvYwC+c VbNACzu05E6qNKAyODzLDW4tEVrRGoBHkKBtbyBeR9JCLnERyghMHaUzm2lGyXfDAOCUP nhi3nYUsokMzrnoCgW/RTY/lA9oiIn12kQlt5uKX1w1zwS1GsGOo4aPF7P/3Uk3DnfCGA I+F4JXkiEy5e9FJY7Lqt8QSJ6z2K4CImzCmf8PuTLf8LoFL13csknmvrcTxscMTE8s0Es VZEE3hoqdqB81av/UEtq8it7Et9ubibBrMjZOKGgGwy/Oi4KImoIkGvDTtFWpxyJ0Ig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796454166; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=vpq1R/pe9IYg/O7u3Jf9rbEP+evnf3+tdjPeUagw8yA=; b=N0nIkDDyQJGnRlaA9XSNcFsoXnrXVqVROES71vOtmpVYx66cc0YGRfQ5HCGAK+DWSfO/ WwEee8M7GwAt7Z7CR4BWn8bGtA/AHbPZQbxrHhyccPV+/RaqusX5LnxrDE4Hlxgwwu8mX dca7lgWa0pfyFw6FRJye5yZtWqKIsnoIsGEbgPSIrQBHqF2j7vsBpqLt9pmOOhp7+RNXW Q67rLFBZUq5fTvT3W8twFl0/LWSnPM8wZ76E7SDteIcczTa1cdfxKFomXpqA7tbSQcHeL Gz2RzQ6iKT9yL8Jrn3xwhH6sOYLvfp+WU3TBGy2lA+HCHPyDGmvj09XyJfbRFIy7nng== 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=MKYnmLU6; 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 D4EA2606A322 for ; Sat, 5 Dec 2026 07:02: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=MKYnmLU6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 938C91F0092B; Sat, 5 Dec 2026 07:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796454166; bh=vpq1R/pe9IYg/O7u3Jf9rbEP+evnf3+tdjPeUagw8yA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=MKYnmLU6AuLFwBuoODsSHkPSV/vCc7NKIk1pJSrMtnGOx+GEHRSbRv8l1iyb1MR2D g3JQ12yeTNP/65VMCL+kNuPIEaSISJVOwzFOv95Zce5E0fCJZqeOPe0BtZFDPQ2Znz bOketZDTT0H9XSr7yEpvwzzqxBbuZarVyiMJHJ06ADixUXH00itQB7Ubi7LY4bu97V bOYhdTF0NjQSdT0JvSjVj4dgh/R8VPfGXYgJsSJgLhliRktiIdmmgdmLBHOx93MKvm 9lgQ5V7sNKvOA5iLr5aVZVrjC/V9d7KqptN31UGXMAKX00G90e5mwV3H25ZAnAvlBv n1pxbuITN8m2Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] crypto: bcm - Reject requests with too many fragments Reply-To: sashiko-reviews@lists.linux.dev To: "Praneeth Balasubramanian" , "Herbert Xu" , "David S. Miller" Cc: linux-crypto@vger.kernel.org In-Reply-To: <20261205064109.2526623-1-praneethb2002@gmail.com> References: <20261205064109.2526623-1-praneethb2002@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 07:02:46 +0000 X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Critical] crypto: bcm: off-by-one rx_frag_num check wraps u8 in spu_aead_rx_sg_create() -- commit 18c5819a2054b0edb55dbef6d87807eed0c94639 Author: Praneeth Balasubramanian crypto: bcm - Reject requests with too many fragments This commit widens the fragment counters in the skcipher, ahash, and aead request handlers from u8 to u32 and rejects requests with -EINVAL when a count exceeds U8_MAX before calling the sg create helpers. > diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c > index 8c3e9525c134e..6a811a93a31fb 100644 > --- a/drivers/crypto/bcm/cipher.c > +++ b/drivers/crypto/bcm/cipher.c [ ... ] > @@ -1486,6 +1496,9 @@ static int handle_aead_req(struct iproc_reqctx_s *r= ctx) > rx_frag_num -=3D rctx->dst_nents; > } > =20 > + /* The sg create helpers take the fragment counts as a u8 */ > + if (rx_frag_num > U8_MAX) > + return -EINVAL; > err =3D spu_aead_rx_sg_create(mssg, req, rctx, rx_frag_num, > aead_parms.assoc_size, > aead_parms.ret_iv_len, resp_len, digestsize, [Severity: Critical] Can rx_frag_num still wrap to 0 inside spu_aead_rx_sg_create()? This check lets rx_frag_num =3D=3D U8_MAX (255) through, but spu_aead_rx_sg_create() takes rx_frag_num as a u8 and increments it again when data_padlen is non-zero: drivers/crypto/bcm/cipher.c:spu_aead_rx_sg_create() { ... if (data_padlen) /* have to catch gcm pad in separate buffer */ rx_frag_num++; mssg->spu.dst =3D kmalloc_objs(struct scatterlist, rx_frag_num, rctx->gfp); if (!mssg->spu.dst) return -ENOMEM; sg =3D mssg->spu.dst; sg_init_table(sg, rx_frag_num); ... } On SPU-M hardware, an unprivileged AF_ALG user submitting a GCM request with a payload not aligned to 16 bytes (e.g. 252 bytes across 252 dst sg entries) gets a non-zero data_padlen from spum_gcm_ccm_pad_len() with rx_frag_num =3D=3D 255. Incrementing u8 rx_frag_num wraps it to 0, so kmalloc_objs() returns ZERO_SIZE_PTR (bypassing the NULL check) and sg_init_table(sg, 0) writes out of bounds through ZERO_SIZE_PTR, causing a kernel oops or panic. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205064109.2526= 623-1-praneethb2002@gmail.com?part=3D1