From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=180.181.231.80 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796363424; b=NgTkpDDIGUxXatih8gu/W0DyTONx1waoYmfuCmJwaDc8I5Pf8BYg6Rg83vU/i4jH672r skOkKXyhOATVNryezoforo4vCMYxAET2zmpxZ9s6y5x23TM5utnrLwkCXQHlLMLwmUiDQ fASMqzx1eXVbRhKv4V1Aqd1Z+cQJKpvixp014df7ryReb006TNjWKWkUUnecr/bXS6Sz8 qapGXUaFNU5gVuaKWiMgzL78SmZTJIUDssi+NEk5YKKkiO+3Um4s8PzCXV/BZYPpphiyT FLD1v+AfMhus7FwLaD1XBPAHEXCsZeJJyB7w+kVZuxnh221gcgwAcDXwdpaaSyvDhVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796363424; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-Newsgroups; bh=T+Kc2EbtEBmm4L6qRfrlzE9JigbiSXidGNsKo5qI6gg=; b=fQPR6coDd/ar2h0DGffUZlo8GVaGmIRHQDME0X24ZKnoGlhdnxAEPPM4s/YY//dIY3OB 4yiHC+ISTd5FEl9wBfp8jGLsqakjWfTwI3BlTefocylzL92mvoSQAkjYUEfI3E89hCnsR GqCSto+JFCorPAlTWfYoIotyekPepGFXdo6Aeruy0WEnJRxYRJ+oaZfxrlB3nhpVzOz5y UmMOcZ604/U9VeQiWBojr5URJfWZ6f1YDk4QeUTbW4PyVKStAnsHmQ3JRisUYoyuO4QHH vQgH7d14qTdrPSvCa+V3cYvPDm9HlfuiOfM6S2NEevjcbJxjhBOVrbK5MpPPPYYCICA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gondor.apana.org.au; spf=pass smtp.mailfrom=gondor.apana.org.au; dkim=pass header.d=gondor.apana.org.au header.i=@gondor.apana.org.au header.a=rsa-sha256 header.s=h01 header.b=IMrZNI0f; arc=none smtp.remote-ip=180.181.231.80 Received: from abb.hmeau.com (abb.hmeau.com [180.181.231.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1115C606A322; Fri, 4 Dec 2026 05:50:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1115C606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gondor.apana.org.au header.i=@gondor.apana.org.au header.a=rsa-sha256 header.s=h01 header.b=IMrZNI0f DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gondor.apana.org.au; s=h01; h=In-Reply-To:Content-Type:MIME-Version: Message-ID:Subject:Cc:To:From:Date:cc:to:subject:message-id:date:from: content-type:references:reply-to; bh=T+Kc2EbtEBmm4L6qRfrlzE9JigbiSXidGNsKo5qI6gg=; b=IMrZNI0fLEan8GFX5JjGuTmggZ EJDXMnvgrk4GT5FUKwuXOTj6hsWr7r/w7eq7KUeBVO7CgZZsykM8gI3wU+ePb6Ln9vWOisc4/zprE q/gQCbfT6gffLG7asdGtu+usVV6b4TAJWbjwoCrKDttP0Hl1gU2awQNxRZlFVoSPLJBM8P/WhWzLJ 1GVNvnLlQZWVJuNxik29EiZRrccaWo4LStcS1vlqZ4DxaW1AojBN6pYV2CixalmoO6k46v6CFs7Iv nBmF+Ozj1gR607rjua8+2Yb5WkbMFt3z7QBjjP5/ovNXuBrvhM8aseTX3H5Q3zrmcQiIqk/uIilN5 L5uu50nw==; Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.100.1 #2 (Debian)) id 1xZMBX-00000005EoO-4Ar9; Fri, 04 Dec 2026 13:50:21 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 04 Dec 2026 13:50:19 +0800 Date: Fri, 4 Dec 2026 13:50:19 +0800 From: Herbert Xu To: Jack Wallner Cc: kees@kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, linux-crypto@vger.kernel.org Subject: Re: [PATCH 1/8] crypto: gcm, ccm - Derive the rfc4106/rfc4309 IV from the request context Message-ID: X-Mailing-List: linux-crypto@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: <20261129085612.22266-2-jackwallner@gmail.com> X-Newsgroups: apana.lists.os.linux.cryptoapi,apana.lists.os.linux.kernel Jack Wallner wrote: > crypto_rfc4106_crypt() and crypto_rfc4309_crypt() keep the IV for the > child request in the space that follows the child's request context. > They find that space by starting from "subreq + 1", where subreq points > to the subreq member of the request context structure. > > "subreq + 1" is one past the end of that member, so as far as the > compiler can tell, everything stored through a pointer derived from it > lies outside the member: with GCC, > __builtin_dynamic_object_size(iv, 1) is 0. The memcpy() calls that fill > in the IV are spared a FORTIFY_SOURCE "field-spanning write" warning > only because PTR_ALIGN() casts the pointer to an integer and back, which > makes the compiler forget where it came from. > > A later patch in this series makes PTR_ALIGN() keep the object size. > With it, a kernel built with GCC 13.3 reports this from the crypto > self-tests, which is how I found these two callers: > > memcpy: detected field-spanning write (size 4) of single field "iv" at crypto/gcm.c:483 (size 0) > memcpy: detected field-spanning write (size 8) of single field "iv + 4" at crypto/gcm.c:484 (size 0) > > Start from "rctx + 1" instead, as crypto_rfc4543_crypt() in gcm.c already > does. crypto_rfc4106_init_tfm() and crypto_rfc4309_init_tfm() size the > request from sizeof() of the request context structure, so "rctx + 1" > is also the address that calculation is based on. subreq is the last > member of both structures and nothing follows it, so the address does > not change. I checked that with a temporary build-time assertion of > sizeof() against offsetofend() of subreq, on x86-64, i386, arm, arm64, > riscv and powerpc. > > No functional change. With this patch and the PTR_ALIGN() one applied, > the self-tests run without the warning. Nothing in my test boot > instantiates rfc4309, so for ccm.c I have no runtime report, only the > same construct and the same compile-time finding. > > The change and this changelog were written by an AI coding assistant > (Claude, run in Claude Code) at my direction. See the cover letter for > how it was used and tested. > > Signed-off-by: Jack Wallner > --- > crypto/ccm.c | 2 +- > crypto/gcm.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) Acked-by: Herbert Xu -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt