Skip to content

Commit 1863b40

Browse files
committed
Merge tag 'libcrypto-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux
Pull crypto library fixes from Eric Biggers: - Disable the "padlock" SHA-1 and SHA-256 driver on Zhaoxin processors, since it does not compute hash values correctly - Make a generated file be removed by 'make clean' - Fix excessive stack usage in some of the arm64 AES code * tag 'libcrypto-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux: lib/crypto: powerpc: Add powerpc/aesp8-ppc.S to clean-files crypto: padlock-sha - Disable for Zhaoxin processor crypto: arm64/aes-neonbs - Move key expansion off the stack
2 parents 8a30aeb + d5b6617 commit 1863b40

3 files changed

Lines changed: 33 additions & 14 deletions

File tree

arch/arm64/crypto/aes-neonbs-glue.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,24 @@ static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
7676
unsigned int key_len)
7777
{
7878
struct aesbs_ctx *ctx = crypto_skcipher_ctx(tfm);
79-
struct crypto_aes_ctx rk;
79+
struct crypto_aes_ctx *rk;
8080
int err;
8181

82-
err = aes_expandkey(&rk, in_key, key_len);
82+
rk = kmalloc(sizeof(*rk), GFP_KERNEL);
83+
if (!rk)
84+
return -ENOMEM;
85+
86+
err = aes_expandkey(rk, in_key, key_len);
8387
if (err)
84-
return err;
88+
goto out;
8589

8690
ctx->rounds = 6 + key_len / 4;
8791

8892
scoped_ksimd()
89-
aesbs_convert_key(ctx->rk, rk.key_enc, ctx->rounds);
90-
91-
return 0;
93+
aesbs_convert_key(ctx->rk, rk->key_enc, ctx->rounds);
94+
out:
95+
kfree_sensitive(rk);
96+
return err;
9297
}
9398

9499
static int __ecb_crypt(struct skcipher_request *req,
@@ -133,22 +138,26 @@ static int aesbs_cbc_ctr_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
133138
unsigned int key_len)
134139
{
135140
struct aesbs_cbc_ctr_ctx *ctx = crypto_skcipher_ctx(tfm);
136-
struct crypto_aes_ctx rk;
141+
struct crypto_aes_ctx *rk;
137142
int err;
138143

139-
err = aes_expandkey(&rk, in_key, key_len);
144+
rk = kmalloc(sizeof(*rk), GFP_KERNEL);
145+
if (!rk)
146+
return -ENOMEM;
147+
148+
err = aes_expandkey(rk, in_key, key_len);
140149
if (err)
141-
return err;
150+
goto out;
142151

143152
ctx->key.rounds = 6 + key_len / 4;
144153

145-
memcpy(ctx->enc, rk.key_enc, sizeof(ctx->enc));
154+
memcpy(ctx->enc, rk->key_enc, sizeof(ctx->enc));
146155

147156
scoped_ksimd()
148-
aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
149-
memzero_explicit(&rk, sizeof(rk));
150-
151-
return 0;
157+
aesbs_convert_key(ctx->key.rk, rk->key_enc, ctx->key.rounds);
158+
out:
159+
kfree_sensitive(rk);
160+
return err;
152161
}
153162

154163
static int cbc_encrypt(struct skcipher_request *req)

drivers/crypto/padlock-sha.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,13 @@ static int __init padlock_init(void)
332332
if (!x86_match_cpu(padlock_sha_ids) || !boot_cpu_has(X86_FEATURE_PHE_EN))
333333
return -ENODEV;
334334

335+
/*
336+
* Skip family 0x07 and newer used by Zhaoxin processors,
337+
* as the driver's self-tests fail on these CPUs.
338+
*/
339+
if (c->x86 >= 0x07)
340+
return -ENODEV;
341+
335342
/* Register the newly added algorithm module if on *
336343
* VIA Nano processor, or else just do as before */
337344
if (c->x86_model < 0x0f) {

lib/crypto/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ libaes-$(CONFIG_SPARC) += sparc/aes_asm.o
5555
libaes-$(CONFIG_X86) += x86/aes-aesni.o
5656
endif # CONFIG_CRYPTO_LIB_AES_ARCH
5757

58+
# clean-files must be defined unconditionally
59+
clean-files += powerpc/aesp8-ppc.S
60+
5861
################################################################################
5962

6063
obj-$(CONFIG_CRYPTO_LIB_AESCFB) += libaescfb.o

0 commit comments

Comments
 (0)