From: Wenkai Lin linwenkai6@hisilicon.com
driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8LFYK CVE: NA
----------------------------------------------------------------------
Add device algs size check in hisi_qm_set_algs(). And remove unused parameter 'algs' in 'struct hisi_qm'.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com Signed-off-by: JiangShui Yang yangjiangshui@h-partners.com --- drivers/crypto/hisilicon/qm.c | 13 +++++++++---- include/linux/hisi_acc_qm.h | 1 - 2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index bd19a8746575..7547d12d7a9a 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -838,6 +838,12 @@ int hisi_qm_set_algs(struct hisi_qm *qm, u64 alg_msk, const struct qm_dev_alg *d if (!qm->use_uacce) return 0;
+ if (dev_algs_size >= QM_DEV_ALG_MAX_LEN) { + dev_err(dev, "algs size %u is equal or larger than %d.\n", + dev_algs_size, QM_DEV_ALG_MAX_LEN); + return -EINVAL; + } + algs = devm_kzalloc(dev, QM_DEV_ALG_MAX_LEN * sizeof(char), GFP_KERNEL); if (!algs) return -ENOMEM; @@ -847,10 +853,10 @@ int hisi_qm_set_algs(struct hisi_qm *qm, u64 alg_msk, const struct qm_dev_alg *d strcat(algs, dev_algs[i].alg);
ptr = strrchr(algs, '\n'); - if (ptr) + if (ptr) { *ptr = '\0'; - - qm->uacce->algs = algs; + qm->uacce->algs = algs; + }
return 0; } @@ -2546,7 +2552,6 @@ static void qm_uacce_base_init(struct hisi_qm *qm)
uacce->is_vf = pdev->is_virtfn; uacce->priv = qm; - uacce->algs = qm->algs; uacce->parent = &pdev->dev; qm_get_xqc_depth(qm, &sq_depth, &cq_depth, QM_QP_DEPTH_CAP);
diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h index 0cfc46a5eda2..113e0720441f 100644 --- a/include/linux/hisi_acc_qm.h +++ b/include/linux/hisi_acc_qm.h @@ -395,7 +395,6 @@ struct hisi_qm { struct work_struct rst_work; struct work_struct cmd_process;
- const char *algs; bool use_uacce; bool use_sva; bool use_iommu;