Skip to content

Commit 93bbca2

Browse files
committed
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: - NULL dereference in octeontx - PM reference imbalance in ks-sa - deadlock in crypto manager - memory leak in drbg - missing socket limit check on receive SG list size in algif_skcipher - typos in caam - warnings in ccp and hisilicon * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: drbg - always try to free Jitter RNG instance crypto: marvell/octeontx - Fix a potential NULL dereference crypto: algboss - don't wait during notifier callback crypto: caam - fix typos crypto: ccp - Fix sparse warnings in sev-dev crypto: hisilicon - Cap block size at 2^31 crypto: algif_skcipher - Cap recv SG list at ctx->used hwrng: ks-sa - Fix runtime PM imbalance on error
2 parents 6467777 + 819966c commit 93bbca2

File tree

12 files changed

+45
-35
lines changed

12 files changed

+45
-35
lines changed

crypto/algboss.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
178178
if (IS_ERR(thread))
179179
goto err_put_larval;
180180

181-
wait_for_completion_interruptible(&larval->completion);
182-
183181
return NOTIFY_STOP;
184182

185183
err_put_larval:

crypto/algif_skcipher.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,10 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
7474
return PTR_ERR(areq);
7575

7676
/* convert iovecs of output buffers into RX SGL */
77-
err = af_alg_get_rsgl(sk, msg, flags, areq, -1, &len);
77+
err = af_alg_get_rsgl(sk, msg, flags, areq, ctx->used, &len);
7878
if (err)
7979
goto free;
8080

81-
/* Process only as much RX buffers for which we have TX data */
82-
if (len > ctx->used)
83-
len = ctx->used;
84-
8581
/*
8682
* If more buffers are to be expected to be processed, process only
8783
* full block size buffers.

crypto/drbg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,10 +1631,12 @@ static int drbg_uninstantiate(struct drbg_state *drbg)
16311631
if (drbg->random_ready.func) {
16321632
del_random_ready_callback(&drbg->random_ready);
16331633
cancel_work_sync(&drbg->seed_work);
1634-
crypto_free_rng(drbg->jent);
1635-
drbg->jent = NULL;
16361634
}
16371635

1636+
if (!IS_ERR_OR_NULL(drbg->jent))
1637+
crypto_free_rng(drbg->jent);
1638+
drbg->jent = NULL;
1639+
16381640
if (drbg->d_ops)
16391641
drbg->d_ops->crypto_fini(drbg);
16401642
drbg_dealloc_state(drbg);

drivers/char/hw_random/ks-sa-rng.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ static int ks_sa_rng_probe(struct platform_device *pdev)
244244
ret = pm_runtime_get_sync(dev);
245245
if (ret < 0) {
246246
dev_err(dev, "Failed to enable SA power-domain\n");
247+
pm_runtime_put_noidle(dev);
247248
pm_runtime_disable(dev);
248249
return ret;
249250
}

drivers/crypto/caam/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ config CRYPTO_DEV_FSL_CAAM_RNG_API
147147
select HW_RANDOM
148148
help
149149
Selecting this will register the SEC4 hardware rng to
150-
the hw_random API for suppying the kernel entropy pool.
150+
the hw_random API for supplying the kernel entropy pool.
151151

152152
endif # CRYPTO_DEV_FSL_CAAM_JR
153153

drivers/crypto/caam/ctrl.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void build_instantiation_desc(u32 *desc, int handle, int do_sk)
5454

5555
/*
5656
* load 1 to clear written reg:
57-
* resets the done interrrupt and returns the RNG to idle.
57+
* resets the done interrupt and returns the RNG to idle.
5858
*/
5959
append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW);
6060

@@ -156,7 +156,7 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc,
156156
DESC_DER_DECO_STAT_SHIFT;
157157

158158
/*
159-
* If an error occured in the descriptor, then
159+
* If an error occurred in the descriptor, then
160160
* the DECO status field will be set to 0x0D
161161
*/
162162
if (deco_state == DECO_STAT_HOST_ERR)
@@ -264,7 +264,7 @@ static void devm_deinstantiate_rng(void *data)
264264
* - -ENODEV if DECO0 couldn't be acquired
265265
* - -EAGAIN if an error occurred when executing the descriptor
266266
* f.i. there was a RNG hardware error due to not "good enough"
267-
* entropy being aquired.
267+
* entropy being acquired.
268268
*/
269269
static int instantiate_rng(struct device *ctrldev, int state_handle_mask,
270270
int gen_sk)
@@ -733,8 +733,8 @@ static int caam_probe(struct platform_device *pdev)
733733
handle_imx6_err005766(&ctrl->mcr);
734734

735735
/*
736-
* Read the Compile Time paramters and SCFGR to determine
737-
* if Virtualization is enabled for this platform
736+
* Read the Compile Time parameters and SCFGR to determine
737+
* if virtualization is enabled for this platform
738738
*/
739739
scfgr = rd_reg32(&ctrl->scfgr);
740740

@@ -863,9 +863,9 @@ static int caam_probe(struct platform_device *pdev)
863863
}
864864
/*
865865
* if instantiate_rng(...) fails, the loop will rerun
866-
* and the kick_trng(...) function will modfiy the
866+
* and the kick_trng(...) function will modify the
867867
* upper and lower limits of the entropy sampling
868-
* interval, leading to a sucessful initialization of
868+
* interval, leading to a successful initialization of
869869
* the RNG.
870870
*/
871871
ret = instantiate_rng(dev, inst_handles,
@@ -882,8 +882,8 @@ static int caam_probe(struct platform_device *pdev)
882882
return ret;
883883
}
884884
/*
885-
* Set handles init'ed by this module as the complement of the
886-
* already initialized ones
885+
* Set handles initialized by this module as the complement of
886+
* the already initialized ones
887887
*/
888888
ctrlpriv->rng4_sh_init = ~ctrlpriv->rng4_sh_init & RDSTA_MASK;
889889

drivers/crypto/caam/desc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
#define SEC4_SG_LEN_EXT 0x80000000 /* Entry points to table */
21-
#define SEC4_SG_LEN_FIN 0x40000000 /* Last ent in table */
21+
#define SEC4_SG_LEN_FIN 0x40000000 /* Last entry in table */
2222
#define SEC4_SG_BPID_MASK 0x000000ff
2323
#define SEC4_SG_BPID_SHIFT 16
2424
#define SEC4_SG_LEN_MASK 0x3fffffff /* Excludes EXT and FINAL */
@@ -113,7 +113,7 @@
113113
*/
114114
#define HDR_REVERSE 0x00000800
115115

116-
/* Propogate DNR property to SharedDesc */
116+
/* Propagate DNR property to SharedDesc */
117117
#define HDR_PROP_DNR 0x00000800
118118

119119
/* JobDesc/SharedDesc share property */

drivers/crypto/caam/pdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ struct srtp_decap_pdb {
453453
#define DSA_PDB_N_MASK 0x7f
454454

455455
struct dsa_sign_pdb {
456-
u32 sgf_ln; /* Use DSA_PDB_ defintions per above */
456+
u32 sgf_ln; /* Use DSA_PDB_ definitions per above */
457457
u8 *q;
458458
u8 *r;
459459
u8 *g; /* or Gx,y */

drivers/crypto/ccp/sev-dev.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
376376
struct sev_device *sev = psp_master->sev_data;
377377
struct sev_user_data_pek_csr input;
378378
struct sev_data_pek_csr *data;
379+
void __user *input_address;
379380
void *blob = NULL;
380381
int ret;
381382

@@ -394,6 +395,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
394395
goto cmd;
395396

396397
/* allocate a physically contiguous buffer to store the CSR blob */
398+
input_address = (void __user *)input.address;
397399
if (input.length > SEV_FW_BLOB_MAX_SIZE) {
398400
ret = -EFAULT;
399401
goto e_free;
@@ -426,7 +428,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
426428
}
427429

428430
if (blob) {
429-
if (copy_to_user((void __user *)input.address, blob, input.length))
431+
if (copy_to_user(input_address, blob, input.length))
430432
ret = -EFAULT;
431433
}
432434

@@ -437,7 +439,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
437439
return ret;
438440
}
439441

440-
void *psp_copy_user_blob(u64 __user uaddr, u32 len)
442+
void *psp_copy_user_blob(u64 uaddr, u32 len)
441443
{
442444
if (!uaddr || !len)
443445
return ERR_PTR(-EINVAL);
@@ -446,7 +448,7 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len)
446448
if (len > SEV_FW_BLOB_MAX_SIZE)
447449
return ERR_PTR(-EINVAL);
448450

449-
return memdup_user((void __user *)(uintptr_t)uaddr, len);
451+
return memdup_user((void __user *)uaddr, len);
450452
}
451453
EXPORT_SYMBOL_GPL(psp_copy_user_blob);
452454

@@ -621,6 +623,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
621623
{
622624
struct sev_user_data_get_id2 input;
623625
struct sev_data_get_id *data;
626+
void __user *input_address;
624627
void *id_blob = NULL;
625628
int ret;
626629

@@ -631,6 +634,8 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
631634
if (copy_from_user(&input, (void __user *)argp->data, sizeof(input)))
632635
return -EFAULT;
633636

637+
input_address = (void __user *)input.address;
638+
634639
data = kzalloc(sizeof(*data), GFP_KERNEL);
635640
if (!data)
636641
return -ENOMEM;
@@ -660,8 +665,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
660665
}
661666

662667
if (id_blob) {
663-
if (copy_to_user((void __user *)input.address,
664-
id_blob, data->len)) {
668+
if (copy_to_user(input_address, id_blob, data->len)) {
665669
ret = -EFAULT;
666670
goto e_free;
667671
}
@@ -720,6 +724,8 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
720724
struct sev_user_data_pdh_cert_export input;
721725
void *pdh_blob = NULL, *cert_blob = NULL;
722726
struct sev_data_pdh_cert_export *data;
727+
void __user *input_cert_chain_address;
728+
void __user *input_pdh_cert_address;
723729
int ret;
724730

725731
/* If platform is not in INIT state then transition it to INIT. */
@@ -745,6 +751,9 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
745751
!input.cert_chain_address)
746752
goto cmd;
747753

754+
input_pdh_cert_address = (void __user *)input.pdh_cert_address;
755+
input_cert_chain_address = (void __user *)input.cert_chain_address;
756+
748757
/* Allocate a physically contiguous buffer to store the PDH blob. */
749758
if (input.pdh_cert_len > SEV_FW_BLOB_MAX_SIZE) {
750759
ret = -EFAULT;
@@ -788,15 +797,15 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
788797
}
789798

790799
if (pdh_blob) {
791-
if (copy_to_user((void __user *)input.pdh_cert_address,
800+
if (copy_to_user(input_pdh_cert_address,
792801
pdh_blob, input.pdh_cert_len)) {
793802
ret = -EFAULT;
794803
goto e_free_cert;
795804
}
796805
}
797806

798807
if (cert_blob) {
799-
if (copy_to_user((void __user *)input.cert_chain_address,
808+
if (copy_to_user(input_cert_chain_address,
800809
cert_blob, input.cert_chain_len))
801810
ret = -EFAULT;
802811
}

drivers/crypto/hisilicon/sgl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,
6666

6767
sgl_size = sizeof(struct acc_hw_sge) * sge_nr +
6868
sizeof(struct hisi_acc_hw_sgl);
69-
block_size = PAGE_SIZE * (1 << (MAX_ORDER - 1));
69+
block_size = 1 << (PAGE_SHIFT + MAX_ORDER <= 32 ?
70+
PAGE_SHIFT + MAX_ORDER - 1 : 31);
7071
sgl_num_per_block = block_size / sgl_size;
7172
block_num = count / sgl_num_per_block;
7273
remain_sgl = count % sgl_num_per_block;

0 commit comments

Comments
 (0)