diff options
author | Andrzej Zaborowski <andrew.zaborowski@intel.com> | 2015-12-12 00:03:51 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-12-22 07:43:24 -0500 |
commit | 5319216dcfee14886abb2b7090e8fcf2e2d8a611 (patch) | |
tree | 16befddf660d00d6aea8c5c9acc4061c61e982ce /crypto/rsa-pkcs1pad.c | |
parent | 16f080aaadcb912c9a47c8603a38ccad87da38ea (diff) |
crypto: rsa-pkcs1pad - don't allocate buffer on stack
Avoid the s390 compile "warning: 'pkcs1pad_encrypt_sign_complete'
uses dynamic stack allocation" reported by kbuild test robot. Don't
use a flat zero-filled buffer, instead zero the contents of the SGL.
Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/rsa-pkcs1pad.c')
-rw-r--r-- | crypto/rsa-pkcs1pad.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index accc67d16686..50f5c97e1087 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c | |||
@@ -110,21 +110,32 @@ static int pkcs1pad_encrypt_sign_complete(struct akcipher_request *req, int err) | |||
110 | struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); | 110 | struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); |
111 | struct pkcs1pad_ctx *ctx = akcipher_tfm_ctx(tfm); | 111 | struct pkcs1pad_ctx *ctx = akcipher_tfm_ctx(tfm); |
112 | struct pkcs1pad_request *req_ctx = akcipher_request_ctx(req); | 112 | struct pkcs1pad_request *req_ctx = akcipher_request_ctx(req); |
113 | uint8_t zeros[ctx->key_size - req_ctx->child_req.dst_len]; | 113 | size_t pad_len = ctx->key_size - req_ctx->child_req.dst_len; |
114 | size_t chunk_len, pad_left; | ||
115 | struct sg_mapping_iter miter; | ||
114 | 116 | ||
115 | if (!err) { | 117 | if (!err) { |
116 | if (req_ctx->child_req.dst_len < ctx->key_size) { | 118 | if (pad_len) { |
117 | memset(zeros, 0, sizeof(zeros)); | 119 | sg_miter_start(&miter, req->dst, |
118 | sg_copy_from_buffer(req->dst, | 120 | sg_nents_for_len(req->dst, pad_len), |
119 | sg_nents_for_len(req->dst, | 121 | SG_MITER_ATOMIC | SG_MITER_TO_SG); |
120 | sizeof(zeros)), | 122 | |
121 | zeros, sizeof(zeros)); | 123 | pad_left = pad_len; |
124 | while (pad_left) { | ||
125 | sg_miter_next(&miter); | ||
126 | |||
127 | chunk_len = min(miter.length, pad_left); | ||
128 | memset(miter.addr, 0, chunk_len); | ||
129 | pad_left -= chunk_len; | ||
130 | } | ||
131 | |||
132 | sg_miter_stop(&miter); | ||
122 | } | 133 | } |
123 | 134 | ||
124 | sg_pcopy_from_buffer(req->dst, | 135 | sg_pcopy_from_buffer(req->dst, |
125 | sg_nents_for_len(req->dst, ctx->key_size), | 136 | sg_nents_for_len(req->dst, ctx->key_size), |
126 | req_ctx->out_buf, req_ctx->child_req.dst_len, | 137 | req_ctx->out_buf, req_ctx->child_req.dst_len, |
127 | sizeof(zeros)); | 138 | pad_len); |
128 | } | 139 | } |
129 | req->dst_len = ctx->key_size; | 140 | req->dst_len = ctx->key_size; |
130 | 141 | ||