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

Configure Feed

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

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>

+13
+7
include/crypto/algapi.h
··· 302 302 CRYPTO_MSG_ALG_LOADED, 303 303 }; 304 304 305 + static inline void crypto_request_complete(struct crypto_async_request *req, 306 + int err) 307 + { 308 + crypto_completion_t complete = req->complete; 309 + complete(req, err); 310 + } 311 + 305 312 #endif /* _CRYPTO_ALGAPI_H */
+6
include/linux/crypto.h
··· 176 176 struct crypto_tfm; 177 177 struct crypto_type; 178 178 179 + typedef struct crypto_async_request crypto_completion_data_t; 179 180 typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); 180 181 181 182 /** ··· 596 595 /* 597 596 * Async ops completion helper functioons 598 597 */ 598 + static inline void *crypto_get_completion_data(crypto_completion_data_t *req) 599 + { 600 + return req->data; 601 + } 602 + 599 603 void crypto_req_done(struct crypto_async_request *req, int err); 600 604 601 605 static inline int crypto_wait_req(int err, struct crypto_wait *wait)