Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Cc: "Horia Geantă" <horia.geanta@nxp.com>,
	"Pankaj Gupta" <pankaj.gupta@nxp.com>,
	"Sahil Malhotra" <sahil.malhotra@nxp.com>,
	"David S. Miller" <davem@davemloft.net>,
	kernel@puri.sm, linux-crypto@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] crypto: caam - handle empty message in ahash_finup_first
Date: Fri, 27 Nov 2026 13:15:31 +0800	[thread overview]
Message-ID: <awkR86kDmeYENeva@gondor.apana.org.au> (raw)
In-Reply-To: <20261120-caam-empty-v1-1-d82106209428@puri.sm>

On Fri, Nov 20, 2026 at 12:59:57AM +0100, Sebastian Krzyszkowiak wrote:
> Since commit 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API"),
> crypto_ahash_final calls crypto_ahash_finup with req->nbytes == 0.
> This leads to an oops on an empty message to hash when ahash_edesc_add_src
> calls sg_dma_address(req->src) if the caller passes NULL as req->src:
> 
>     Unable to handle kernel NULL pointer dereference at virtual
>     address 0000000000000010
>     Call trace:
>      ahash_edesc_add_src+0x40/0x390 (P)
>      ahash_digest+0xcc/0x250
>      ahash_finup_first+0x18/0x30
>      ahash_finup+0x24/0x38
>      ahash_do_req_chain+0xc0/0x1b0
>      crypto_ahash_finup+0x168/0x200
>      hash_recvmsg+0xb0/0x1f0 [algif_hash]
> 
> It can be reproduced on i.MX 8M Quad with the following Python snippet:
> 
>     import socket
>     s = socket.socket(socket.AF_ALG, socket.SOCK_SEQPACKET, 0)
>     s.bind(("hash", "sha256"))
>     op, _ = s.accept()
>     print(op.recv(32).hex())
> 
> The oops was observed being triggered by iwd.
> 
> ahash_finup_first runs only when nothing has been hashed yet, so handle
> the empty-message case by routing it to ahash_final_no_ctx.
> 
> Fixes: 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
> ---
>  drivers/crypto/caam/caamalg_qi2.c | 3 +++
>  drivers/crypto/caam/caamhash.c    | 3 +++
>  2 files changed, 6 insertions(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2026-11-27  5:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 23:59 [PATCH] crypto: caam - handle empty message in ahash_finup_first Sebastian Krzyszkowiak
2026-11-27  5:15 ` Herbert Xu [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=awkR86kDmeYENeva@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=horia.geanta@nxp.com \
    --cc=kernel@puri.sm \
    --cc=linux-crypto@vger.kernel.org \
    --cc=pankaj.gupta@nxp.com \
    --cc=sahil.malhotra@nxp.com \
    --cc=sebastian.krzyszkowiak@puri.sm \
    --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