mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
	skhan@linuxfoundation.org, me@brighamcampbell.com,
	jkoolstra@xs4all.nl, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] crypto: x86/aes-gcm - fix always true check for last AAD segment
Date: Sat, 26 Sep 2026 10:26:34 -0700	[thread overview]
Message-ID: <20260926172634.GB2460@quark> (raw)
In-Reply-To: <20260926145903.6061-1-raizudeen.kerneldev@gmail.com>

On Sat, Sep 26, 2026 at 08:29:03PM +0530, Mohamad Raizudeen wrote:
> In gcm_process_assoc(), a segment that is not the last one must have its
> length rounded down to a multiple of 16 bytes, as required by the
> assembly. The check for a non-last segment is `if (unlikely(assoclen))
> /* Not the last segment yet? */` where assoclen is the number of AAD
> bytes remaining after the current segment.
> 
> Since the conversion to the new scatterwalk API, assoclen is decremented
> at the end of the loop body rather than the beginning, so it still
> includes the current segment when the check executes, making the check
> always true.
> 
> As a result the last segment was rounded down as well, causing some
> avoidable extra work: an additional memcpy into the temporary buffer and
> an additional call into the assembly afte the loop. The GCM
> authentication tag is unaffected either way, so the self-tests pass and
> this went unnoticed. It is purely an efficiency issue rather than a
> correctness one.
> 
> Fix this by moving the assoclen decrement back to the beginning of the
> loop body.
> 
> Fixes: e9787deff49ea ("crypto: x86/aes-gcm - use the new scatterwalk functions")
> Cc: stable@vger.kernel.org
> Suggested-by: Eric Biggers <ebiggers@kernel.org>
> Signed-off-by: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-fixes

Thanks!

- Eric

      reply	other threads:[~2026-09-26 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26 14:59 Mohamad Raizudeen
2026-09-26 17:26 ` Eric Biggers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260926172634.GB2460@quark \
    --to=ebiggers@kernel.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=jkoolstra@xs4all.nl \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@brighamcampbell.com \
    --cc=raizudeen.kerneldev@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®