diff mbox series

ubifs: add check for crypto_shash_tfm_digest

Message ID 20240620034533.569099-1-nichen@iscas.ac.cn
State Changes Requested
Headers show
Series ubifs: add check for crypto_shash_tfm_digest | expand

Commit Message

Chen Ni June 20, 2024, 3:45 a.m. UTC
Add check for the return value of crypto_shash_tfm_digest() and return
the error if it fails in order to catch the error.

Fixes: f80df3851246 ("ubifs: use crypto_shash_tfm_digest()")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 fs/ubifs/master.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Zhihao Cheng June 20, 2024, 6:14 a.m. UTC | #1
在 2024/6/20 11:45, Chen Ni 写道:
> Add check for the return value of crypto_shash_tfm_digest() and return
> the error if it fails in order to catch the error.
> 
> Fixes: f80df3851246 ("ubifs: use crypto_shash_tfm_digest()")

I think the fix tag should 
817aa094842dfc3a6b98c9582d4a647827f66201("ubifs: support offline signed 
images"), otherwise:
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>   fs/ubifs/master.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c
> index 7adc37c10b6a..a148760fa49e 100644
> --- a/fs/ubifs/master.c
> +++ b/fs/ubifs/master.c
> @@ -67,10 +67,13 @@ static int mst_node_check_hash(const struct ubifs_info *c,
>   {
>   	u8 calc[UBIFS_MAX_HASH_LEN];
>   	const void *node = mst;
> +	int ret;
>   
> -	crypto_shash_tfm_digest(c->hash_tfm, node + sizeof(struct ubifs_ch),
> +	ret = crypto_shash_tfm_digest(c->hash_tfm, node + sizeof(struct ubifs_ch),
>   				UBIFS_MST_NODE_SZ - sizeof(struct ubifs_ch),
>   				calc);
> +	if (ret)
> +		return ret;
>   
>   	if (ubifs_check_hash(c, expected, calc))
>   		return -EPERM;
>
diff mbox series

Patch

diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c
index 7adc37c10b6a..a148760fa49e 100644
--- a/fs/ubifs/master.c
+++ b/fs/ubifs/master.c
@@ -67,10 +67,13 @@  static int mst_node_check_hash(const struct ubifs_info *c,
 {
 	u8 calc[UBIFS_MAX_HASH_LEN];
 	const void *node = mst;
+	int ret;
 
-	crypto_shash_tfm_digest(c->hash_tfm, node + sizeof(struct ubifs_ch),
+	ret = crypto_shash_tfm_digest(c->hash_tfm, node + sizeof(struct ubifs_ch),
 				UBIFS_MST_NODE_SZ - sizeof(struct ubifs_ch),
 				calc);
+	if (ret)
+		return ret;
 
 	if (ubifs_check_hash(c, expected, calc))
 		return -EPERM;