Skip to contentSkip to conversation

crypto: AF_ALG - update correct dst SGL entry

PATCH In review Stephan Müller 2 participants 3 messages Aug 30, 2017 – Sep 21, 2017 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: AF_ALG - update correct dst SGL entry

When two adjacent TX SGL are processed and parts of both TX SGLs are pulled into the per-request TX SGL, the wrong per-request TX SGL entries were updated.

This fixes a NULL pointer dereference when a cipher implementation walks the TX SGL where some of the SGL entries were NULL.

---
 crypto/af_alg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
crypto/af_alg.c +2 -2
index ffa9f4ccd9b4..337cf382718e 100644
@@ -619,14 +619,14 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
 	struct af_alg_ctx *ctx = ask->private;
 	struct af_alg_tsgl *sgl;
 	struct scatterlist *sg;
-	unsigned int i, j;
+	unsigned int i, j = 0;
 
 	while (!list_empty(&ctx->tsgl_list)) {
 		sgl = list_first_entry(&ctx->tsgl_list, struct af_alg_tsgl,
 				       list);
 		sg = sgl->sg;
 
-		for (i = 0, j = 0; i < sgl->cur; i++) {
+		for (i = 0; i < sgl->cur; i++) {
 			size_t plen = min_t(size_t, used, sg[i].length);
 			struct page *page = sg_page(sg + i);
 
Signature · 1 line
2.13.5
maintainer
#1 lore raw
Quoted 8 lines · Stephan Müller

When two adjacent TX SGL are processed and parts of both TX SGLs are pulled into the per-request TX SGL, the wrong per-request TX SGL entries were updated.

This fixes a NULL pointer dereference when a cipher implementation walks the TX SGL where some of the SGL entries were NULL.

Oops, looks like you already sent me this fix. It should have this fixes header:

Fixes e870456d8e7c ("crypto: algif_skcipher - overhaul memory...")

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#2 lore raw
In reply to Stephan Müller
Quoted 8 lines · Stephan Müller

When two adjacent TX SGL are processed and parts of both TX SGLs are pulled into the per-request TX SGL, the wrong per-request TX SGL entries were updated.

This fixes a NULL pointer dereference when a cipher implementation walks the TX SGL where some of the SGL entries were NULL.

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt