aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/crypto_user_base.c18
-rw-r--r--crypto/crypto_user_stat.c21
-rw-r--r--crypto/simd.c5
3 files changed, 33 insertions, 11 deletions
diff --git a/crypto/crypto_user_base.c b/crypto/crypto_user_base.c
index e41f6cc33fff..784748dbb19f 100644
--- a/crypto/crypto_user_base.c
+++ b/crypto/crypto_user_base.c
@@ -84,7 +84,7 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
84{ 84{
85 struct crypto_report_cipher rcipher; 85 struct crypto_report_cipher rcipher;
86 86
87 strlcpy(rcipher.type, "cipher", sizeof(rcipher.type)); 87 strncpy(rcipher.type, "cipher", sizeof(rcipher.type));
88 88
89 rcipher.blocksize = alg->cra_blocksize; 89 rcipher.blocksize = alg->cra_blocksize;
90 rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; 90 rcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
@@ -103,7 +103,7 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
103{ 103{
104 struct crypto_report_comp rcomp; 104 struct crypto_report_comp rcomp;
105 105
106 strlcpy(rcomp.type, "compression", sizeof(rcomp.type)); 106 strncpy(rcomp.type, "compression", sizeof(rcomp.type));
107 if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, 107 if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS,
108 sizeof(struct crypto_report_comp), &rcomp)) 108 sizeof(struct crypto_report_comp), &rcomp))
109 goto nla_put_failure; 109 goto nla_put_failure;
@@ -117,7 +117,7 @@ static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg)
117{ 117{
118 struct crypto_report_acomp racomp; 118 struct crypto_report_acomp racomp;
119 119
120 strlcpy(racomp.type, "acomp", sizeof(racomp.type)); 120 strncpy(racomp.type, "acomp", sizeof(racomp.type));
121 121
122 if (nla_put(skb, CRYPTOCFGA_REPORT_ACOMP, 122 if (nla_put(skb, CRYPTOCFGA_REPORT_ACOMP,
123 sizeof(struct crypto_report_acomp), &racomp)) 123 sizeof(struct crypto_report_acomp), &racomp))
@@ -132,7 +132,7 @@ static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg)
132{ 132{
133 struct crypto_report_akcipher rakcipher; 133 struct crypto_report_akcipher rakcipher;
134 134
135 strlcpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); 135 strncpy(rakcipher.type, "akcipher", sizeof(rakcipher.type));
136 136
137 if (nla_put(skb, CRYPTOCFGA_REPORT_AKCIPHER, 137 if (nla_put(skb, CRYPTOCFGA_REPORT_AKCIPHER,
138 sizeof(struct crypto_report_akcipher), &rakcipher)) 138 sizeof(struct crypto_report_akcipher), &rakcipher))
@@ -147,7 +147,7 @@ static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)
147{ 147{
148 struct crypto_report_kpp rkpp; 148 struct crypto_report_kpp rkpp;
149 149
150 strlcpy(rkpp.type, "kpp", sizeof(rkpp.type)); 150 strncpy(rkpp.type, "kpp", sizeof(rkpp.type));
151 151
152 if (nla_put(skb, CRYPTOCFGA_REPORT_KPP, 152 if (nla_put(skb, CRYPTOCFGA_REPORT_KPP,
153 sizeof(struct crypto_report_kpp), &rkpp)) 153 sizeof(struct crypto_report_kpp), &rkpp))
@@ -161,10 +161,10 @@ nla_put_failure:
161static int crypto_report_one(struct crypto_alg *alg, 161static int crypto_report_one(struct crypto_alg *alg,
162 struct crypto_user_alg *ualg, struct sk_buff *skb) 162 struct crypto_user_alg *ualg, struct sk_buff *skb)
163{ 163{
164 strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name)); 164 strncpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));
165 strlcpy(ualg->cru_driver_name, alg->cra_driver_name, 165 strncpy(ualg->cru_driver_name, alg->cra_driver_name,
166 sizeof(ualg->cru_driver_name)); 166 sizeof(ualg->cru_driver_name));
167 strlcpy(ualg->cru_module_name, module_name(alg->cra_module), 167 strncpy(ualg->cru_module_name, module_name(alg->cra_module),
168 sizeof(ualg->cru_module_name)); 168 sizeof(ualg->cru_module_name));
169 169
170 ualg->cru_type = 0; 170 ualg->cru_type = 0;
@@ -177,7 +177,7 @@ static int crypto_report_one(struct crypto_alg *alg,
177 if (alg->cra_flags & CRYPTO_ALG_LARVAL) { 177 if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
178 struct crypto_report_larval rl; 178 struct crypto_report_larval rl;
179 179
180 strlcpy(rl.type, "larval", sizeof(rl.type)); 180 strncpy(rl.type, "larval", sizeof(rl.type));
181 if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL, 181 if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL,
182 sizeof(struct crypto_report_larval), &rl)) 182 sizeof(struct crypto_report_larval), &rl))
183 goto nla_put_failure; 183 goto nla_put_failure;
diff --git a/crypto/crypto_user_stat.c b/crypto/crypto_user_stat.c
index 021ad06bbb62..1dfaa0ccd555 100644
--- a/crypto/crypto_user_stat.c
+++ b/crypto/crypto_user_stat.c
@@ -37,6 +37,8 @@ static int crypto_report_aead(struct sk_buff *skb, struct crypto_alg *alg)
37 u64 v64; 37 u64 v64;
38 u32 v32; 38 u32 v32;
39 39
40 memset(&raead, 0, sizeof(raead));
41
40 strncpy(raead.type, "aead", sizeof(raead.type)); 42 strncpy(raead.type, "aead", sizeof(raead.type));
41 43
42 v32 = atomic_read(&alg->encrypt_cnt); 44 v32 = atomic_read(&alg->encrypt_cnt);
@@ -65,6 +67,8 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
65 u64 v64; 67 u64 v64;
66 u32 v32; 68 u32 v32;
67 69
70 memset(&rcipher, 0, sizeof(rcipher));
71
68 strlcpy(rcipher.type, "cipher", sizeof(rcipher.type)); 72 strlcpy(rcipher.type, "cipher", sizeof(rcipher.type));
69 73
70 v32 = atomic_read(&alg->encrypt_cnt); 74 v32 = atomic_read(&alg->encrypt_cnt);
@@ -93,6 +97,8 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
93 u64 v64; 97 u64 v64;
94 u32 v32; 98 u32 v32;
95 99
100 memset(&rcomp, 0, sizeof(rcomp));
101
96 strlcpy(rcomp.type, "compression", sizeof(rcomp.type)); 102 strlcpy(rcomp.type, "compression", sizeof(rcomp.type));
97 v32 = atomic_read(&alg->compress_cnt); 103 v32 = atomic_read(&alg->compress_cnt);
98 rcomp.stat_compress_cnt = v32; 104 rcomp.stat_compress_cnt = v32;
@@ -120,6 +126,8 @@ static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg)
120 u64 v64; 126 u64 v64;
121 u32 v32; 127 u32 v32;
122 128
129 memset(&racomp, 0, sizeof(racomp));
130
123 strlcpy(racomp.type, "acomp", sizeof(racomp.type)); 131 strlcpy(racomp.type, "acomp", sizeof(racomp.type));
124 v32 = atomic_read(&alg->compress_cnt); 132 v32 = atomic_read(&alg->compress_cnt);
125 racomp.stat_compress_cnt = v32; 133 racomp.stat_compress_cnt = v32;
@@ -147,6 +155,8 @@ static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg)
147 u64 v64; 155 u64 v64;
148 u32 v32; 156 u32 v32;
149 157
158 memset(&rakcipher, 0, sizeof(rakcipher));
159
150 strncpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); 160 strncpy(rakcipher.type, "akcipher", sizeof(rakcipher.type));
151 v32 = atomic_read(&alg->encrypt_cnt); 161 v32 = atomic_read(&alg->encrypt_cnt);
152 rakcipher.stat_encrypt_cnt = v32; 162 rakcipher.stat_encrypt_cnt = v32;
@@ -177,6 +187,8 @@ static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)
177 struct crypto_stat rkpp; 187 struct crypto_stat rkpp;
178 u32 v; 188 u32 v;
179 189
190 memset(&rkpp, 0, sizeof(rkpp));
191
180 strlcpy(rkpp.type, "kpp", sizeof(rkpp.type)); 192 strlcpy(rkpp.type, "kpp", sizeof(rkpp.type));
181 193
182 v = atomic_read(&alg->setsecret_cnt); 194 v = atomic_read(&alg->setsecret_cnt);
@@ -203,6 +215,8 @@ static int crypto_report_ahash(struct sk_buff *skb, struct crypto_alg *alg)
203 u64 v64; 215 u64 v64;
204 u32 v32; 216 u32 v32;
205 217
218 memset(&rhash, 0, sizeof(rhash));
219
206 strncpy(rhash.type, "ahash", sizeof(rhash.type)); 220 strncpy(rhash.type, "ahash", sizeof(rhash.type));
207 221
208 v32 = atomic_read(&alg->hash_cnt); 222 v32 = atomic_read(&alg->hash_cnt);
@@ -227,6 +241,8 @@ static int crypto_report_shash(struct sk_buff *skb, struct crypto_alg *alg)
227 u64 v64; 241 u64 v64;
228 u32 v32; 242 u32 v32;
229 243
244 memset(&rhash, 0, sizeof(rhash));
245
230 strncpy(rhash.type, "shash", sizeof(rhash.type)); 246 strncpy(rhash.type, "shash", sizeof(rhash.type));
231 247
232 v32 = atomic_read(&alg->hash_cnt); 248 v32 = atomic_read(&alg->hash_cnt);
@@ -251,6 +267,8 @@ static int crypto_report_rng(struct sk_buff *skb, struct crypto_alg *alg)
251 u64 v64; 267 u64 v64;
252 u32 v32; 268 u32 v32;
253 269
270 memset(&rrng, 0, sizeof(rrng));
271
254 strncpy(rrng.type, "rng", sizeof(rrng.type)); 272 strncpy(rrng.type, "rng", sizeof(rrng.type));
255 273
256 v32 = atomic_read(&alg->generate_cnt); 274 v32 = atomic_read(&alg->generate_cnt);
@@ -275,6 +293,8 @@ static int crypto_reportstat_one(struct crypto_alg *alg,
275 struct crypto_user_alg *ualg, 293 struct crypto_user_alg *ualg,
276 struct sk_buff *skb) 294 struct sk_buff *skb)
277{ 295{
296 memset(ualg, 0, sizeof(*ualg));
297
278 strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name)); 298 strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));
279 strlcpy(ualg->cru_driver_name, alg->cra_driver_name, 299 strlcpy(ualg->cru_driver_name, alg->cra_driver_name,
280 sizeof(ualg->cru_driver_name)); 300 sizeof(ualg->cru_driver_name));
@@ -291,6 +311,7 @@ static int crypto_reportstat_one(struct crypto_alg *alg,
291 if (alg->cra_flags & CRYPTO_ALG_LARVAL) { 311 if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
292 struct crypto_stat rl; 312 struct crypto_stat rl;
293 313
314 memset(&rl, 0, sizeof(rl));
294 strlcpy(rl.type, "larval", sizeof(rl.type)); 315 strlcpy(rl.type, "larval", sizeof(rl.type));
295 if (nla_put(skb, CRYPTOCFGA_STAT_LARVAL, 316 if (nla_put(skb, CRYPTOCFGA_STAT_LARVAL,
296 sizeof(struct crypto_stat), &rl)) 317 sizeof(struct crypto_stat), &rl))
diff --git a/crypto/simd.c b/crypto/simd.c
index ea7240be3001..78e8d037ae2b 100644
--- a/crypto/simd.c
+++ b/crypto/simd.c
@@ -124,8 +124,9 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
124 124
125 ctx->cryptd_tfm = cryptd_tfm; 125 ctx->cryptd_tfm = cryptd_tfm;
126 126
127 reqsize = sizeof(struct skcipher_request); 127 reqsize = crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
128 reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base); 128 reqsize = max(reqsize, crypto_skcipher_reqsize(&cryptd_tfm->base));
129 reqsize += sizeof(struct skcipher_request);
129 130
130 crypto_skcipher_set_reqsize(tfm, reqsize); 131 crypto_skcipher_set_reqsize(tfm, reqsize);
131 132