Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

[CRYPTO] xcbc: Fix crash with IPsec

When using aes-xcbc-mac for authentication in IPsec,
the kernel crashes. It seems this algorithm doesn't
account for the space IPsec may make in scatterlist for authtag.
Thus when crypto_xcbc_digest_update2() gets called,
nbytes may be less than sg[i].length.
Since nbytes is an unsigned number, it wraps
at the end of the loop allowing us to go back
into loop and causing crash in memcpy.

I used update function in digest.c to model this fix.
Please let me know if it looks ok.

Signed-off-by: Joy Latten <latten@austin.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Joy Latten and committed by
Herbert Xu
2f40a178 6212f2c7

+5 -1
+5 -1
crypto/xcbc.c
··· 124 124 unsigned int offset = sg[i].offset; 125 125 unsigned int slen = sg[i].length; 126 126 127 + if (unlikely(slen > nbytes)) 128 + slen = nbytes; 129 + 130 + nbytes -= slen; 131 + 127 132 while (slen > 0) { 128 133 unsigned int len = min(slen, ((unsigned int)(PAGE_SIZE)) - offset); 129 134 char *p = crypto_kmap(pg, 0) + offset; ··· 182 177 offset = 0; 183 178 pg++; 184 179 } 185 - nbytes-=sg[i].length; 186 180 i++; 187 181 } while (nbytes>0); 188 182