From: Herbert Xu Date: Fri, 22 Jan 2016 15:21:10 +0000 (+0800) Subject: crypto: skcipher - Add helper to zero stack request X-Git-Tag: v4.1.12-111.0.20170907_2225~73 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4cbd16c5f82505c7d0acc0f7e540d97da2e3cae7;p=users%2Fjedix%2Flinux-maple.git crypto: skcipher - Add helper to zero stack request Orabug: 26644685 As the size of an skcipher_request is variable, it's awkward to zero it explicitly. This patch adds a helper to do that which should be used when it is created on the stack. Signed-off-by: Herbert Xu (cherry picked from commit 1aaa753d918c48c603195a468766e6a2b32b87f9) Signed-off-by: Somasundaram Krishnasamy Reviewed-by: Jack Vogel --- diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h index d8dd41fb034fe..85a8bbc22b7e5 100644 --- a/include/crypto/skcipher.h +++ b/include/crypto/skcipher.h @@ -433,6 +433,13 @@ static inline void skcipher_request_free(struct skcipher_request *req) kzfree(req); } +static inline void skcipher_request_zero(struct skcipher_request *req) +{ + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); + + memzero_explicit(req, sizeof(*req) + crypto_skcipher_reqsize(tfm)); +} + /** * skcipher_request_set_callback() - set asynchronous callback function * @req: request handle