Update some patch for uadk from mainline. To get more infomation, please visit the homepage: https://github.com/Linaro/uadk Signed-off-by: Yang Shen <shenyang39@huawei.com>
48 lines
1.5 KiB
Diff
48 lines
1.5 KiB
Diff
From 5927f19669247d738dfd4a687b5f134a2d289784 Mon Sep 17 00:00:00 2001
|
|
From: Kai Ye <yekai13@huawei.com>
|
|
Date: Wed, 29 Dec 2021 17:14:11 +0800
|
|
Subject: [PATCH 27/28] hisi-sec: bugfix for out_bytes checking
|
|
|
|
1. Add out_bytes checking for digest alg. and modify some log
|
|
information.
|
|
2. Optimize the in_bytes length checking.
|
|
|
|
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
|
---
|
|
drv/hisi_sec.c | 11 ++++++++---
|
|
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
|
|
index 603bdda..d31a1b9 100644
|
|
--- a/drv/hisi_sec.c
|
|
+++ b/drv/hisi_sec.c
|
|
@@ -1279,9 +1279,9 @@ static void parse_digest_bd2(struct hisi_sec_sqe *sqe, struct wd_digest_msg *rec
|
|
|
|
static int digest_long_bd_check(struct wd_digest_msg *msg)
|
|
{
|
|
- if (msg->alg >= WD_DIGEST_SHA512 && msg->in_bytes % SHA512_ALIGN_SZ)
|
|
+ if (msg->alg >= WD_DIGEST_SHA512 && msg->in_bytes & (SHA512_ALIGN_SZ - 1))
|
|
return -WD_EINVAL;
|
|
- else if (msg->in_bytes % SHA1_ALIGN_SZ)
|
|
+ else if (msg->in_bytes & (SHA1_ALIGN_SZ - 1))
|
|
return -WD_EINVAL;
|
|
|
|
return 0;
|
|
@@ -1298,7 +1298,12 @@ static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type)
|
|
}
|
|
|
|
if (unlikely(msg->in_bytes > MAX_INPUT_DATA_LEN)) {
|
|
- WD_ERR("input data length is too long, size:%u!\n", msg->in_bytes);
|
|
+ WD_ERR("digest input length is too long, size:%u!\n", msg->in_bytes);
|
|
+ return -WD_EINVAL;
|
|
+ }
|
|
+
|
|
+ if (unlikely(msg->out_bytes & WORD_ALIGNMENT_MASK)) {
|
|
+ WD_ERR("digest out length is error, size:%u!\n", msg->out_bytes);
|
|
return -WD_EINVAL;
|
|
}
|
|
|
|
--
|
|
2.31.1
|
|
|