linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.4,4.9,4.14] crypto: salsa20 - don't access already-freed walk.iv
@ 2019-05-17 17:25 Eric Biggers
  2019-05-18  7:00 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2019-05-17 17:25 UTC (permalink / raw)
  To: stable; +Cc: linux-crypto

From: Eric Biggers <ebiggers@google.com>

commit edaf28e996af69222b2cb40455dbb5459c2b875a upstream.
[Please apply to 4.14-stable and earlier.]

If the user-provided IV needs to be aligned to the algorithm's
alignmask, then skcipher_walk_virt() copies the IV into a new aligned
buffer walk.iv.  But skcipher_walk_virt() can fail afterwards, and then
if the caller unconditionally accesses walk.iv, it's a use-after-free.

salsa20-generic doesn't set an alignmask, so currently it isn't affected
by this despite unconditionally accessing walk.iv.  However this is more
subtle than desired, and it was actually broken prior to the alignmask
being removed by commit b62b3db76f73 ("crypto: salsa20-generic - cleanup
and convert to skcipher API").

Since salsa20-generic does not update the IV and does not need any IV
alignment, update it to use req->iv instead of walk.iv.

Fixes: 2407d60872dd ("[CRYPTO] salsa20: Salsa20 stream cipher")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/salsa20_generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/salsa20_generic.c b/crypto/salsa20_generic.c
index d7da0eea5622a..319d9962552e1 100644
--- a/crypto/salsa20_generic.c
+++ b/crypto/salsa20_generic.c
@@ -186,7 +186,7 @@ static int encrypt(struct blkcipher_desc *desc,
 	blkcipher_walk_init(&walk, dst, src, nbytes);
 	err = blkcipher_walk_virt_block(desc, &walk, 64);
 
-	salsa20_ivsetup(ctx, walk.iv);
+	salsa20_ivsetup(ctx, desc->info);
 
 	while (walk.nbytes >= 64) {
 		salsa20_encrypt_bytes(ctx, walk.dst.virt.addr,
-- 
2.21.0.1020.gf2820cf01a-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 4.4,4.9,4.14] crypto: salsa20 - don't access already-freed walk.iv
  2019-05-17 17:25 [PATCH 4.4,4.9,4.14] crypto: salsa20 - don't access already-freed walk.iv Eric Biggers
@ 2019-05-18  7:00 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-05-18  7:00 UTC (permalink / raw)
  To: Eric Biggers; +Cc: stable, linux-crypto

On Fri, May 17, 2019 at 10:25:58AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> commit edaf28e996af69222b2cb40455dbb5459c2b875a upstream.
> [Please apply to 4.14-stable and earlier.]

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-18  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 17:25 [PATCH 4.4,4.9,4.14] crypto: salsa20 - don't access already-freed walk.iv Eric Biggers
2019-05-18  7:00 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).