Skip to content

Commit

Permalink
crypto: essiv - Handle EBUSY correctly
Browse files Browse the repository at this point in the history
As it is essiv only handles the special return value of EINPROGERSS,
which means that in all other cases it will free data related to the
request.

However, as the caller of essiv may specify MAY_BACKLOG, we also need
to expect EBUSY and treat it in the same way.  Otherwise backlogged
requests will trigger a use-after-free.

Fixes: be1eb7f ("crypto: essiv - create wrapper template...")
Signed-off-by: Herbert Xu <[email protected]>
Acked-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Jan 20, 2023
1 parent b0f4f74 commit b5a772a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crypto/essiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ static void essiv_aead_done(struct crypto_async_request *areq, int err)
struct aead_request *req = areq->data;
struct essiv_aead_request_ctx *rctx = aead_request_ctx(req);

if (err == -EINPROGRESS)
goto out;

kfree(rctx->assoc);

out:
aead_request_complete(req, err);
}

Expand Down Expand Up @@ -247,7 +252,7 @@ static int essiv_aead_crypt(struct aead_request *req, bool enc)
err = enc ? crypto_aead_encrypt(subreq) :
crypto_aead_decrypt(subreq);

if (rctx->assoc && err != -EINPROGRESS)
if (rctx->assoc && err != -EINPROGRESS && err != -EBUSY)
kfree(rctx->assoc);
return err;
}
Expand Down

0 comments on commit b5a772a

Please sign in to comment.