diff mbox series

[v13,1/6] ima: Move arch_ima_add_kexec_buffer() to ima

Message ID 20201219175713.18888-2-nramas@linux.microsoft.com
State Superseded
Headers show
Series Carry forward IMA measurement log on kexec on ARM64 | expand

Commit Message

nramas Dec. 19, 2020, 5:57 p.m. UTC
arch_ima_add_kexec_buffer() defined in "arch/powerpc/kexec/ima.c"
sets up the address and size of the IMA measurement list in
the architecture specific fields in kimage struct. This function does not
have architecture specific code, but is currently limited to powerpc.

Move arch_ima_add_kexec_buffer() to ima.

Co-developed-by: Prakhar Srivastava <prsriva@linux.microsoft.com>
Signed-off-by: Prakhar Srivastava <prsriva@linux.microsoft.com>
Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
---
 arch/powerpc/include/asm/ima.h     |  3 ---
 arch/powerpc/kexec/ima.c           | 17 -----------------
 security/integrity/ima/ima_kexec.c | 22 ++++++++++++++++++++++
 3 files changed, 22 insertions(+), 20 deletions(-)

Comments

Mimi Zohar Dec. 22, 2020, 2:22 p.m. UTC | #1
On Sat, 2020-12-19 at 09:57 -0800, Lakshmi Ramasubramanian wrote:
> arch_ima_add_kexec_buffer() defined in "arch/powerpc/kexec/ima.c"

> sets up the address and size of the IMA measurement list in

> the architecture specific fields in kimage struct. This function does not

> have architecture specific code, but is currently limited to powerpc.

> 

> Move arch_ima_add_kexec_buffer() to ima.

> 

> Co-developed-by: Prakhar Srivastava <prsriva@linux.microsoft.com>

> Signed-off-by: Prakhar Srivastava <prsriva@linux.microsoft.com>

> Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>


Acked-by: Mimi Zohar <zohar@linux.ibm.com>
Thiago Jung Bauermann Dec. 22, 2020, 10:53 p.m. UTC | #2
Lakshmi Ramasubramanian <nramas@linux.microsoft.com> writes:

> arch_ima_add_kexec_buffer() defined in "arch/powerpc/kexec/ima.c"

> sets up the address and size of the IMA measurement list in

> the architecture specific fields in kimage struct. This function does not

> have architecture specific code, but is currently limited to powerpc.

>

> Move arch_ima_add_kexec_buffer() to ima.

>

> Co-developed-by: Prakhar Srivastava <prsriva@linux.microsoft.com>

> Signed-off-by: Prakhar Srivastava <prsriva@linux.microsoft.com>

> Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>

> ---

>  arch/powerpc/include/asm/ima.h     |  3 ---

>  arch/powerpc/kexec/ima.c           | 17 -----------------

>  security/integrity/ima/ima_kexec.c | 22 ++++++++++++++++++++++

>  3 files changed, 22 insertions(+), 20 deletions(-)


Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>


Just one nit below.

Also, I just noticed that this patch series hasn't been cc'd to the linuxppc-dev
mailing list. You should do that, since it affects powerpc code. The
powerpc maintainers are being copied so at least they've been made aware
of it, but that isn't enough.

> diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c

> index 121de3e04af2..38bcd7543e27 100644

> --- a/security/integrity/ima/ima_kexec.c

> +++ b/security/integrity/ima/ima_kexec.c

> @@ -10,6 +10,7 @@

>  #include <linux/seq_file.h>

>  #include <linux/vmalloc.h>

>  #include <linux/kexec.h>

> +#include <linux/ima.h>

>  #include "ima.h"

>  

>  #ifdef CONFIG_IMA_KEXEC


There's no need to add this include.

-- 
Thiago Jung Bauermann
IBM Linux Technology Center
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/ima.h b/arch/powerpc/include/asm/ima.h
index ead488cf3981..51f64fd06c19 100644
--- a/arch/powerpc/include/asm/ima.h
+++ b/arch/powerpc/include/asm/ima.h
@@ -14,9 +14,6 @@  static inline void remove_ima_buffer(void *fdt, int chosen_node) {}
 #endif
 
 #ifdef CONFIG_IMA_KEXEC
-int arch_ima_add_kexec_buffer(struct kimage *image, unsigned long load_addr,
-			      size_t size);
-
 int setup_ima_buffer(const struct kimage *image, void *fdt, int chosen_node);
 #else
 static inline int setup_ima_buffer(const struct kimage *image, void *fdt,
diff --git a/arch/powerpc/kexec/ima.c b/arch/powerpc/kexec/ima.c
index 720e50e490b6..7378d59c0c1e 100644
--- a/arch/powerpc/kexec/ima.c
+++ b/arch/powerpc/kexec/ima.c
@@ -128,23 +128,6 @@  void remove_ima_buffer(void *fdt, int chosen_node)
 }
 
 #ifdef CONFIG_IMA_KEXEC
-/**
- * arch_ima_add_kexec_buffer - do arch-specific steps to add the IMA buffer
- *
- * Architectures should use this function to pass on the IMA buffer
- * information to the next kernel.
- *
- * Return: 0 on success, negative errno on error.
- */
-int arch_ima_add_kexec_buffer(struct kimage *image, unsigned long load_addr,
-			      size_t size)
-{
-	image->arch.ima_buffer_addr = load_addr;
-	image->arch.ima_buffer_size = size;
-
-	return 0;
-}
-
 static int write_number(void *p, u64 value, int cells)
 {
 	if (cells == 1) {
diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
index 121de3e04af2..38bcd7543e27 100644
--- a/security/integrity/ima/ima_kexec.c
+++ b/security/integrity/ima/ima_kexec.c
@@ -10,6 +10,7 @@ 
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
 #include <linux/kexec.h>
+#include <linux/ima.h>
 #include "ima.h"
 
 #ifdef CONFIG_IMA_KEXEC
@@ -71,6 +72,27 @@  static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
 	return ret;
 }
 
+/**
+ * arch_ima_add_kexec_buffer - do arch-specific steps to add the IMA buffer
+ *
+ * @image: kimage struct to set IMA buffer data
+ * @load_addr: Starting address where IMA buffer is loaded at
+ * @size: Number of bytes in the IMA buffer
+ *
+ * Architectures should use this function to pass on the IMA buffer
+ * information to the next kernel.
+ *
+ * Return: 0 on success, negative errno on error.
+ */
+static int arch_ima_add_kexec_buffer(struct kimage *image,
+				     unsigned long load_addr, size_t size)
+{
+	image->arch.ima_buffer_addr = load_addr;
+	image->arch.ima_buffer_size = size;
+
+	return 0;
+}
+
 /*
  * Called during kexec_file_load so that IMA can add a segment to the kexec
  * image for the measurement list for the next kernel.