Patch "ima: Free IMA measurement buffer after kexec syscall" has been added to the 5.4-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: Free IMA measurement buffer after kexec syscall

to the 5.4-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-free-ima-measurement-buffer-after-kexec-syscall.patch
and it can be found in the queue-5.4 subdirectory.

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



commit e80a4b01ec2334c5fa823f129fcc9f23b65b5fdf
Author: Lakshmi Ramasubramanian <nramas@xxxxxxxxxxxxxxxxxxx>
Date:   Thu Feb 4 09:49:51 2021 -0800

    ima: Free IMA measurement buffer after kexec syscall
    
    [ Upstream commit f31e3386a4e92ba6eda7328cb508462956c94c64 ]
    
    IMA allocates kernel virtual memory to carry forward the measurement
    list, from the current kernel to the next kernel on kexec system call,
    in ima_add_kexec_buffer() function.  This buffer is not freed before
    completing the kexec system call resulting in memory leak.
    
    Add ima_buffer field in "struct kimage" to store the virtual address
    of the buffer allocated for the IMA measurement list.
    Free the memory allocated for the IMA measurement list in
    kimage_file_post_load_cleanup() function.
    
    Signed-off-by: Lakshmi Ramasubramanian <nramas@xxxxxxxxxxxxxxxxxxx>
    Suggested-by: Tyler Hicks <tyhicks@xxxxxxxxxxxxxxxxxxx>
    Reviewed-by: Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxx>
    Reviewed-by: Tyler Hicks <tyhicks@xxxxxxxxxxxxxxxxxxx>
    Fixes: 7b8589cc29e7 ("ima: on soft reboot, save the measurement list")
    Signed-off-by: Mimi Zohar <zohar@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 1776eb2e43a44..a1cffce3de8cd 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -293,6 +293,11 @@ struct kimage {
 	/* Information for loading purgatory */
 	struct purgatory_info purgatory_info;
 #endif
+
+#ifdef CONFIG_IMA_KEXEC
+	/* Virtual address of IMA measurement buffer for kexec syscall */
+	void *ima_buffer;
+#endif
 };
 
 /* kexec interface functions */
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 79f252af7dee3..4e74db89bd23f 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -165,6 +165,11 @@ void kimage_file_post_load_cleanup(struct kimage *image)
 	vfree(pi->sechdrs);
 	pi->sechdrs = NULL;
 
+#ifdef CONFIG_IMA_KEXEC
+	vfree(image->ima_buffer);
+	image->ima_buffer = NULL;
+#endif /* CONFIG_IMA_KEXEC */
+
 	/* See if architecture has anything to cleanup post load */
 	arch_kimage_file_post_load_cleanup(image);
 
diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
index 37b1244e3a166..955e4b4d09e21 100644
--- a/security/integrity/ima/ima_kexec.c
+++ b/security/integrity/ima/ima_kexec.c
@@ -130,6 +130,8 @@ void ima_add_kexec_buffer(struct kimage *image)
 		return;
 	}
 
+	image->ima_buffer = kexec_buffer;
+
 	pr_debug("kexec measurement buffer for the loaded kernel at 0x%lx.\n",
 		 kbuf.mem);
 }



[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