Patch "ima: Fix misuse of dereference of pointer in template_desc_init_fields()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ima: Fix misuse of dereference of pointer in template_desc_init_fields()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ima-fix-misuse-of-dereference-of-pointer-in-template.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e65090f2e651c360e8faa8e0693216930567edda
Author: Xiu Jianfeng <xiujianfeng@xxxxxxxxxx>
Date:   Sat Nov 12 17:27:19 2022 +0800

    ima: Fix misuse of dereference of pointer in template_desc_init_fields()
    
    [ Upstream commit 25369175ce84813dd99d6604e710dc2491f68523 ]
    
    The input parameter @fields is type of struct ima_template_field ***, so
    when allocates array memory for @fields, the size of element should be
    sizeof(**field) instead of sizeof(*field).
    
    Actually the original code would not cause any runtime error, but it's
    better to make it logically right.
    
    Fixes: adf53a778a0a ("ima: new templates management mechanism")
    Signed-off-by: Xiu Jianfeng <xiujianfeng@xxxxxxxxxx>
    Reviewed-by: Roberto Sassu <roberto.sassu@xxxxxxxxxx>
    Signed-off-by: Mimi Zohar <zohar@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index f64c01d53e96..e053c741997b 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -220,11 +220,11 @@ int template_desc_init_fields(const char *template_fmt,
 	}
 
 	if (fields && num_fields) {
-		*fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL);
+		*fields = kmalloc_array(i, sizeof(**fields), GFP_KERNEL);
 		if (*fields == NULL)
 			return -ENOMEM;
 
-		memcpy(*fields, found_fields, i * sizeof(*fields));
+		memcpy(*fields, found_fields, i * sizeof(**fields));
 		*num_fields = i;
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux