crypto: api - Add scaffolding to change completion function signature

The crypto completion function currently takes a pointer to a
struct crypto_async_request object.  However, in reality the API
does not allow the use of any part of the object apart from the
data field.  For example, ahash/shash will create a fake object
on the stack to pass along a different data field.

This leads to potential bugs where the user may try to dereference
or otherwise use the crypto_async_request object.

This patch adds some temporary scaffolding so that the completion
function can take a void * instead.  Once affected users have been
converted this can be removed.

The helper crypto_request_complete will remain even after the
conversion is complete.  It should be used instead of calling
the completion function directly.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu
2023-01-31 16:01:45 +08:00
parent 4409c08d80
commit c35e03eaec
2 changed files with 13 additions and 0 deletions

View File

@@ -302,4 +302,11 @@ enum {
CRYPTO_MSG_ALG_LOADED,
};
static inline void crypto_request_complete(struct crypto_async_request *req,
int err)
{
crypto_completion_t complete = req->complete;
complete(req, err);
}
#endif /* _CRYPTO_ALGAPI_H */