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=1796315817; b=gLG7pywTkUI3C7OStSPxhZrxHzUX3NyullWSD/L1E9K36s/e5vkxZofgajG0EnxWJG0Z QmsTA/cz9b7k/6aIdU3pyRxLJzp0AOfnrb0NsxwmbHOubrEgUy23mJDUzJCscClWG+YUF yWSrX2jORsUzUAynjcs6/aLHW2G1eZ9D8xYkJqecPP2CVBgH8AuCTHWRPzN2NrBA1vEB8 SrwHAQLXFnCFzdDuP1OM498LVTjh/c9pwHYXt7b4LCVMzN8gig2LVDgBq8V82TOiipnRn cJdgSrjKqNO2C+NUnVggLwdT0dERh41RQlP9ZkiA07edAMcZOMO9/DA+9lU2+X/j2eQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796315817; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=uxpZ8ZbL/861Vk0CJnIH7X7Bp/dvOEoSmwfSqhm9uUw=; b=VJywNy7ectEjqU3QeftRnWdFIKG8wa2Wtkfn3uaX1IW1rOOdVThCxfwJEzhk+U480eYC CL0HowgYRolGzQP7TpshzykZ5EajZqlel9Ruyj1CMr9BidNLHbG2olnwD5v+K5GPWTGyy mq9kmG8nx765D/qY9bu2iFoAKi5JGpzr7NNRbULyxk9Dq4lkrXagmdrZhHDbaNupOukrU YPS0jzGeXKS9cBjTTP9abQ+ihSS6wgZmPwGJxETfrd3y8LxDayoC2RD4Q/fRXi63wU5R6 Iose7dW4yNX+dZGJfULsF12E3VMGPddZA+ZFKCIpwyHzlt/gOMHqF6xA9BXqrmFIhnQ== 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="a3BP/1yP"; 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 E5B15606A322 for ; Thu, 3 Dec 2026 16:36:56 +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=a3BP/1yP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 865691F000C1; Thu, 3 Dec 2026 16:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796315816; bh=uxpZ8ZbL/861Vk0CJnIH7X7Bp/dvOEoSmwfSqhm9uUw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=a3BP/1yPp1KOmg39Bfjo+Pypi0LbhWSPvtSYvPDitYJgCc8k3jegcDH70FToiLymc /RuEIkmxpjMgASme9k9rjz/5v8IMJDYoE/yNo/kUPMj//HBqAorZUMs80O8pnGOU8Y WZJ+lOKYSnOQz7ibLsVTepy3yOczvj9Yu0iLmEXIjjGdV1eIuzSWRCeJHF8EKfwe3w bXVfZEZxi29tScxmsT5krVXtzgd11lCJIVS7qvxlQdK1WtoAuK5iJf9eIg1shXMsK4 /52iDlL/I9O1edhpJPBcLoMjmA6El+nZLEbQrQCYoIvqsfrBZsQNf0mistGMw7lFWi jZNcZ3hrkiGtw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] crypto: chacha - Consolidate XChaCha initialization Reply-To: sashiko-reviews@lists.linux.dev To: "Laveesh Bansal" , "Herbert Xu" , "Eric Biggers" Cc: "Jason A. Donenfeld" , "Ard Biesheuvel" , "David S. Miller" , linux-crypto@vger.kernel.org In-Reply-To: <20261203161849.85971-1-laveeshb@laveeshbansal.com> References: <20261203161849.85971-1-laveeshb@laveeshbansal.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 16:36:56 +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: - [Low] crypto: chacha - xchacha_init() leaves stack iv buffer unzeroized -- commit cb60a2e5b6777695110805ae396df4d61a659318 Author: Laveesh Bansal crypto: chacha - Consolidate XChaCha initialization This commit adds a shared xchacha_init() helper to include/crypto/chacha.h and replaces the duplicated XChaCha initialization code in crypto/adiantum.c, crypto/chacha.c, and lib/crypto/chacha20poly1305.c. > diff --git a/include/crypto/chacha.h b/include/crypto/chacha.h > index bacf253781d52..10071d7b03043 100644 > --- a/include/crypto/chacha.h > +++ b/include/crypto/chacha.h [ ... ] > @@ -85,6 +86,28 @@ static inline void chacha_init(struct chacha_state *st= ate, > state->x[15] =3D get_unaligned_le32(iv + 12); > } > =20 > +/* > + * Initialize @state for XChaCha with the given key and 192-bit nonce, > + * starting at stream position 0. > + */ > +static inline void xchacha_init(struct chacha_state *state, > + const u32 key[at_least CHACHA_KEY_WORDS], > + const u8 nonce[at_least XCHACHA_NONCE_SIZE], > + int nrounds) > +{ > + u32 subkey[HCHACHA_OUT_WORDS]; > + u8 iv[CHACHA_IV_SIZE] =3D {}; > + > + /* Compute the subkey given the original key and first 128 nonce bits */ > + chacha_init(state, key, nonce); > + hchacha_block(state, subkey, nrounds); > + > + memcpy(&iv[8], nonce + 16, 8); > + chacha_init(state, subkey, iv); > + > + memzero_explicit(subkey, sizeof(subkey)); > +} [Severity: Low] Should xchacha_init() also zeroize iv with memzero_explicit() before returning? Previously, xchacha_init() in lib/crypto/chacha20poly1305.c cleared its stack iv buffer with memzero_explicit(iv, sizeof(iv)). Leaving iv uncleared here leaves the upper 8 nonce bytes on the stack on every xchacha20poly1305_encrypt() or xchacha20poly1305_decrypt() call. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203161849.8597= 1-1-laveeshb@laveeshbansal.com?part=3D1