Commit 93bbca27 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 64677779 819966c0
...@@ -178,8 +178,6 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval) ...@@ -178,8 +178,6 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
if (IS_ERR(thread)) if (IS_ERR(thread))
goto err_put_larval; goto err_put_larval;
wait_for_completion_interruptible(&larval->completion);
return NOTIFY_STOP; return NOTIFY_STOP;
err_put_larval: err_put_larval:
......
...@@ -74,14 +74,10 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg, ...@@ -74,14 +74,10 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
return PTR_ERR(areq); return PTR_ERR(areq);
/* convert iovecs of output buffers into RX SGL */ /* convert iovecs of output buffers into RX SGL */
err = af_alg_get_rsgl(sk, msg, flags, areq, -1, &len); err = af_alg_get_rsgl(sk, msg, flags, areq, ctx->used, &len);
if (err) if (err)
goto free; goto free;
/* Process only as much RX buffers for which we have TX data */
if (len > ctx->used)
len = ctx->used;
/* /*
* If more buffers are to be expected to be processed, process only * If more buffers are to be expected to be processed, process only
* full block size buffers. * full block size buffers.
......
...@@ -1631,9 +1631,11 @@ static int drbg_uninstantiate(struct drbg_state *drbg) ...@@ -1631,9 +1631,11 @@ static int drbg_uninstantiate(struct drbg_state *drbg)
if (drbg->random_ready.func) { if (drbg->random_ready.func) {
del_random_ready_callback(&drbg->random_ready); del_random_ready_callback(&drbg->random_ready);
cancel_work_sync(&drbg->seed_work); cancel_work_sync(&drbg->seed_work);
}
if (!IS_ERR_OR_NULL(drbg->jent))
crypto_free_rng(drbg->jent); crypto_free_rng(drbg->jent);
drbg->jent = NULL; drbg->jent = NULL;
}
if (drbg->d_ops) if (drbg->d_ops)
drbg->d_ops->crypto_fini(drbg); drbg->d_ops->crypto_fini(drbg);
......
...@@ -244,6 +244,7 @@ static int ks_sa_rng_probe(struct platform_device *pdev) ...@@ -244,6 +244,7 @@ static int ks_sa_rng_probe(struct platform_device *pdev)
ret = pm_runtime_get_sync(dev); ret = pm_runtime_get_sync(dev);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Failed to enable SA power-domain\n"); dev_err(dev, "Failed to enable SA power-domain\n");
pm_runtime_put_noidle(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
return ret; return ret;
} }
......
...@@ -147,7 +147,7 @@ config CRYPTO_DEV_FSL_CAAM_RNG_API ...@@ -147,7 +147,7 @@ config CRYPTO_DEV_FSL_CAAM_RNG_API
select HW_RANDOM select HW_RANDOM
help help
Selecting this will register the SEC4 hardware rng to Selecting this will register the SEC4 hardware rng to
the hw_random API for suppying the kernel entropy pool. the hw_random API for supplying the kernel entropy pool.
endif # CRYPTO_DEV_FSL_CAAM_JR endif # CRYPTO_DEV_FSL_CAAM_JR
......
...@@ -54,7 +54,7 @@ static void build_instantiation_desc(u32 *desc, int handle, int do_sk) ...@@ -54,7 +54,7 @@ static void build_instantiation_desc(u32 *desc, int handle, int do_sk)
/* /*
* load 1 to clear written reg: * load 1 to clear written reg:
* resets the done interrrupt and returns the RNG to idle. * resets the done interrupt and returns the RNG to idle.
*/ */
append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW); append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW);
...@@ -156,7 +156,7 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, ...@@ -156,7 +156,7 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc,
DESC_DER_DECO_STAT_SHIFT; DESC_DER_DECO_STAT_SHIFT;
/* /*
* If an error occured in the descriptor, then * If an error occurred in the descriptor, then
* the DECO status field will be set to 0x0D * the DECO status field will be set to 0x0D
*/ */
if (deco_state == DECO_STAT_HOST_ERR) if (deco_state == DECO_STAT_HOST_ERR)
...@@ -264,7 +264,7 @@ static void devm_deinstantiate_rng(void *data) ...@@ -264,7 +264,7 @@ static void devm_deinstantiate_rng(void *data)
* - -ENODEV if DECO0 couldn't be acquired * - -ENODEV if DECO0 couldn't be acquired
* - -EAGAIN if an error occurred when executing the descriptor * - -EAGAIN if an error occurred when executing the descriptor
* f.i. there was a RNG hardware error due to not "good enough" * f.i. there was a RNG hardware error due to not "good enough"
* entropy being aquired. * entropy being acquired.
*/ */
static int instantiate_rng(struct device *ctrldev, int state_handle_mask, static int instantiate_rng(struct device *ctrldev, int state_handle_mask,
int gen_sk) int gen_sk)
...@@ -733,8 +733,8 @@ static int caam_probe(struct platform_device *pdev) ...@@ -733,8 +733,8 @@ static int caam_probe(struct platform_device *pdev)
handle_imx6_err005766(&ctrl->mcr); handle_imx6_err005766(&ctrl->mcr);
/* /*
* Read the Compile Time paramters and SCFGR to determine * Read the Compile Time parameters and SCFGR to determine
* if Virtualization is enabled for this platform * if virtualization is enabled for this platform
*/ */
scfgr = rd_reg32(&ctrl->scfgr); scfgr = rd_reg32(&ctrl->scfgr);
...@@ -863,9 +863,9 @@ static int caam_probe(struct platform_device *pdev) ...@@ -863,9 +863,9 @@ static int caam_probe(struct platform_device *pdev)
} }
/* /*
* if instantiate_rng(...) fails, the loop will rerun * if instantiate_rng(...) fails, the loop will rerun
* and the kick_trng(...) function will modfiy the * and the kick_trng(...) function will modify the
* upper and lower limits of the entropy sampling * upper and lower limits of the entropy sampling
* interval, leading to a sucessful initialization of * interval, leading to a successful initialization of
* the RNG. * the RNG.
*/ */
ret = instantiate_rng(dev, inst_handles, ret = instantiate_rng(dev, inst_handles,
...@@ -882,8 +882,8 @@ static int caam_probe(struct platform_device *pdev) ...@@ -882,8 +882,8 @@ static int caam_probe(struct platform_device *pdev)
return ret; return ret;
} }
/* /*
* Set handles init'ed by this module as the complement of the * Set handles initialized by this module as the complement of
* already initialized ones * the already initialized ones
*/ */
ctrlpriv->rng4_sh_init = ~ctrlpriv->rng4_sh_init & RDSTA_MASK; ctrlpriv->rng4_sh_init = ~ctrlpriv->rng4_sh_init & RDSTA_MASK;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#define SEC4_SG_LEN_EXT 0x80000000 /* Entry points to table */ #define SEC4_SG_LEN_EXT 0x80000000 /* Entry points to table */
#define SEC4_SG_LEN_FIN 0x40000000 /* Last ent in table */ #define SEC4_SG_LEN_FIN 0x40000000 /* Last entry in table */
#define SEC4_SG_BPID_MASK 0x000000ff #define SEC4_SG_BPID_MASK 0x000000ff
#define SEC4_SG_BPID_SHIFT 16 #define SEC4_SG_BPID_SHIFT 16
#define SEC4_SG_LEN_MASK 0x3fffffff /* Excludes EXT and FINAL */ #define SEC4_SG_LEN_MASK 0x3fffffff /* Excludes EXT and FINAL */
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
*/ */
#define HDR_REVERSE 0x00000800 #define HDR_REVERSE 0x00000800
/* Propogate DNR property to SharedDesc */ /* Propagate DNR property to SharedDesc */
#define HDR_PROP_DNR 0x00000800 #define HDR_PROP_DNR 0x00000800
/* JobDesc/SharedDesc share property */ /* JobDesc/SharedDesc share property */
......
...@@ -453,7 +453,7 @@ struct srtp_decap_pdb { ...@@ -453,7 +453,7 @@ struct srtp_decap_pdb {
#define DSA_PDB_N_MASK 0x7f #define DSA_PDB_N_MASK 0x7f
struct dsa_sign_pdb { struct dsa_sign_pdb {
u32 sgf_ln; /* Use DSA_PDB_ defintions per above */ u32 sgf_ln; /* Use DSA_PDB_ definitions per above */
u8 *q; u8 *q;
u8 *r; u8 *r;
u8 *g; /* or Gx,y */ u8 *g; /* or Gx,y */
......
...@@ -376,6 +376,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable) ...@@ -376,6 +376,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
struct sev_device *sev = psp_master->sev_data; struct sev_device *sev = psp_master->sev_data;
struct sev_user_data_pek_csr input; struct sev_user_data_pek_csr input;
struct sev_data_pek_csr *data; struct sev_data_pek_csr *data;
void __user *input_address;
void *blob = NULL; void *blob = NULL;
int ret; int ret;
...@@ -394,6 +395,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable) ...@@ -394,6 +395,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
goto cmd; goto cmd;
/* allocate a physically contiguous buffer to store the CSR blob */ /* allocate a physically contiguous buffer to store the CSR blob */
input_address = (void __user *)input.address;
if (input.length > SEV_FW_BLOB_MAX_SIZE) { if (input.length > SEV_FW_BLOB_MAX_SIZE) {
ret = -EFAULT; ret = -EFAULT;
goto e_free; goto e_free;
...@@ -426,7 +428,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable) ...@@ -426,7 +428,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
} }
if (blob) { if (blob) {
if (copy_to_user((void __user *)input.address, blob, input.length)) if (copy_to_user(input_address, blob, input.length))
ret = -EFAULT; ret = -EFAULT;
} }
...@@ -437,7 +439,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable) ...@@ -437,7 +439,7 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
return ret; return ret;
} }
void *psp_copy_user_blob(u64 __user uaddr, u32 len) void *psp_copy_user_blob(u64 uaddr, u32 len)
{ {
if (!uaddr || !len) if (!uaddr || !len)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -446,7 +448,7 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len) ...@@ -446,7 +448,7 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len)
if (len > SEV_FW_BLOB_MAX_SIZE) if (len > SEV_FW_BLOB_MAX_SIZE)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
return memdup_user((void __user *)(uintptr_t)uaddr, len); return memdup_user((void __user *)uaddr, len);
} }
EXPORT_SYMBOL_GPL(psp_copy_user_blob); EXPORT_SYMBOL_GPL(psp_copy_user_blob);
...@@ -621,6 +623,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp) ...@@ -621,6 +623,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
{ {
struct sev_user_data_get_id2 input; struct sev_user_data_get_id2 input;
struct sev_data_get_id *data; struct sev_data_get_id *data;
void __user *input_address;
void *id_blob = NULL; void *id_blob = NULL;
int ret; int ret;
...@@ -631,6 +634,8 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp) ...@@ -631,6 +634,8 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
if (copy_from_user(&input, (void __user *)argp->data, sizeof(input))) if (copy_from_user(&input, (void __user *)argp->data, sizeof(input)))
return -EFAULT; return -EFAULT;
input_address = (void __user *)input.address;
data = kzalloc(sizeof(*data), GFP_KERNEL); data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -660,8 +665,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp) ...@@ -660,8 +665,7 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
} }
if (id_blob) { if (id_blob) {
if (copy_to_user((void __user *)input.address, if (copy_to_user(input_address, id_blob, data->len)) {
id_blob, data->len)) {
ret = -EFAULT; ret = -EFAULT;
goto e_free; goto e_free;
} }
...@@ -720,6 +724,8 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable) ...@@ -720,6 +724,8 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
struct sev_user_data_pdh_cert_export input; struct sev_user_data_pdh_cert_export input;
void *pdh_blob = NULL, *cert_blob = NULL; void *pdh_blob = NULL, *cert_blob = NULL;
struct sev_data_pdh_cert_export *data; struct sev_data_pdh_cert_export *data;
void __user *input_cert_chain_address;
void __user *input_pdh_cert_address;
int ret; int ret;
/* If platform is not in INIT state then transition it to INIT. */ /* 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) ...@@ -745,6 +751,9 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
!input.cert_chain_address) !input.cert_chain_address)
goto cmd; goto cmd;
input_pdh_cert_address = (void __user *)input.pdh_cert_address;
input_cert_chain_address = (void __user *)input.cert_chain_address;
/* Allocate a physically contiguous buffer to store the PDH blob. */ /* Allocate a physically contiguous buffer to store the PDH blob. */
if (input.pdh_cert_len > SEV_FW_BLOB_MAX_SIZE) { if (input.pdh_cert_len > SEV_FW_BLOB_MAX_SIZE) {
ret = -EFAULT; ret = -EFAULT;
...@@ -788,7 +797,7 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable) ...@@ -788,7 +797,7 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
} }
if (pdh_blob) { if (pdh_blob) {
if (copy_to_user((void __user *)input.pdh_cert_address, if (copy_to_user(input_pdh_cert_address,
pdh_blob, input.pdh_cert_len)) { pdh_blob, input.pdh_cert_len)) {
ret = -EFAULT; ret = -EFAULT;
goto e_free_cert; goto e_free_cert;
...@@ -796,7 +805,7 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable) ...@@ -796,7 +805,7 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
} }
if (cert_blob) { if (cert_blob) {
if (copy_to_user((void __user *)input.cert_chain_address, if (copy_to_user(input_cert_chain_address,
cert_blob, input.cert_chain_len)) cert_blob, input.cert_chain_len))
ret = -EFAULT; ret = -EFAULT;
} }
......
...@@ -66,7 +66,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev, ...@@ -66,7 +66,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,
sgl_size = sizeof(struct acc_hw_sge) * sge_nr + sgl_size = sizeof(struct acc_hw_sge) * sge_nr +
sizeof(struct hisi_acc_hw_sgl); sizeof(struct hisi_acc_hw_sgl);
block_size = PAGE_SIZE * (1 << (MAX_ORDER - 1)); block_size = 1 << (PAGE_SHIFT + MAX_ORDER <= 32 ?
PAGE_SHIFT + MAX_ORDER - 1 : 31);
sgl_num_per_block = block_size / sgl_size; sgl_num_per_block = block_size / sgl_size;
block_num = count / sgl_num_per_block; block_num = count / sgl_num_per_block;
remain_sgl = count % sgl_num_per_block; remain_sgl = count % sgl_num_per_block;
......
...@@ -118,6 +118,9 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2) ...@@ -118,6 +118,9 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
struct otx_cpt_req_info *cpt_req; struct otx_cpt_req_info *cpt_req;
struct pci_dev *pdev; struct pci_dev *pdev;
if (!cpt_info)
goto complete;
cpt_req = cpt_info->req; cpt_req = cpt_info->req;
if (!status) { if (!status) {
/* /*
...@@ -129,10 +132,10 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2) ...@@ -129,10 +132,10 @@ static void otx_cpt_aead_callback(int status, void *arg1, void *arg2)
!cpt_req->is_enc) !cpt_req->is_enc)
status = validate_hmac_cipher_null(cpt_req); status = validate_hmac_cipher_null(cpt_req);
} }
if (cpt_info) {
pdev = cpt_info->pdev; pdev = cpt_info->pdev;
do_request_cleanup(pdev, cpt_info); do_request_cleanup(pdev, cpt_info);
}
complete:
if (areq) if (areq)
areq->complete(areq, status); areq->complete(areq, status);
} }
......
...@@ -597,7 +597,7 @@ int sev_guest_df_flush(int *error); ...@@ -597,7 +597,7 @@ int sev_guest_df_flush(int *error);
*/ */
int sev_guest_decommission(struct sev_data_decommission *data, int *error); int sev_guest_decommission(struct sev_data_decommission *data, int *error);
void *psp_copy_user_blob(u64 __user uaddr, u32 len); void *psp_copy_user_blob(u64 uaddr, u32 len);
#else /* !CONFIG_CRYPTO_DEV_SP_PSP */ #else /* !CONFIG_CRYPTO_DEV_SP_PSP */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment