Skip to content

Commit 2397e92

Browse files
5unkn0wn-Theoriherbertx
authored andcommitted
crypto: authencesn - reject too-short AAD (assoclen<8) to match ESP/ESN spec
authencesn assumes an ESP/ESN-formatted AAD. When assoclen is shorter than the minimum expected length, crypto_authenc_esn_decrypt() can advance past the end of the destination scatterlist and trigger a NULL pointer dereference in scatterwalk_map_and_copy(), leading to a kernel panic (DoS). Add a minimum AAD length check to fail fast on invalid inputs. Fixes: 104880a ("crypto: authencesn - Convert to new AEAD interface") Reported-By: Taeyang Lee <0wn@theori.io> Signed-off-by: Taeyang Lee <0wn@theori.io> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 961ac9d commit 2397e92

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

crypto/authencesn.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ static int crypto_authenc_esn_encrypt(struct aead_request *req)
169169
struct scatterlist *src, *dst;
170170
int err;
171171

172+
if (assoclen < 8)
173+
return -EINVAL;
174+
172175
sg_init_table(areq_ctx->src, 2);
173176
src = scatterwalk_ffwd(areq_ctx->src, req->src, assoclen);
174177
dst = src;
@@ -256,6 +259,9 @@ static int crypto_authenc_esn_decrypt(struct aead_request *req)
256259
u32 tmp[2];
257260
int err;
258261

262+
if (assoclen < 8)
263+
return -EINVAL;
264+
259265
cryptlen -= authsize;
260266

261267
if (req->src != dst)

0 commit comments

Comments
 (0)