From 38cad8c5bcc49ee130443c5d8f396b0498535595 Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Fri, 26 May 2023 18:04:37 +0800 Subject: [PATCH 1/2] crypto: hisilicon/trng - use %u to print u32 variables driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9A5GZ CVE: NA ---------------------------------------------------------------------- The 'dlen' is u32 type, use %u instead of %d to print u32 values. Signed-off-by: Weili Qian Signed-off-by: JiangShui Yang --- drivers/crypto/hisilicon/trng/trng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/trng/trng.c b/drivers/crypto/hisilicon/trng/trng.c index 451b167bcc73..025f39a0bb82 100644 --- a/drivers/crypto/hisilicon/trng/trng.c +++ b/drivers/crypto/hisilicon/trng/trng.c @@ -121,7 +121,7 @@ static int hisi_trng_generate(struct crypto_rng *tfm, const u8 *src, u32 i; if (dlen > SW_DRBG_BLOCKS_NUM * SW_DRBG_BYTES || dlen == 0) { - pr_err("dlen(%d) exceeds limit(%d)!\n", dlen, + pr_err("dlen(%u) exceeds limit(%d)!\n", dlen, SW_DRBG_BLOCKS_NUM * SW_DRBG_BYTES); return -EINVAL; } -- Gitee From decc5b842f27bfe99806769b943f857b9a274d13 Mon Sep 17 00:00:00 2001 From: liulongfang Date: Fri, 26 May 2023 18:04:38 +0800 Subject: [PATCH 2/2] crypto/trng: Remove the automatic loading of the hisi_trng driver driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9A5GZ CVE: NA ---------------------------------------------------------------------- On the current openEuler OS, when the OS is automatically started, the hisi_trng_v2 device driver will be loaded because the algorithm self-test needs to use random numbers. However, the trng framework of community crypto requires that the first loaded and used trng resource handle cannot be released, which will cause hisi_trng_v2 to fail to unload the driver in subsequent hisi trng module function processing. The patch is modified by reducing the algorithm priority of the hardware device driver. Not enabled in autotest and load. Only reload this device driver for stand-alone use. Signed-off-by: liulongfang Signed-off-by: JiangShui Yang --- drivers/crypto/hisilicon/trng/trng.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/trng/trng.c b/drivers/crypto/hisilicon/trng/trng.c index 025f39a0bb82..72abc3d85b3b 100644 --- a/drivers/crypto/hisilicon/trng/trng.c +++ b/drivers/crypto/hisilicon/trng/trng.c @@ -27,6 +27,7 @@ #define SW_DRBG_SEED(n) (SW_DRBG_KEY_BASE - ((n) << SW_DRBG_NUM_SHIFT)) #define SW_DRBG_SEED_REGS_NUM 12 #define SW_DRBG_SEED_SIZE 48 +#define SW_DRBG_CRYPTO_ALG_PRI 100 #define SW_DRBG_BLOCKS 0x0830 #define SW_DRBG_INIT 0x0834 #define SW_DRBG_GEN 0x083c @@ -218,7 +219,7 @@ static struct rng_alg hisi_trng_alg = { .base = { .cra_name = "stdrng", .cra_driver_name = "hisi_stdrng", - .cra_priority = 300, + .cra_priority = SW_DRBG_CRYPTO_ALG_PRI, .cra_ctxsize = sizeof(struct hisi_trng_ctx), .cra_module = THIS_MODULE, .cra_init = hisi_trng_init, -- Gitee