All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
@ 2021-01-04 19:25 ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

On kexec file load Integrity Measurement Architecture (IMA) subsystem
may verify the IMA signature of the kernel and initramfs, and measure
it. The command line parameters passed to the kernel in the kexec call
may also be measured by IMA. A remote attestation service can verify
a TPM quote based on the TPM event log, the IMA measurement list, and
the TPM PCR data. This can be achieved only if the IMA measurement log
is carried over from the current kernel to the next kernel across
the kexec call.

powerpc already supports carrying forward the IMA measurement log on
kexec. This patch set adds support for carrying forward the IMA
measurement log on kexec on ARM64. 

This patch set moves the platform independent code defined for powerpc
such that it can be reused for other platforms as well. A chosen node
"linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
the address and the size of the memory reserved to carry
the IMA measurement log.

This patch set has been tested for ARM64 platform using QEMU.
I would like help from the community for testing this change on powerpc.
Thanks.

This patch set is based on
commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
"dt/kexec" branch.

Changelog:

v14
  - Select CONFIG_HAVE_IMA_KEXEC for CONFIG_KEXEC_FILE, for powerpc
    and arm64, if CONFIG_IMA is enabled.
  - Use IS_ENABLED() macro instead of "#ifdef" in remove_ima_buffer(),
    ima_get_kexec_buffer(), and ima_free_kexec_buffer().
  - Call of_kexec_setup_new_fdt() from setup_new_fdt_ppc64() and
    remove setup_new_fdt() in "arch/powerpc/kexec/file_load.c".

v13
  - Moved the arch independent functions to drivers/of/kexec.c
    and then refactored the code.
  - Moved arch_ima_add_kexec_buffer() to
    security/integrity/ima/ima_kexec.c

v12
  - Use fdt_appendprop_addrrange() in setup_ima_buffer()
    to setup the IMA measurement list property in
    the device tree.
  - Moved architecture independent functions from
    "arch/powerpc/kexec/ima.c" to "drivers/of/kexec."
  - Deleted "arch/powerpc/kexec/ima.c" and
    "arch/powerpc/include/asm/ima.h".

v11
  - Rebased the changes on the kexec code refactoring done by
    Rob Herring in his "dt/kexec" branch
  - Removed "extern" keyword in function declarations
  - Removed unnecessary header files included in C files
  - Updated patch descriptions per Thiago's comments

v10
  - Moved delete_fdt_mem_rsv(), remove_ima_buffer(),
    get_ima_kexec_buffer, and get_root_addr_size_cells()
    to drivers/of/kexec.c
  - Moved arch_ima_add_kexec_buffer() to
    security/integrity/ima/ima_kexec.c
  - Conditionally define IMA buffer fields in struct kimage_arch

v9
  - Moved delete_fdt_mem_rsv() to drivers/of/kexec_fdt.c
  - Defined a new function get_ima_kexec_buffer() in
    drivers/of/ima_kexec.c to replace do_get_kexec_buffer()
  - Changed remove_ima_kexec_buffer() to the original function name
    remove_ima_buffer()
  - Moved remove_ima_buffer() to drivers/of/ima_kexec.c
  - Moved ima_get_kexec_buffer() and ima_free_kexec_buffer()
    to security/integrity/ima/ima_kexec.c

v8:
  - Moved remove_ima_kexec_buffer(), do_get_kexec_buffer(), and
    delete_fdt_mem_rsv() to drivers/of/fdt.c
  - Moved ima_dump_measurement_list() and ima_add_kexec_buffer()
    back to security/integrity/ima/ima_kexec.c

v7:
  - Renamed remove_ima_buffer() to remove_ima_kexec_buffer() and moved
    this function definition to kernel.
  - Moved delete_fdt_mem_rsv() definition to kernel
  - Moved ima_dump_measurement_list() and ima_add_kexec_buffer() to
    a new file namely ima_kexec_fdt.c in IMA

v6:
  - Remove any existing FDT_PROP_IMA_KEXEC_BUFFER property in the device
    tree and also its corresponding memory reservation in the currently
    running kernel.
  - Moved the function remove_ima_buffer() defined for powerpc to IMA
    and renamed the function to ima_remove_kexec_buffer(). Also, moved
    delete_fdt_mem_rsv() from powerpc to IMA.

v5:
  - Merged get_addr_size_cells() and do_get_kexec_buffer() into a single
    function when moving the arch independent code from powerpc to IMA
  - Reverted the change to use FDT functions in powerpc code and added
    back the original code in get_addr_size_cells() and
    do_get_kexec_buffer() for powerpc.
  - Added fdt_add_mem_rsv() for ARM64 to reserve the memory for
    the IMA log buffer during kexec.
  - Fixed the warning reported by kernel test bot for ARM64
    arch_ima_add_kexec_buffer() - moved this function to a new file
    namely arch/arm64/kernel/ima_kexec.c

v4:
  - Submitting the patch series on behalf of the original author
    Prakhar Srivastava <prsriva@linux.microsoft.com>
  - Moved FDT_PROP_IMA_KEXEC_BUFFER ("linux,ima-kexec-buffer") to
    libfdt.h so that it can be shared by multiple platforms.

v3:
Breakup patches further into separate patches.
  - Refactoring non architecture specific code out of powerpc
  - Update powerpc related code to use fdt functions
  - Update IMA buffer read related code to use of functions
  - Add support to store the memory information of the IMA
    measurement logs to be carried forward.
  - Update the property strings to align with documented nodes
    https://github.com/devicetree-org/dt-schema/pull/46

v2:
  Break patches into separate patches.
  - Powerpc related Refactoring
  - Updating the docuemntation for chosen node
  - Updating arm64 to support IMA buffer pass

v1:
  Refactoring carrying over IMA measuremnet logs over Kexec. This patch
    moves the non-architecture specific code out of powerpc and adds to
    security/ima.(Suggested by Thiago)
  Add Documentation regarding the ima-kexec-buffer node in the chosen
    node documentation

v0:
  Add a layer of abstraction to use the memory reserved by device tree
    for ima buffer pass.
  Add support for ima buffer pass using reserved memory for arm64 kexec.
    Update the arch sepcific code path in kexec file load to store the
    ima buffer in the reserved memory. The same reserved memory is read
    on kexec or cold boot.

Lakshmi Ramasubramanian (6):
  ima: Move arch_ima_add_kexec_buffer() to ima
  powerpc: Move arch independent ima kexec functions to
    drivers/of/kexec.c
  kexec: Use fdt_appendprop_addrrange() to add ima buffer to FDT
  powerpc: Delete unused functions
  arm64: Free DTB buffer if fdt_open_into() fails
  arm64: Add IMA log information in kimage used for kexec

 arch/arm64/Kconfig                     |   1 +
 arch/arm64/include/asm/kexec.h         |   5 +
 arch/arm64/kernel/machine_kexec_file.c |   4 +-
 arch/powerpc/Kconfig                   |   2 +-
 arch/powerpc/include/asm/ima.h         |  30 ----
 arch/powerpc/include/asm/kexec.h       |   4 -
 arch/powerpc/kexec/Makefile            |   7 -
 arch/powerpc/kexec/file_load.c         |  67 --------
 arch/powerpc/kexec/file_load_64.c      |   4 +-
 arch/powerpc/kexec/ima.c               | 219 -------------------------
 drivers/of/kexec.c                     | 193 ++++++++++++++++++++++
 include/linux/of.h                     |   2 +
 security/integrity/ima/ima.h           |   4 -
 security/integrity/ima/ima_kexec.c     |  22 +++
 14 files changed, 230 insertions(+), 334 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/ima.h
 delete mode 100644 arch/powerpc/kexec/ima.c

-- 
2.29.2


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
@ 2021-01-04 19:25 ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

On kexec file load Integrity Measurement Architecture (IMA) subsystem
may verify the IMA signature of the kernel and initramfs, and measure
it. The command line parameters passed to the kernel in the kexec call
may also be measured by IMA. A remote attestation service can verify
a TPM quote based on the TPM event log, the IMA measurement list, and
the TPM PCR data. This can be achieved only if the IMA measurement log
is carried over from the current kernel to the next kernel across
the kexec call.

powerpc already supports carrying forward the IMA measurement log on
kexec. This patch set adds support for carrying forward the IMA
measurement log on kexec on ARM64. 

This patch set moves the platform independent code defined for powerpc
such that it can be reused for other platforms as well. A chosen node
"linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
the address and the size of the memory reserved to carry
the IMA measurement log.

This patch set has been tested for ARM64 platform using QEMU.
I would like help from the community for testing this change on powerpc.
Thanks.

This patch set is based on
commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
"dt/kexec" branch.

Changelog:

v14
  - Select CONFIG_HAVE_IMA_KEXEC for CONFIG_KEXEC_FILE, for powerpc
    and arm64, if CONFIG_IMA is enabled.
  - Use IS_ENABLED() macro instead of "#ifdef" in remove_ima_buffer(),
    ima_get_kexec_buffer(), and ima_free_kexec_buffer().
  - Call of_kexec_setup_new_fdt() from setup_new_fdt_ppc64() and
    remove setup_new_fdt() in "arch/powerpc/kexec/file_load.c".

v13
  - Moved the arch independent functions to drivers/of/kexec.c
    and then refactored the code.
  - Moved arch_ima_add_kexec_buffer() to
    security/integrity/ima/ima_kexec.c

v12
  - Use fdt_appendprop_addrrange() in setup_ima_buffer()
    to setup the IMA measurement list property in
    the device tree.
  - Moved architecture independent functions from
    "arch/powerpc/kexec/ima.c" to "drivers/of/kexec."
  - Deleted "arch/powerpc/kexec/ima.c" and
    "arch/powerpc/include/asm/ima.h".

v11
  - Rebased the changes on the kexec code refactoring done by
    Rob Herring in his "dt/kexec" branch
  - Removed "extern" keyword in function declarations
  - Removed unnecessary header files included in C files
  - Updated patch descriptions per Thiago's comments

v10
  - Moved delete_fdt_mem_rsv(), remove_ima_buffer(),
    get_ima_kexec_buffer, and get_root_addr_size_cells()
    to drivers/of/kexec.c
  - Moved arch_ima_add_kexec_buffer() to
    security/integrity/ima/ima_kexec.c
  - Conditionally define IMA buffer fields in struct kimage_arch

v9
  - Moved delete_fdt_mem_rsv() to drivers/of/kexec_fdt.c
  - Defined a new function get_ima_kexec_buffer() in
    drivers/of/ima_kexec.c to replace do_get_kexec_buffer()
  - Changed remove_ima_kexec_buffer() to the original function name
    remove_ima_buffer()
  - Moved remove_ima_buffer() to drivers/of/ima_kexec.c
  - Moved ima_get_kexec_buffer() and ima_free_kexec_buffer()
    to security/integrity/ima/ima_kexec.c

v8:
  - Moved remove_ima_kexec_buffer(), do_get_kexec_buffer(), and
    delete_fdt_mem_rsv() to drivers/of/fdt.c
  - Moved ima_dump_measurement_list() and ima_add_kexec_buffer()
    back to security/integrity/ima/ima_kexec.c

v7:
  - Renamed remove_ima_buffer() to remove_ima_kexec_buffer() and moved
    this function definition to kernel.
  - Moved delete_fdt_mem_rsv() definition to kernel
  - Moved ima_dump_measurement_list() and ima_add_kexec_buffer() to
    a new file namely ima_kexec_fdt.c in IMA

v6:
  - Remove any existing FDT_PROP_IMA_KEXEC_BUFFER property in the device
    tree and also its corresponding memory reservation in the currently
    running kernel.
  - Moved the function remove_ima_buffer() defined for powerpc to IMA
    and renamed the function to ima_remove_kexec_buffer(). Also, moved
    delete_fdt_mem_rsv() from powerpc to IMA.

v5:
  - Merged get_addr_size_cells() and do_get_kexec_buffer() into a single
    function when moving the arch independent code from powerpc to IMA
  - Reverted the change to use FDT functions in powerpc code and added
    back the original code in get_addr_size_cells() and
    do_get_kexec_buffer() for powerpc.
  - Added fdt_add_mem_rsv() for ARM64 to reserve the memory for
    the IMA log buffer during kexec.
  - Fixed the warning reported by kernel test bot for ARM64
    arch_ima_add_kexec_buffer() - moved this function to a new file
    namely arch/arm64/kernel/ima_kexec.c

v4:
  - Submitting the patch series on behalf of the original author
    Prakhar Srivastava <prsriva@linux.microsoft.com>
  - Moved FDT_PROP_IMA_KEXEC_BUFFER ("linux,ima-kexec-buffer") to
    libfdt.h so that it can be shared by multiple platforms.

v3:
Breakup patches further into separate patches.
  - Refactoring non architecture specific code out of powerpc
  - Update powerpc related code to use fdt functions
  - Update IMA buffer read related code to use of functions
  - Add support to store the memory information of the IMA
    measurement logs to be carried forward.
  - Update the property strings to align with documented nodes
    https://github.com/devicetree-org/dt-schema/pull/46

v2:
  Break patches into separate patches.
  - Powerpc related Refactoring
  - Updating the docuemntation for chosen node
  - Updating arm64 to support IMA buffer pass

v1:
  Refactoring carrying over IMA measuremnet logs over Kexec. This patch
    moves the non-architecture specific code out of powerpc and adds to
    security/ima.(Suggested by Thiago)
  Add Documentation regarding the ima-kexec-buffer node in the chosen
    node documentation

v0:
  Add a layer of abstraction to use the memory reserved by device tree
    for ima buffer pass.
  Add support for ima buffer pass using reserved memory for arm64 kexec.
    Update the arch sepcific code path in kexec file load to store the
    ima buffer in the reserved memory. The same reserved memory is read
    on kexec or cold boot.

Lakshmi Ramasubramanian (6):
  ima: Move arch_ima_add_kexec_buffer() to ima
  powerpc: Move arch independent ima kexec functions to
    drivers/of/kexec.c
  kexec: Use fdt_appendprop_addrrange() to add ima buffer to FDT
  powerpc: Delete unused functions
  arm64: Free DTB buffer if fdt_open_into() fails
  arm64: Add IMA log information in kimage used for kexec

 arch/arm64/Kconfig                     |   1 +
 arch/arm64/include/asm/kexec.h         |   5 +
 arch/arm64/kernel/machine_kexec_file.c |   4 +-
 arch/powerpc/Kconfig                   |   2 +-
 arch/powerpc/include/asm/ima.h         |  30 ----
 arch/powerpc/include/asm/kexec.h       |   4 -
 arch/powerpc/kexec/Makefile            |   7 -
 arch/powerpc/kexec/file_load.c         |  67 --------
 arch/powerpc/kexec/file_load_64.c      |   4 +-
 arch/powerpc/kexec/ima.c               | 219 -------------------------
 drivers/of/kexec.c                     | 193 ++++++++++++++++++++++
 include/linux/of.h                     |   2 +
 security/integrity/ima/ima.h           |   4 -
 security/integrity/ima/ima_kexec.c     |  22 +++
 14 files changed, 230 insertions(+), 334 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/ima.h
 delete mode 100644 arch/powerpc/kexec/ima.c

-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH v14 1/6] ima: Move arch_ima_add_kexec_buffer() to ima
  2021-01-04 19:25 ` Lakshmi Ramasubramanian
@ 2021-01-04 19:25   ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

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>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
---
 arch/powerpc/include/asm/ima.h     |  3 ---
 arch/powerpc/kexec/ima.c           | 17 -----------------
 security/integrity/ima/ima_kexec.c | 21 +++++++++++++++++++++
 3 files changed, 21 insertions(+), 20 deletions(-)

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..95513c97ce8f 100644
--- a/security/integrity/ima/ima_kexec.c
+++ b/security/integrity/ima/ima_kexec.c
@@ -71,6 +71,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.
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 1/6] ima: Move arch_ima_add_kexec_buffer() to ima
@ 2021-01-04 19:25   ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

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>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
---
 arch/powerpc/include/asm/ima.h     |  3 ---
 arch/powerpc/kexec/ima.c           | 17 -----------------
 security/integrity/ima/ima_kexec.c | 21 +++++++++++++++++++++
 3 files changed, 21 insertions(+), 20 deletions(-)

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..95513c97ce8f 100644
--- a/security/integrity/ima/ima_kexec.c
+++ b/security/integrity/ima/ima_kexec.c
@@ -71,6 +71,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.
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c
  2021-01-04 19:25 ` Lakshmi Ramasubramanian
@ 2021-01-04 19:25   ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

The functions defined in "arch/powerpc/kexec/ima.c" handle setting up
and freeing the resources required to carry over the IMA measurement
list from the current kernel to the next kernel across kexec system call.
These functions do not have architecture specific code, but are
currently limited to powerpc.

Move setup_ima_buffer() call into of_kexec_setup_new_fdt() defined in
"drivers/of/kexec.c".

Move the remaining architecture independent functions from
"arch/powerpc/kexec/ima.c" to "drivers/of/kexec.c".
Delete "arch/powerpc/kexec/ima.c" and "arch/powerpc/include/asm/ima.h".
Remove references to the deleted files in powerpc and in 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/Kconfig               |   2 +-
 arch/powerpc/include/asm/ima.h     |  27 ----
 arch/powerpc/kexec/Makefile        |   7 -
 arch/powerpc/kexec/file_load.c     |   7 -
 arch/powerpc/kexec/ima.c           | 202 ------------------------
 drivers/of/kexec.c                 | 240 +++++++++++++++++++++++++++++
 include/linux/of.h                 |   2 +
 security/integrity/ima/ima.h       |   4 -
 security/integrity/ima/ima_kexec.c |   1 +
 9 files changed, 244 insertions(+), 248 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/ima.h
 delete mode 100644 arch/powerpc/kexec/ima.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5181872f9452..7fce3034e44a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -549,7 +549,7 @@ config KEXEC
 config KEXEC_FILE
 	bool "kexec file based system call"
 	select KEXEC_CORE
-	select HAVE_IMA_KEXEC
+	select HAVE_IMA_KEXEC if IMA
 	select BUILD_BIN2C
 	select KEXEC_ELF
 	depends on PPC64
diff --git a/arch/powerpc/include/asm/ima.h b/arch/powerpc/include/asm/ima.h
deleted file mode 100644
index 51f64fd06c19..000000000000
--- a/arch/powerpc/include/asm/ima.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_POWERPC_IMA_H
-#define _ASM_POWERPC_IMA_H
-
-struct kimage;
-
-int ima_get_kexec_buffer(void **addr, size_t *size);
-int ima_free_kexec_buffer(void);
-
-#ifdef CONFIG_IMA
-void remove_ima_buffer(void *fdt, int chosen_node);
-#else
-static inline void remove_ima_buffer(void *fdt, int chosen_node) {}
-#endif
-
-#ifdef CONFIG_IMA_KEXEC
-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,
-				   int chosen_node)
-{
-	remove_ima_buffer(fdt, chosen_node);
-	return 0;
-}
-#endif /* CONFIG_IMA_KEXEC */
-
-#endif /* _ASM_POWERPC_IMA_H */
diff --git a/arch/powerpc/kexec/Makefile b/arch/powerpc/kexec/Makefile
index 4aff6846c772..b6c52608cb49 100644
--- a/arch/powerpc/kexec/Makefile
+++ b/arch/powerpc/kexec/Makefile
@@ -9,13 +9,6 @@ obj-$(CONFIG_PPC32)		+= relocate_32.o
 
 obj-$(CONFIG_KEXEC_FILE)	+= file_load.o ranges.o file_load_$(BITS).o elf_$(BITS).o
 
-ifdef CONFIG_HAVE_IMA_KEXEC
-ifdef CONFIG_IMA
-obj-y				+= ima.o
-endif
-endif
-
-
 # Disable GCOV, KCOV & sanitizers in odd or sensitive code
 GCOV_PROFILE_core_$(BITS).o := n
 KCOV_INSTRUMENT_core_$(BITS).o := n
diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c
index 956bcb2d1ec2..9f3ec0b239ef 100644
--- a/arch/powerpc/kexec/file_load.c
+++ b/arch/powerpc/kexec/file_load.c
@@ -20,7 +20,6 @@
 #include <linux/of_fdt.h>
 #include <linux/libfdt.h>
 #include <asm/setup.h>
-#include <asm/ima.h>
 
 #define SLAVE_CODE_SIZE		256	/* First 0x100 bytes */
 
@@ -163,12 +162,6 @@ int setup_new_fdt(const struct kimage *image, void *fdt,
 	if (ret)
 		goto err;
 
-	ret = setup_ima_buffer(image, fdt, fdt_path_offset(fdt, "/chosen"));
-	if (ret) {
-		pr_err("Error setting up the new device tree.\n");
-		return ret;
-	}
-
 	return 0;
 
 err:
diff --git a/arch/powerpc/kexec/ima.c b/arch/powerpc/kexec/ima.c
deleted file mode 100644
index 7378d59c0c1e..000000000000
--- a/arch/powerpc/kexec/ima.c
+++ /dev/null
@@ -1,202 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (C) 2016 IBM Corporation
- *
- * Authors:
- * Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
- */
-
-#include <linux/slab.h>
-#include <linux/kexec.h>
-#include <linux/of.h>
-#include <linux/memblock.h>
-#include <linux/libfdt.h>
-
-static int get_addr_size_cells(int *addr_cells, int *size_cells)
-{
-	struct device_node *root;
-
-	root = of_find_node_by_path("/");
-	if (!root)
-		return -EINVAL;
-
-	*addr_cells = of_n_addr_cells(root);
-	*size_cells = of_n_size_cells(root);
-
-	of_node_put(root);
-
-	return 0;
-}
-
-static int do_get_kexec_buffer(const void *prop, int len, unsigned long *addr,
-			       size_t *size)
-{
-	int ret, addr_cells, size_cells;
-
-	ret = get_addr_size_cells(&addr_cells, &size_cells);
-	if (ret)
-		return ret;
-
-	if (len < 4 * (addr_cells + size_cells))
-		return -ENOENT;
-
-	*addr = of_read_number(prop, addr_cells);
-	*size = of_read_number(prop + 4 * addr_cells, size_cells);
-
-	return 0;
-}
-
-/**
- * ima_get_kexec_buffer - get IMA buffer from the previous kernel
- * @addr:	On successful return, set to point to the buffer contents.
- * @size:	On successful return, set to the buffer size.
- *
- * Return: 0 on success, negative errno on error.
- */
-int ima_get_kexec_buffer(void **addr, size_t *size)
-{
-	int ret, len;
-	unsigned long tmp_addr;
-	size_t tmp_size;
-	const void *prop;
-
-	prop = of_get_property(of_chosen, "linux,ima-kexec-buffer", &len);
-	if (!prop)
-		return -ENOENT;
-
-	ret = do_get_kexec_buffer(prop, len, &tmp_addr, &tmp_size);
-	if (ret)
-		return ret;
-
-	*addr = __va(tmp_addr);
-	*size = tmp_size;
-
-	return 0;
-}
-
-/**
- * ima_free_kexec_buffer - free memory used by the IMA buffer
- */
-int ima_free_kexec_buffer(void)
-{
-	int ret;
-	unsigned long addr;
-	size_t size;
-	struct property *prop;
-
-	prop = of_find_property(of_chosen, "linux,ima-kexec-buffer", NULL);
-	if (!prop)
-		return -ENOENT;
-
-	ret = do_get_kexec_buffer(prop->value, prop->length, &addr, &size);
-	if (ret)
-		return ret;
-
-	ret = of_remove_property(of_chosen, prop);
-	if (ret)
-		return ret;
-
-	return memblock_free(addr, size);
-
-}
-
-/**
- * remove_ima_buffer - remove the IMA buffer property and reservation from @fdt
- *
- * The IMA measurement buffer is of no use to a subsequent kernel, so we always
- * remove it from the device tree.
- */
-void remove_ima_buffer(void *fdt, int chosen_node)
-{
-	int ret, len;
-	unsigned long addr;
-	size_t size;
-	const void *prop;
-
-	prop = fdt_getprop(fdt, chosen_node, "linux,ima-kexec-buffer", &len);
-	if (!prop)
-		return;
-
-	ret = do_get_kexec_buffer(prop, len, &addr, &size);
-	fdt_delprop(fdt, chosen_node, "linux,ima-kexec-buffer");
-	if (ret)
-		return;
-
-	ret = delete_fdt_mem_rsv(fdt, addr, size);
-	if (!ret)
-		pr_debug("Removed old IMA buffer reservation.\n");
-}
-
-#ifdef CONFIG_IMA_KEXEC
-static int write_number(void *p, u64 value, int cells)
-{
-	if (cells == 1) {
-		u32 tmp;
-
-		if (value > U32_MAX)
-			return -EINVAL;
-
-		tmp = cpu_to_be32(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else if (cells == 2) {
-		u64 tmp;
-
-		tmp = cpu_to_be64(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else
-		return -EINVAL;
-
-	return 0;
-}
-
-/**
- * setup_ima_buffer - add IMA buffer information to the fdt
- * @image:		kexec image being loaded.
- * @fdt:		Flattened device tree for the next kernel.
- * @chosen_node:	Offset to the chosen node.
- *
- * Return: 0 on success, or negative errno on error.
- */
-int setup_ima_buffer(const struct kimage *image, void *fdt, int chosen_node)
-{
-	int ret, addr_cells, size_cells, entry_size;
-	u8 value[16];
-
-	remove_ima_buffer(fdt, chosen_node);
-	if (!image->arch.ima_buffer_size)
-		return 0;
-
-	ret = get_addr_size_cells(&addr_cells, &size_cells);
-	if (ret)
-		return ret;
-
-	entry_size = 4 * (addr_cells + size_cells);
-
-	if (entry_size > sizeof(value))
-		return -EINVAL;
-
-	ret = write_number(value, image->arch.ima_buffer_addr, addr_cells);
-	if (ret)
-		return ret;
-
-	ret = write_number(value + 4 * addr_cells, image->arch.ima_buffer_size,
-			   size_cells);
-	if (ret)
-		return ret;
-
-	ret = fdt_setprop(fdt, chosen_node, "linux,ima-kexec-buffer", value,
-			  entry_size);
-	if (ret < 0)
-		return -EINVAL;
-
-	ret = fdt_add_mem_rsv(fdt, image->arch.ima_buffer_addr,
-			      image->arch.ima_buffer_size);
-	if (ret)
-		return -EINVAL;
-
-	pr_debug("IMA buffer at 0x%llx, size = 0x%zx\n",
-		 image->arch.ima_buffer_addr, image->arch.ima_buffer_size);
-
-	return 0;
-}
-#endif /* CONFIG_IMA_KEXEC */
diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c
index 66787be081fe..9b1650b5c036 100644
--- a/drivers/of/kexec.c
+++ b/drivers/of/kexec.c
@@ -11,6 +11,7 @@
 
 #include <linux/kernel.h>
 #include <linux/kexec.h>
+#include <linux/memblock.h>
 #include <linux/libfdt.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
@@ -59,6 +60,240 @@ static int fdt_find_and_del_mem_rsv(void *fdt, unsigned long start, unsigned lon
 	return -ENOENT;
 }
 
+/**
+ * get_addr_size_cells - Get address and size of root node
+ *
+ * @addr_cells: Return address of the root node
+ * @size_cells: Return size of the root node
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int get_addr_size_cells(int *addr_cells, int *size_cells)
+{
+	struct device_node *root;
+
+	root = of_find_node_by_path("/");
+	if (!root)
+		return -EINVAL;
+
+	*addr_cells = of_n_addr_cells(root);
+	*size_cells = of_n_size_cells(root);
+
+	of_node_put(root);
+
+	return 0;
+}
+
+/**
+ * do_get_kexec_buffer - Get address and size of device tree property
+ *
+ * @prop: Device tree property
+ * @len: Size of @prop
+ * @addr: Return address of the node
+ * @size: Return size of the node
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int do_get_kexec_buffer(const void *prop, int len, unsigned long *addr,
+			       size_t *size)
+{
+	int ret, addr_cells, size_cells;
+
+	ret = get_addr_size_cells(&addr_cells, &size_cells);
+	if (ret)
+		return ret;
+
+	if (len < 4 * (addr_cells + size_cells))
+		return -ENOENT;
+
+	*addr = of_read_number(prop, addr_cells);
+	*size = of_read_number(prop + 4 * addr_cells, size_cells);
+
+	return 0;
+}
+
+/**
+ * remove_ima_buffer - remove the IMA buffer property and reservation from @fdt
+ *
+ * @fdt: Flattened Device Tree to update
+ * @chosen_node: Offset to the chosen node in the device tree
+ *
+ * The IMA measurement buffer is of no use to a subsequent kernel, so we always
+ * remove it from the device tree.
+ */
+static void remove_ima_buffer(void *fdt, int chosen_node)
+{
+	int ret, len;
+	unsigned long addr;
+	size_t size;
+	const void *prop;
+
+	if (!IS_ENABLED(CONFIG_HAVE_IMA_KEXEC))
+		return;
+
+	prop = fdt_getprop(fdt, chosen_node, "linux,ima-kexec-buffer", &len);
+	if (!prop)
+		return;
+
+	ret = do_get_kexec_buffer(prop, len, &addr, &size);
+	fdt_delprop(fdt, chosen_node, "linux,ima-kexec-buffer");
+	if (ret)
+		return;
+
+	ret = fdt_find_and_del_mem_rsv(fdt, addr, size);
+	if (!ret)
+		pr_debug("Removed old IMA buffer reservation.\n");
+}
+
+/**
+ * ima_get_kexec_buffer - get IMA buffer from the previous kernel
+ * @addr:	On successful return, set to point to the buffer contents.
+ * @size:	On successful return, set to the buffer size.
+ *
+ * Return: 0 on success, negative errno on error.
+ */
+int ima_get_kexec_buffer(void **addr, size_t *size)
+{
+	int ret, len;
+	unsigned long tmp_addr;
+	size_t tmp_size;
+	const void *prop;
+
+	if (!IS_ENABLED(CONFIG_HAVE_IMA_KEXEC))
+		return -ENOTSUPP;
+
+	prop = of_get_property(of_chosen, "linux,ima-kexec-buffer", &len);
+	if (!prop)
+		return -ENOENT;
+
+	ret = do_get_kexec_buffer(prop, len, &tmp_addr, &tmp_size);
+	if (ret)
+		return ret;
+
+	*addr = __va(tmp_addr);
+	*size = tmp_size;
+
+	return 0;
+}
+
+/**
+ * ima_free_kexec_buffer - free memory used by the IMA buffer
+ */
+int ima_free_kexec_buffer(void)
+{
+	int ret;
+	unsigned long addr;
+	size_t size;
+	struct property *prop;
+
+	if (!IS_ENABLED(CONFIG_HAVE_IMA_KEXEC))
+		return -ENOTSUPP;
+
+	prop = of_find_property(of_chosen, "linux,ima-kexec-buffer", NULL);
+	if (!prop)
+		return -ENOENT;
+
+	ret = do_get_kexec_buffer(prop->value, prop->length, &addr, &size);
+	if (ret)
+		return ret;
+
+	ret = of_remove_property(of_chosen, prop);
+	if (ret)
+		return ret;
+
+	return memblock_free(addr, size);
+
+}
+
+#ifdef CONFIG_IMA_KEXEC
+/**
+ * write_number - Convert number to big-endian format
+ *
+ * @p:		Buffer to write the number to
+ * @value:	Number to convert
+ * @cells:	Number of cells
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int write_number(void *p, u64 value, int cells)
+{
+	if (cells == 1) {
+		u32 tmp;
+
+		if (value > U32_MAX)
+			return -EINVAL;
+
+		tmp = cpu_to_be32(value);
+		memcpy(p, &tmp, sizeof(tmp));
+	} else if (cells == 2) {
+		u64 tmp;
+
+		tmp = cpu_to_be64(value);
+		memcpy(p, &tmp, sizeof(tmp));
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+/**
+ * setup_ima_buffer - add IMA buffer information to the fdt
+ * @image:		kexec image being loaded.
+ * @fdt:		Flattened device tree for the next kernel.
+ * @chosen_node:	Offset to the chosen node.
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int setup_ima_buffer(const struct kimage *image, void *fdt,
+			    int chosen_node)
+{
+	int ret, addr_cells, size_cells, entry_size;
+	u8 value[16];
+
+	if (!image->arch.ima_buffer_size)
+		return 0;
+
+	ret = get_addr_size_cells(&addr_cells, &size_cells);
+	if (ret)
+		return ret;
+
+	entry_size = 4 * (addr_cells + size_cells);
+
+	if (entry_size > sizeof(value))
+		return -EINVAL;
+
+	ret = write_number(value, image->arch.ima_buffer_addr, addr_cells);
+	if (ret)
+		return ret;
+
+	ret = write_number(value + 4 * addr_cells, image->arch.ima_buffer_size,
+			   size_cells);
+	if (ret)
+		return ret;
+
+	ret = fdt_setprop(fdt, chosen_node, "linux,ima-kexec-buffer", value,
+			  entry_size);
+	if (ret < 0)
+		return -EINVAL;
+
+	ret = fdt_add_mem_rsv(fdt, image->arch.ima_buffer_addr,
+			      image->arch.ima_buffer_size);
+	if (ret)
+		return -EINVAL;
+
+	pr_debug("IMA buffer at 0x%llx, size = 0x%zx\n",
+		 image->arch.ima_buffer_addr, image->arch.ima_buffer_size);
+
+	return 0;
+}
+#else /* CONFIG_IMA_KEXEC */
+static inline int setup_ima_buffer(const struct kimage *image, void *fdt,
+				   int chosen_node)
+{
+	return 0;
+}
+#endif /* CONFIG_IMA_KEXEC */
+
 /*
  * of_kexec_setup_new_fdt - modify /chosen and memory reservation for the next kernel
  *
@@ -219,6 +454,11 @@ int of_kexec_setup_new_fdt(const struct kimage *image, void *fdt,
 	}
 
 	ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0);
+	if (ret)
+		goto out;
+
+	remove_ima_buffer(fdt, chosen_node);
+	ret = setup_ima_buffer(image, fdt, fdt_path_offset(fdt, "/chosen"));
 
 out:
 	if (ret)
diff --git a/include/linux/of.h b/include/linux/of.h
index 3375f5295875..48eb2d05c0ec 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -562,6 +562,8 @@ struct kimage;
 int of_kexec_setup_new_fdt(const struct kimage *image, void *fdt,
 			   unsigned long initrd_load_addr, unsigned long initrd_len,
 			   const char *cmdline);
+int ima_get_kexec_buffer(void **addr, size_t *size);
+int ima_free_kexec_buffer(void);
 
 #else /* CONFIG_OF */
 
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 6ebefec616e4..7c3947ad3773 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -24,10 +24,6 @@
 
 #include "../integrity.h"
 
-#ifdef CONFIG_HAVE_IMA_KEXEC
-#include <asm/ima.h>
-#endif
-
 enum ima_show_type { IMA_SHOW_BINARY, IMA_SHOW_BINARY_NO_FIELD_LEN,
 		     IMA_SHOW_BINARY_OLD_STRING_FMT, IMA_SHOW_ASCII };
 enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8, TPM_PCR10 = 10 };
diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
index 95513c97ce8f..c62bbb586d2e 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/of.h>
 #include "ima.h"
 
 #ifdef CONFIG_IMA_KEXEC
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c
@ 2021-01-04 19:25   ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

The functions defined in "arch/powerpc/kexec/ima.c" handle setting up
and freeing the resources required to carry over the IMA measurement
list from the current kernel to the next kernel across kexec system call.
These functions do not have architecture specific code, but are
currently limited to powerpc.

Move setup_ima_buffer() call into of_kexec_setup_new_fdt() defined in
"drivers/of/kexec.c".

Move the remaining architecture independent functions from
"arch/powerpc/kexec/ima.c" to "drivers/of/kexec.c".
Delete "arch/powerpc/kexec/ima.c" and "arch/powerpc/include/asm/ima.h".
Remove references to the deleted files in powerpc and in 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/Kconfig               |   2 +-
 arch/powerpc/include/asm/ima.h     |  27 ----
 arch/powerpc/kexec/Makefile        |   7 -
 arch/powerpc/kexec/file_load.c     |   7 -
 arch/powerpc/kexec/ima.c           | 202 ------------------------
 drivers/of/kexec.c                 | 240 +++++++++++++++++++++++++++++
 include/linux/of.h                 |   2 +
 security/integrity/ima/ima.h       |   4 -
 security/integrity/ima/ima_kexec.c |   1 +
 9 files changed, 244 insertions(+), 248 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/ima.h
 delete mode 100644 arch/powerpc/kexec/ima.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5181872f9452..7fce3034e44a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -549,7 +549,7 @@ config KEXEC
 config KEXEC_FILE
 	bool "kexec file based system call"
 	select KEXEC_CORE
-	select HAVE_IMA_KEXEC
+	select HAVE_IMA_KEXEC if IMA
 	select BUILD_BIN2C
 	select KEXEC_ELF
 	depends on PPC64
diff --git a/arch/powerpc/include/asm/ima.h b/arch/powerpc/include/asm/ima.h
deleted file mode 100644
index 51f64fd06c19..000000000000
--- a/arch/powerpc/include/asm/ima.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_POWERPC_IMA_H
-#define _ASM_POWERPC_IMA_H
-
-struct kimage;
-
-int ima_get_kexec_buffer(void **addr, size_t *size);
-int ima_free_kexec_buffer(void);
-
-#ifdef CONFIG_IMA
-void remove_ima_buffer(void *fdt, int chosen_node);
-#else
-static inline void remove_ima_buffer(void *fdt, int chosen_node) {}
-#endif
-
-#ifdef CONFIG_IMA_KEXEC
-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,
-				   int chosen_node)
-{
-	remove_ima_buffer(fdt, chosen_node);
-	return 0;
-}
-#endif /* CONFIG_IMA_KEXEC */
-
-#endif /* _ASM_POWERPC_IMA_H */
diff --git a/arch/powerpc/kexec/Makefile b/arch/powerpc/kexec/Makefile
index 4aff6846c772..b6c52608cb49 100644
--- a/arch/powerpc/kexec/Makefile
+++ b/arch/powerpc/kexec/Makefile
@@ -9,13 +9,6 @@ obj-$(CONFIG_PPC32)		+= relocate_32.o
 
 obj-$(CONFIG_KEXEC_FILE)	+= file_load.o ranges.o file_load_$(BITS).o elf_$(BITS).o
 
-ifdef CONFIG_HAVE_IMA_KEXEC
-ifdef CONFIG_IMA
-obj-y				+= ima.o
-endif
-endif
-
-
 # Disable GCOV, KCOV & sanitizers in odd or sensitive code
 GCOV_PROFILE_core_$(BITS).o := n
 KCOV_INSTRUMENT_core_$(BITS).o := n
diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c
index 956bcb2d1ec2..9f3ec0b239ef 100644
--- a/arch/powerpc/kexec/file_load.c
+++ b/arch/powerpc/kexec/file_load.c
@@ -20,7 +20,6 @@
 #include <linux/of_fdt.h>
 #include <linux/libfdt.h>
 #include <asm/setup.h>
-#include <asm/ima.h>
 
 #define SLAVE_CODE_SIZE		256	/* First 0x100 bytes */
 
@@ -163,12 +162,6 @@ int setup_new_fdt(const struct kimage *image, void *fdt,
 	if (ret)
 		goto err;
 
-	ret = setup_ima_buffer(image, fdt, fdt_path_offset(fdt, "/chosen"));
-	if (ret) {
-		pr_err("Error setting up the new device tree.\n");
-		return ret;
-	}
-
 	return 0;
 
 err:
diff --git a/arch/powerpc/kexec/ima.c b/arch/powerpc/kexec/ima.c
deleted file mode 100644
index 7378d59c0c1e..000000000000
--- a/arch/powerpc/kexec/ima.c
+++ /dev/null
@@ -1,202 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright (C) 2016 IBM Corporation
- *
- * Authors:
- * Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
- */
-
-#include <linux/slab.h>
-#include <linux/kexec.h>
-#include <linux/of.h>
-#include <linux/memblock.h>
-#include <linux/libfdt.h>
-
-static int get_addr_size_cells(int *addr_cells, int *size_cells)
-{
-	struct device_node *root;
-
-	root = of_find_node_by_path("/");
-	if (!root)
-		return -EINVAL;
-
-	*addr_cells = of_n_addr_cells(root);
-	*size_cells = of_n_size_cells(root);
-
-	of_node_put(root);
-
-	return 0;
-}
-
-static int do_get_kexec_buffer(const void *prop, int len, unsigned long *addr,
-			       size_t *size)
-{
-	int ret, addr_cells, size_cells;
-
-	ret = get_addr_size_cells(&addr_cells, &size_cells);
-	if (ret)
-		return ret;
-
-	if (len < 4 * (addr_cells + size_cells))
-		return -ENOENT;
-
-	*addr = of_read_number(prop, addr_cells);
-	*size = of_read_number(prop + 4 * addr_cells, size_cells);
-
-	return 0;
-}
-
-/**
- * ima_get_kexec_buffer - get IMA buffer from the previous kernel
- * @addr:	On successful return, set to point to the buffer contents.
- * @size:	On successful return, set to the buffer size.
- *
- * Return: 0 on success, negative errno on error.
- */
-int ima_get_kexec_buffer(void **addr, size_t *size)
-{
-	int ret, len;
-	unsigned long tmp_addr;
-	size_t tmp_size;
-	const void *prop;
-
-	prop = of_get_property(of_chosen, "linux,ima-kexec-buffer", &len);
-	if (!prop)
-		return -ENOENT;
-
-	ret = do_get_kexec_buffer(prop, len, &tmp_addr, &tmp_size);
-	if (ret)
-		return ret;
-
-	*addr = __va(tmp_addr);
-	*size = tmp_size;
-
-	return 0;
-}
-
-/**
- * ima_free_kexec_buffer - free memory used by the IMA buffer
- */
-int ima_free_kexec_buffer(void)
-{
-	int ret;
-	unsigned long addr;
-	size_t size;
-	struct property *prop;
-
-	prop = of_find_property(of_chosen, "linux,ima-kexec-buffer", NULL);
-	if (!prop)
-		return -ENOENT;
-
-	ret = do_get_kexec_buffer(prop->value, prop->length, &addr, &size);
-	if (ret)
-		return ret;
-
-	ret = of_remove_property(of_chosen, prop);
-	if (ret)
-		return ret;
-
-	return memblock_free(addr, size);
-
-}
-
-/**
- * remove_ima_buffer - remove the IMA buffer property and reservation from @fdt
- *
- * The IMA measurement buffer is of no use to a subsequent kernel, so we always
- * remove it from the device tree.
- */
-void remove_ima_buffer(void *fdt, int chosen_node)
-{
-	int ret, len;
-	unsigned long addr;
-	size_t size;
-	const void *prop;
-
-	prop = fdt_getprop(fdt, chosen_node, "linux,ima-kexec-buffer", &len);
-	if (!prop)
-		return;
-
-	ret = do_get_kexec_buffer(prop, len, &addr, &size);
-	fdt_delprop(fdt, chosen_node, "linux,ima-kexec-buffer");
-	if (ret)
-		return;
-
-	ret = delete_fdt_mem_rsv(fdt, addr, size);
-	if (!ret)
-		pr_debug("Removed old IMA buffer reservation.\n");
-}
-
-#ifdef CONFIG_IMA_KEXEC
-static int write_number(void *p, u64 value, int cells)
-{
-	if (cells == 1) {
-		u32 tmp;
-
-		if (value > U32_MAX)
-			return -EINVAL;
-
-		tmp = cpu_to_be32(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else if (cells == 2) {
-		u64 tmp;
-
-		tmp = cpu_to_be64(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else
-		return -EINVAL;
-
-	return 0;
-}
-
-/**
- * setup_ima_buffer - add IMA buffer information to the fdt
- * @image:		kexec image being loaded.
- * @fdt:		Flattened device tree for the next kernel.
- * @chosen_node:	Offset to the chosen node.
- *
- * Return: 0 on success, or negative errno on error.
- */
-int setup_ima_buffer(const struct kimage *image, void *fdt, int chosen_node)
-{
-	int ret, addr_cells, size_cells, entry_size;
-	u8 value[16];
-
-	remove_ima_buffer(fdt, chosen_node);
-	if (!image->arch.ima_buffer_size)
-		return 0;
-
-	ret = get_addr_size_cells(&addr_cells, &size_cells);
-	if (ret)
-		return ret;
-
-	entry_size = 4 * (addr_cells + size_cells);
-
-	if (entry_size > sizeof(value))
-		return -EINVAL;
-
-	ret = write_number(value, image->arch.ima_buffer_addr, addr_cells);
-	if (ret)
-		return ret;
-
-	ret = write_number(value + 4 * addr_cells, image->arch.ima_buffer_size,
-			   size_cells);
-	if (ret)
-		return ret;
-
-	ret = fdt_setprop(fdt, chosen_node, "linux,ima-kexec-buffer", value,
-			  entry_size);
-	if (ret < 0)
-		return -EINVAL;
-
-	ret = fdt_add_mem_rsv(fdt, image->arch.ima_buffer_addr,
-			      image->arch.ima_buffer_size);
-	if (ret)
-		return -EINVAL;
-
-	pr_debug("IMA buffer at 0x%llx, size = 0x%zx\n",
-		 image->arch.ima_buffer_addr, image->arch.ima_buffer_size);
-
-	return 0;
-}
-#endif /* CONFIG_IMA_KEXEC */
diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c
index 66787be081fe..9b1650b5c036 100644
--- a/drivers/of/kexec.c
+++ b/drivers/of/kexec.c
@@ -11,6 +11,7 @@
 
 #include <linux/kernel.h>
 #include <linux/kexec.h>
+#include <linux/memblock.h>
 #include <linux/libfdt.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
@@ -59,6 +60,240 @@ static int fdt_find_and_del_mem_rsv(void *fdt, unsigned long start, unsigned lon
 	return -ENOENT;
 }
 
+/**
+ * get_addr_size_cells - Get address and size of root node
+ *
+ * @addr_cells: Return address of the root node
+ * @size_cells: Return size of the root node
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int get_addr_size_cells(int *addr_cells, int *size_cells)
+{
+	struct device_node *root;
+
+	root = of_find_node_by_path("/");
+	if (!root)
+		return -EINVAL;
+
+	*addr_cells = of_n_addr_cells(root);
+	*size_cells = of_n_size_cells(root);
+
+	of_node_put(root);
+
+	return 0;
+}
+
+/**
+ * do_get_kexec_buffer - Get address and size of device tree property
+ *
+ * @prop: Device tree property
+ * @len: Size of @prop
+ * @addr: Return address of the node
+ * @size: Return size of the node
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int do_get_kexec_buffer(const void *prop, int len, unsigned long *addr,
+			       size_t *size)
+{
+	int ret, addr_cells, size_cells;
+
+	ret = get_addr_size_cells(&addr_cells, &size_cells);
+	if (ret)
+		return ret;
+
+	if (len < 4 * (addr_cells + size_cells))
+		return -ENOENT;
+
+	*addr = of_read_number(prop, addr_cells);
+	*size = of_read_number(prop + 4 * addr_cells, size_cells);
+
+	return 0;
+}
+
+/**
+ * remove_ima_buffer - remove the IMA buffer property and reservation from @fdt
+ *
+ * @fdt: Flattened Device Tree to update
+ * @chosen_node: Offset to the chosen node in the device tree
+ *
+ * The IMA measurement buffer is of no use to a subsequent kernel, so we always
+ * remove it from the device tree.
+ */
+static void remove_ima_buffer(void *fdt, int chosen_node)
+{
+	int ret, len;
+	unsigned long addr;
+	size_t size;
+	const void *prop;
+
+	if (!IS_ENABLED(CONFIG_HAVE_IMA_KEXEC))
+		return;
+
+	prop = fdt_getprop(fdt, chosen_node, "linux,ima-kexec-buffer", &len);
+	if (!prop)
+		return;
+
+	ret = do_get_kexec_buffer(prop, len, &addr, &size);
+	fdt_delprop(fdt, chosen_node, "linux,ima-kexec-buffer");
+	if (ret)
+		return;
+
+	ret = fdt_find_and_del_mem_rsv(fdt, addr, size);
+	if (!ret)
+		pr_debug("Removed old IMA buffer reservation.\n");
+}
+
+/**
+ * ima_get_kexec_buffer - get IMA buffer from the previous kernel
+ * @addr:	On successful return, set to point to the buffer contents.
+ * @size:	On successful return, set to the buffer size.
+ *
+ * Return: 0 on success, negative errno on error.
+ */
+int ima_get_kexec_buffer(void **addr, size_t *size)
+{
+	int ret, len;
+	unsigned long tmp_addr;
+	size_t tmp_size;
+	const void *prop;
+
+	if (!IS_ENABLED(CONFIG_HAVE_IMA_KEXEC))
+		return -ENOTSUPP;
+
+	prop = of_get_property(of_chosen, "linux,ima-kexec-buffer", &len);
+	if (!prop)
+		return -ENOENT;
+
+	ret = do_get_kexec_buffer(prop, len, &tmp_addr, &tmp_size);
+	if (ret)
+		return ret;
+
+	*addr = __va(tmp_addr);
+	*size = tmp_size;
+
+	return 0;
+}
+
+/**
+ * ima_free_kexec_buffer - free memory used by the IMA buffer
+ */
+int ima_free_kexec_buffer(void)
+{
+	int ret;
+	unsigned long addr;
+	size_t size;
+	struct property *prop;
+
+	if (!IS_ENABLED(CONFIG_HAVE_IMA_KEXEC))
+		return -ENOTSUPP;
+
+	prop = of_find_property(of_chosen, "linux,ima-kexec-buffer", NULL);
+	if (!prop)
+		return -ENOENT;
+
+	ret = do_get_kexec_buffer(prop->value, prop->length, &addr, &size);
+	if (ret)
+		return ret;
+
+	ret = of_remove_property(of_chosen, prop);
+	if (ret)
+		return ret;
+
+	return memblock_free(addr, size);
+
+}
+
+#ifdef CONFIG_IMA_KEXEC
+/**
+ * write_number - Convert number to big-endian format
+ *
+ * @p:		Buffer to write the number to
+ * @value:	Number to convert
+ * @cells:	Number of cells
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int write_number(void *p, u64 value, int cells)
+{
+	if (cells == 1) {
+		u32 tmp;
+
+		if (value > U32_MAX)
+			return -EINVAL;
+
+		tmp = cpu_to_be32(value);
+		memcpy(p, &tmp, sizeof(tmp));
+	} else if (cells == 2) {
+		u64 tmp;
+
+		tmp = cpu_to_be64(value);
+		memcpy(p, &tmp, sizeof(tmp));
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
+/**
+ * setup_ima_buffer - add IMA buffer information to the fdt
+ * @image:		kexec image being loaded.
+ * @fdt:		Flattened device tree for the next kernel.
+ * @chosen_node:	Offset to the chosen node.
+ *
+ * Return: 0 on success, or negative errno on error.
+ */
+static int setup_ima_buffer(const struct kimage *image, void *fdt,
+			    int chosen_node)
+{
+	int ret, addr_cells, size_cells, entry_size;
+	u8 value[16];
+
+	if (!image->arch.ima_buffer_size)
+		return 0;
+
+	ret = get_addr_size_cells(&addr_cells, &size_cells);
+	if (ret)
+		return ret;
+
+	entry_size = 4 * (addr_cells + size_cells);
+
+	if (entry_size > sizeof(value))
+		return -EINVAL;
+
+	ret = write_number(value, image->arch.ima_buffer_addr, addr_cells);
+	if (ret)
+		return ret;
+
+	ret = write_number(value + 4 * addr_cells, image->arch.ima_buffer_size,
+			   size_cells);
+	if (ret)
+		return ret;
+
+	ret = fdt_setprop(fdt, chosen_node, "linux,ima-kexec-buffer", value,
+			  entry_size);
+	if (ret < 0)
+		return -EINVAL;
+
+	ret = fdt_add_mem_rsv(fdt, image->arch.ima_buffer_addr,
+			      image->arch.ima_buffer_size);
+	if (ret)
+		return -EINVAL;
+
+	pr_debug("IMA buffer at 0x%llx, size = 0x%zx\n",
+		 image->arch.ima_buffer_addr, image->arch.ima_buffer_size);
+
+	return 0;
+}
+#else /* CONFIG_IMA_KEXEC */
+static inline int setup_ima_buffer(const struct kimage *image, void *fdt,
+				   int chosen_node)
+{
+	return 0;
+}
+#endif /* CONFIG_IMA_KEXEC */
+
 /*
  * of_kexec_setup_new_fdt - modify /chosen and memory reservation for the next kernel
  *
@@ -219,6 +454,11 @@ int of_kexec_setup_new_fdt(const struct kimage *image, void *fdt,
 	}
 
 	ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0);
+	if (ret)
+		goto out;
+
+	remove_ima_buffer(fdt, chosen_node);
+	ret = setup_ima_buffer(image, fdt, fdt_path_offset(fdt, "/chosen"));
 
 out:
 	if (ret)
diff --git a/include/linux/of.h b/include/linux/of.h
index 3375f5295875..48eb2d05c0ec 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -562,6 +562,8 @@ struct kimage;
 int of_kexec_setup_new_fdt(const struct kimage *image, void *fdt,
 			   unsigned long initrd_load_addr, unsigned long initrd_len,
 			   const char *cmdline);
+int ima_get_kexec_buffer(void **addr, size_t *size);
+int ima_free_kexec_buffer(void);
 
 #else /* CONFIG_OF */
 
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 6ebefec616e4..7c3947ad3773 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -24,10 +24,6 @@
 
 #include "../integrity.h"
 
-#ifdef CONFIG_HAVE_IMA_KEXEC
-#include <asm/ima.h>
-#endif
-
 enum ima_show_type { IMA_SHOW_BINARY, IMA_SHOW_BINARY_NO_FIELD_LEN,
 		     IMA_SHOW_BINARY_OLD_STRING_FMT, IMA_SHOW_ASCII };
 enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8, TPM_PCR10 = 10 };
diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
index 95513c97ce8f..c62bbb586d2e 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/of.h>
 #include "ima.h"
 
 #ifdef CONFIG_IMA_KEXEC
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 3/6] kexec: Use fdt_appendprop_addrrange() to add ima buffer to FDT
  2021-01-04 19:25 ` Lakshmi Ramasubramanian
@ 2021-01-04 19:25   ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

fdt_appendprop_addrrange() function adds a property, with the given name,
to the device tree at the given node offset, and also sets the address
and size of the property. This function should be used to add
"linux,ima-kexec-buffer" property to the device tree and set the address
and size of the IMA measurement buffer, instead of using custom function.

Use fdt_appendprop_addrrange() to add  "linux,ima-kexec-buffer" property
to the device tree. This property holds the address and size of
the IMA measurement buffer that needs to be passed from the current
kernel to the next kernel across kexec system call.

Remove custom code that is used in setup_ima_buffer() to add
"linux,ima-kexec-buffer" property to the device tree.

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>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
---
 drivers/of/kexec.c | 57 ++++------------------------------------------
 1 file changed, 5 insertions(+), 52 deletions(-)

diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c
index 9b1650b5c036..d06556dba03b 100644
--- a/drivers/of/kexec.c
+++ b/drivers/of/kexec.c
@@ -206,36 +206,6 @@ int ima_free_kexec_buffer(void)
 }
 
 #ifdef CONFIG_IMA_KEXEC
-/**
- * write_number - Convert number to big-endian format
- *
- * @p:		Buffer to write the number to
- * @value:	Number to convert
- * @cells:	Number of cells
- *
- * Return: 0 on success, or negative errno on error.
- */
-static int write_number(void *p, u64 value, int cells)
-{
-	if (cells == 1) {
-		u32 tmp;
-
-		if (value > U32_MAX)
-			return -EINVAL;
-
-		tmp = cpu_to_be32(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else if (cells == 2) {
-		u64 tmp;
-
-		tmp = cpu_to_be64(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else
-		return -EINVAL;
-
-	return 0;
-}
-
 /**
  * setup_ima_buffer - add IMA buffer information to the fdt
  * @image:		kexec image being loaded.
@@ -247,32 +217,15 @@ static int write_number(void *p, u64 value, int cells)
 static int setup_ima_buffer(const struct kimage *image, void *fdt,
 			    int chosen_node)
 {
-	int ret, addr_cells, size_cells, entry_size;
-	u8 value[16];
+	int ret;
 
 	if (!image->arch.ima_buffer_size)
 		return 0;
 
-	ret = get_addr_size_cells(&addr_cells, &size_cells);
-	if (ret)
-		return ret;
-
-	entry_size = 4 * (addr_cells + size_cells);
-
-	if (entry_size > sizeof(value))
-		return -EINVAL;
-
-	ret = write_number(value, image->arch.ima_buffer_addr, addr_cells);
-	if (ret)
-		return ret;
-
-	ret = write_number(value + 4 * addr_cells, image->arch.ima_buffer_size,
-			   size_cells);
-	if (ret)
-		return ret;
-
-	ret = fdt_setprop(fdt, chosen_node, "linux,ima-kexec-buffer", value,
-			  entry_size);
+	ret = fdt_appendprop_addrrange(fdt, 0, chosen_node,
+				       "linux,ima-kexec-buffer",
+				       image->arch.ima_buffer_addr,
+				       image->arch.ima_buffer_size);
 	if (ret < 0)
 		return -EINVAL;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 3/6] kexec: Use fdt_appendprop_addrrange() to add ima buffer to FDT
@ 2021-01-04 19:25   ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:25 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

fdt_appendprop_addrrange() function adds a property, with the given name,
to the device tree at the given node offset, and also sets the address
and size of the property. This function should be used to add
"linux,ima-kexec-buffer" property to the device tree and set the address
and size of the IMA measurement buffer, instead of using custom function.

Use fdt_appendprop_addrrange() to add  "linux,ima-kexec-buffer" property
to the device tree. This property holds the address and size of
the IMA measurement buffer that needs to be passed from the current
kernel to the next kernel across kexec system call.

Remove custom code that is used in setup_ima_buffer() to add
"linux,ima-kexec-buffer" property to the device tree.

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>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
---
 drivers/of/kexec.c | 57 ++++------------------------------------------
 1 file changed, 5 insertions(+), 52 deletions(-)

diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c
index 9b1650b5c036..d06556dba03b 100644
--- a/drivers/of/kexec.c
+++ b/drivers/of/kexec.c
@@ -206,36 +206,6 @@ int ima_free_kexec_buffer(void)
 }
 
 #ifdef CONFIG_IMA_KEXEC
-/**
- * write_number - Convert number to big-endian format
- *
- * @p:		Buffer to write the number to
- * @value:	Number to convert
- * @cells:	Number of cells
- *
- * Return: 0 on success, or negative errno on error.
- */
-static int write_number(void *p, u64 value, int cells)
-{
-	if (cells == 1) {
-		u32 tmp;
-
-		if (value > U32_MAX)
-			return -EINVAL;
-
-		tmp = cpu_to_be32(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else if (cells == 2) {
-		u64 tmp;
-
-		tmp = cpu_to_be64(value);
-		memcpy(p, &tmp, sizeof(tmp));
-	} else
-		return -EINVAL;
-
-	return 0;
-}
-
 /**
  * setup_ima_buffer - add IMA buffer information to the fdt
  * @image:		kexec image being loaded.
@@ -247,32 +217,15 @@ static int write_number(void *p, u64 value, int cells)
 static int setup_ima_buffer(const struct kimage *image, void *fdt,
 			    int chosen_node)
 {
-	int ret, addr_cells, size_cells, entry_size;
-	u8 value[16];
+	int ret;
 
 	if (!image->arch.ima_buffer_size)
 		return 0;
 
-	ret = get_addr_size_cells(&addr_cells, &size_cells);
-	if (ret)
-		return ret;
-
-	entry_size = 4 * (addr_cells + size_cells);
-
-	if (entry_size > sizeof(value))
-		return -EINVAL;
-
-	ret = write_number(value, image->arch.ima_buffer_addr, addr_cells);
-	if (ret)
-		return ret;
-
-	ret = write_number(value + 4 * addr_cells, image->arch.ima_buffer_size,
-			   size_cells);
-	if (ret)
-		return ret;
-
-	ret = fdt_setprop(fdt, chosen_node, "linux,ima-kexec-buffer", value,
-			  entry_size);
+	ret = fdt_appendprop_addrrange(fdt, 0, chosen_node,
+				       "linux,ima-kexec-buffer",
+				       image->arch.ima_buffer_addr,
+				       image->arch.ima_buffer_size);
 	if (ret < 0)
 		return -EINVAL;
 
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 4/6] powerpc: Delete unused functions
  2021-01-04 19:25 ` Lakshmi Ramasubramanian
@ 2021-01-04 19:26   ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:26 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

delete_fdt_mem_rsv() defined in "arch/powerpc/kexec/file_load.c"
has been renamed to fdt_find_and_del_mem_rsv(), and moved to
"drivers/of/kexec.c".

Remove delete_fdt_mem_rsv() in "arch/powerpc/kexec/file_load.c".

Call of_kexec_setup_new_fdt() from setup_new_fdt_ppc64() and
remove setup_new_fdt() in "arch/powerpc/kexec/file_load.c".

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/kexec.h  |  4 ---
 arch/powerpc/kexec/file_load.c    | 60 -------------------------------
 arch/powerpc/kexec/file_load_64.c |  4 ++-
 3 files changed, 3 insertions(+), 65 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index dbf09d2f36d0..b8c270e08481 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -123,10 +123,6 @@ char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
 int setup_purgatory(struct kimage *image, const void *slave_code,
 		    const void *fdt, unsigned long kernel_load_addr,
 		    unsigned long fdt_load_addr);
-int setup_new_fdt(const struct kimage *image, void *fdt,
-		  unsigned long initrd_load_addr, unsigned long initrd_len,
-		  const char *cmdline);
-int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size);
 
 #ifdef CONFIG_PPC64
 struct kexec_buf;
diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c
index 9f3ec0b239ef..036c8fb48fc3 100644
--- a/arch/powerpc/kexec/file_load.c
+++ b/arch/powerpc/kexec/file_load.c
@@ -108,63 +108,3 @@ int setup_purgatory(struct kimage *image, const void *slave_code,
 
 	return 0;
 }
-
-/**
- * delete_fdt_mem_rsv - delete memory reservation with given address and size
- *
- * Return: 0 on success, or negative errno on error.
- */
-int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size)
-{
-	int i, ret, num_rsvs = fdt_num_mem_rsv(fdt);
-
-	for (i = 0; i < num_rsvs; i++) {
-		uint64_t rsv_start, rsv_size;
-
-		ret = fdt_get_mem_rsv(fdt, i, &rsv_start, &rsv_size);
-		if (ret) {
-			pr_err("Malformed device tree.\n");
-			return -EINVAL;
-		}
-
-		if (rsv_start == start && rsv_size == size) {
-			ret = fdt_del_mem_rsv(fdt, i);
-			if (ret) {
-				pr_err("Error deleting device tree reservation.\n");
-				return -EINVAL;
-			}
-
-			return 0;
-		}
-	}
-
-	return -ENOENT;
-}
-
-/*
- * setup_new_fdt - modify /chosen and memory reservation for the next kernel
- * @image:		kexec image being loaded.
- * @fdt:		Flattened device tree for the next kernel.
- * @initrd_load_addr:	Address where the next initrd will be loaded.
- * @initrd_len:		Size of the next initrd, or 0 if there will be none.
- * @cmdline:		Command line for the next kernel, or NULL if there will
- *			be none.
- *
- * Return: 0 on success, or negative errno on error.
- */
-int setup_new_fdt(const struct kimage *image, void *fdt,
-		  unsigned long initrd_load_addr, unsigned long initrd_len,
-		  const char *cmdline)
-{
-	int ret;
-
-	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
-	if (ret)
-		goto err;
-
-	return 0;
-
-err:
-	pr_err("Error setting up the new device tree.\n");
-	return -EINVAL;
-}
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index a05c19b3cc60..3cab318aa3b9 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -17,6 +17,7 @@
 #include <linux/kexec.h>
 #include <linux/of_fdt.h>
 #include <linux/libfdt.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/memblock.h>
 #include <linux/slab.h>
@@ -944,7 +945,8 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
 	struct crash_mem *umem = NULL, *rmem = NULL;
 	int i, nr_ranges, ret;
 
-	ret = setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
+	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len,
+				     cmdline);
 	if (ret)
 		goto out;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 4/6] powerpc: Delete unused functions
@ 2021-01-04 19:26   ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:26 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

delete_fdt_mem_rsv() defined in "arch/powerpc/kexec/file_load.c"
has been renamed to fdt_find_and_del_mem_rsv(), and moved to
"drivers/of/kexec.c".

Remove delete_fdt_mem_rsv() in "arch/powerpc/kexec/file_load.c".

Call of_kexec_setup_new_fdt() from setup_new_fdt_ppc64() and
remove setup_new_fdt() in "arch/powerpc/kexec/file_load.c".

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/kexec.h  |  4 ---
 arch/powerpc/kexec/file_load.c    | 60 -------------------------------
 arch/powerpc/kexec/file_load_64.c |  4 ++-
 3 files changed, 3 insertions(+), 65 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index dbf09d2f36d0..b8c270e08481 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -123,10 +123,6 @@ char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
 int setup_purgatory(struct kimage *image, const void *slave_code,
 		    const void *fdt, unsigned long kernel_load_addr,
 		    unsigned long fdt_load_addr);
-int setup_new_fdt(const struct kimage *image, void *fdt,
-		  unsigned long initrd_load_addr, unsigned long initrd_len,
-		  const char *cmdline);
-int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size);
 
 #ifdef CONFIG_PPC64
 struct kexec_buf;
diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c
index 9f3ec0b239ef..036c8fb48fc3 100644
--- a/arch/powerpc/kexec/file_load.c
+++ b/arch/powerpc/kexec/file_load.c
@@ -108,63 +108,3 @@ int setup_purgatory(struct kimage *image, const void *slave_code,
 
 	return 0;
 }
-
-/**
- * delete_fdt_mem_rsv - delete memory reservation with given address and size
- *
- * Return: 0 on success, or negative errno on error.
- */
-int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size)
-{
-	int i, ret, num_rsvs = fdt_num_mem_rsv(fdt);
-
-	for (i = 0; i < num_rsvs; i++) {
-		uint64_t rsv_start, rsv_size;
-
-		ret = fdt_get_mem_rsv(fdt, i, &rsv_start, &rsv_size);
-		if (ret) {
-			pr_err("Malformed device tree.\n");
-			return -EINVAL;
-		}
-
-		if (rsv_start == start && rsv_size == size) {
-			ret = fdt_del_mem_rsv(fdt, i);
-			if (ret) {
-				pr_err("Error deleting device tree reservation.\n");
-				return -EINVAL;
-			}
-
-			return 0;
-		}
-	}
-
-	return -ENOENT;
-}
-
-/*
- * setup_new_fdt - modify /chosen and memory reservation for the next kernel
- * @image:		kexec image being loaded.
- * @fdt:		Flattened device tree for the next kernel.
- * @initrd_load_addr:	Address where the next initrd will be loaded.
- * @initrd_len:		Size of the next initrd, or 0 if there will be none.
- * @cmdline:		Command line for the next kernel, or NULL if there will
- *			be none.
- *
- * Return: 0 on success, or negative errno on error.
- */
-int setup_new_fdt(const struct kimage *image, void *fdt,
-		  unsigned long initrd_load_addr, unsigned long initrd_len,
-		  const char *cmdline)
-{
-	int ret;
-
-	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
-	if (ret)
-		goto err;
-
-	return 0;
-
-err:
-	pr_err("Error setting up the new device tree.\n");
-	return -EINVAL;
-}
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index a05c19b3cc60..3cab318aa3b9 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -17,6 +17,7 @@
 #include <linux/kexec.h>
 #include <linux/of_fdt.h>
 #include <linux/libfdt.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/memblock.h>
 #include <linux/slab.h>
@@ -944,7 +945,8 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
 	struct crash_mem *umem = NULL, *rmem = NULL;
 	int i, nr_ranges, ret;
 
-	ret = setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
+	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len,
+				     cmdline);
 	if (ret)
 		goto out;
 
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 5/6] arm64: Free DTB buffer if fdt_open_into() fails
  2021-01-04 19:25 ` Lakshmi Ramasubramanian
@ 2021-01-04 19:26   ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:26 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

create_dtb() function allocates memory for the device tree blob (DTB)
and calls fdt_open_into(). If this call fails the memory allocated
for the DTB is not freed before returning from create_dtb() thereby
leaking memory.

Call vfree() to free the memory allocated for the DTB if fdt_open_into()
fails.

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>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
---
 arch/arm64/kernel/machine_kexec_file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 7da22bb7b9d5..2664b63bb118 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -65,8 +65,10 @@ static int create_dtb(struct kimage *image,
 
 		/* duplicate a device tree blob */
 		ret = fdt_open_into(initial_boot_params, buf, buf_size);
-		if (ret)
+		if (ret) {
+			vfree(buf);
 			return -EINVAL;
+		}
 
 		ret = of_kexec_setup_new_fdt(image, buf, initrd_load_addr,
 					     initrd_len, cmdline);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 5/6] arm64: Free DTB buffer if fdt_open_into() fails
@ 2021-01-04 19:26   ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:26 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

create_dtb() function allocates memory for the device tree blob (DTB)
and calls fdt_open_into(). If this call fails the memory allocated
for the DTB is not freed before returning from create_dtb() thereby
leaking memory.

Call vfree() to free the memory allocated for the DTB if fdt_open_into()
fails.

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>
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
---
 arch/arm64/kernel/machine_kexec_file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index 7da22bb7b9d5..2664b63bb118 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -65,8 +65,10 @@ static int create_dtb(struct kimage *image,
 
 		/* duplicate a device tree blob */
 		ret = fdt_open_into(initial_boot_params, buf, buf_size);
-		if (ret)
+		if (ret) {
+			vfree(buf);
 			return -EINVAL;
+		}
 
 		ret = of_kexec_setup_new_fdt(image, buf, initrd_load_addr,
 					     initrd_len, cmdline);
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
  2021-01-04 19:25 ` Lakshmi Ramasubramanian
@ 2021-01-04 19:26   ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:26 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

Address and size of the buffer containing the IMA measurement log need
to be passed from the current kernel to the next kernel on kexec.

Any existing "linux,ima-kexec-buffer" property in the device tree
needs to be removed and its corresponding memory reservation in
the currently running kernel needs to be freed. The address and
size of the current kernel's IMA measurement log need to be added
to the device tree's IMA kexec buffer node and memory for the buffer
needs to be reserved for the log to be carried over to the next kernel
on the kexec call.

Add address and size fields to "struct kimage_arch" for ARM64 platform
to hold the address and size of the IMA measurement log buffer. Remove
any existing "linux,ima-kexec-buffer" property in the device tree and
free the corresponding memory reservation in the currently running
kernel. Add "linux,ima-kexec-buffer" property to the device tree and
reserve the memory for storing the IMA log that needs to be passed from
the current kernel to the next one.

Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
that the IMA measurement log information is present in the device tree
for ARM64.

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/arm64/Kconfig             | 1 +
 arch/arm64/include/asm/kexec.h | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a6b5b7ef40ae..312b4d5ad232 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1095,6 +1095,7 @@ config KEXEC
 config KEXEC_FILE
 	bool "kexec file based system call"
 	select KEXEC_CORE
+	select HAVE_IMA_KEXEC if IMA
 	help
 	  This is new version of kexec system call. This system call is
 	  file based and takes file descriptors as system call argument
diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h
index d24b527e8c00..2bd19ccb6c43 100644
--- a/arch/arm64/include/asm/kexec.h
+++ b/arch/arm64/include/asm/kexec.h
@@ -100,6 +100,11 @@ struct kimage_arch {
 	void *elf_headers;
 	unsigned long elf_headers_mem;
 	unsigned long elf_headers_sz;
+
+#ifdef CONFIG_IMA_KEXEC
+	phys_addr_t ima_buffer_addr;
+	size_t ima_buffer_size;
+#endif
 };
 
 extern const struct kexec_file_ops kexec_image_ops;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
@ 2021-01-04 19:26   ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-04 19:26 UTC (permalink / raw)
  To: zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

Address and size of the buffer containing the IMA measurement log need
to be passed from the current kernel to the next kernel on kexec.

Any existing "linux,ima-kexec-buffer" property in the device tree
needs to be removed and its corresponding memory reservation in
the currently running kernel needs to be freed. The address and
size of the current kernel's IMA measurement log need to be added
to the device tree's IMA kexec buffer node and memory for the buffer
needs to be reserved for the log to be carried over to the next kernel
on the kexec call.

Add address and size fields to "struct kimage_arch" for ARM64 platform
to hold the address and size of the IMA measurement log buffer. Remove
any existing "linux,ima-kexec-buffer" property in the device tree and
free the corresponding memory reservation in the currently running
kernel. Add "linux,ima-kexec-buffer" property to the device tree and
reserve the memory for storing the IMA log that needs to be passed from
the current kernel to the next one.

Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
that the IMA measurement log information is present in the device tree
for ARM64.

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/arm64/Kconfig             | 1 +
 arch/arm64/include/asm/kexec.h | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a6b5b7ef40ae..312b4d5ad232 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1095,6 +1095,7 @@ config KEXEC
 config KEXEC_FILE
 	bool "kexec file based system call"
 	select KEXEC_CORE
+	select HAVE_IMA_KEXEC if IMA
 	help
 	  This is new version of kexec system call. This system call is
 	  file based and takes file descriptors as system call argument
diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h
index d24b527e8c00..2bd19ccb6c43 100644
--- a/arch/arm64/include/asm/kexec.h
+++ b/arch/arm64/include/asm/kexec.h
@@ -100,6 +100,11 @@ struct kimage_arch {
 	void *elf_headers;
 	unsigned long elf_headers_mem;
 	unsigned long elf_headers_sz;
+
+#ifdef CONFIG_IMA_KEXEC
+	phys_addr_t ima_buffer_addr;
+	size_t ima_buffer_size;
+#endif
 };
 
 extern const struct kexec_file_ops kexec_image_ops;
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
  2021-01-04 19:25 ` Lakshmi Ramasubramanian
@ 2021-01-12 14:42   ` Rob Herring
  -1 siblings, 0 replies; 38+ messages in thread
From: Rob Herring @ 2021-01-12 14:42 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: zohar, bauerman, takahiro.akashi, gregkh, will, catalin.marinas,
	mpe, james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
> On kexec file load Integrity Measurement Architecture (IMA) subsystem
> may verify the IMA signature of the kernel and initramfs, and measure
> it. The command line parameters passed to the kernel in the kexec call
> may also be measured by IMA. A remote attestation service can verify
> a TPM quote based on the TPM event log, the IMA measurement list, and
> the TPM PCR data. This can be achieved only if the IMA measurement log
> is carried over from the current kernel to the next kernel across
> the kexec call.
> 
> powerpc already supports carrying forward the IMA measurement log on
> kexec. This patch set adds support for carrying forward the IMA
> measurement log on kexec on ARM64. 
> 
> This patch set moves the platform independent code defined for powerpc
> such that it can be reused for other platforms as well. A chosen node
> "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
> the address and the size of the memory reserved to carry
> the IMA measurement log.
> 
> This patch set has been tested for ARM64 platform using QEMU.
> I would like help from the community for testing this change on powerpc.
> Thanks.
> 
> This patch set is based on
> commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
> in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
> "dt/kexec" branch.

This all looks good to me. I'd suggest you send the above patches out as 
part of this series because I don't plan to do so.

I would like to also resolve the vmalloc vs. kmalloc difference for 
allocating the FDT. Then we can further consolidate the DT kexec code. 

It all needs some acks from arm64 and powerpc maintainers. As far as 
merging, I think via the integrity tree makes the most sense.

Rob

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
@ 2021-01-12 14:42   ` Rob Herring
  0 siblings, 0 replies; 38+ messages in thread
From: Rob Herring @ 2021-01-12 14:42 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: mark.rutland, benh, bhsharma, tao.li, zohar, paulus,
	vincenzo.frascino, frowand.list, sashal, mpe, masahiroy, jmorris,
	takahiro.akashi, linux-arm-kernel, catalin.marinas, serge,
	devicetree, pasha.tatashin, will, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, gregkh, linux-integrity, bauerman

On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
> On kexec file load Integrity Measurement Architecture (IMA) subsystem
> may verify the IMA signature of the kernel and initramfs, and measure
> it. The command line parameters passed to the kernel in the kexec call
> may also be measured by IMA. A remote attestation service can verify
> a TPM quote based on the TPM event log, the IMA measurement list, and
> the TPM PCR data. This can be achieved only if the IMA measurement log
> is carried over from the current kernel to the next kernel across
> the kexec call.
> 
> powerpc already supports carrying forward the IMA measurement log on
> kexec. This patch set adds support for carrying forward the IMA
> measurement log on kexec on ARM64. 
> 
> This patch set moves the platform independent code defined for powerpc
> such that it can be reused for other platforms as well. A chosen node
> "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
> the address and the size of the memory reserved to carry
> the IMA measurement log.
> 
> This patch set has been tested for ARM64 platform using QEMU.
> I would like help from the community for testing this change on powerpc.
> Thanks.
> 
> This patch set is based on
> commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
> in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
> "dt/kexec" branch.

This all looks good to me. I'd suggest you send the above patches out as 
part of this series because I don't plan to do so.

I would like to also resolve the vmalloc vs. kmalloc difference for 
allocating the FDT. Then we can further consolidate the DT kexec code. 

It all needs some acks from arm64 and powerpc maintainers. As far as 
merging, I think via the integrity tree makes the most sense.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
  2021-01-12 14:42   ` Rob Herring
@ 2021-01-12 18:05     ` Mimi Zohar
  -1 siblings, 0 replies; 38+ messages in thread
From: Mimi Zohar @ 2021-01-12 18:05 UTC (permalink / raw)
  To: Rob Herring, Lakshmi Ramasubramanian
  Cc: bauerman, takahiro.akashi, gregkh, will, catalin.marinas, mpe,
	james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

On Tue, 2021-01-12 at 08:42 -0600, Rob Herring wrote:
> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
> > On kexec file load Integrity Measurement Architecture (IMA) subsystem
> > may verify the IMA signature of the kernel and initramfs, and measure
> > it. The command line parameters passed to the kernel in the kexec call
> > may also be measured by IMA. A remote attestation service can verify
> > a TPM quote based on the TPM event log, the IMA measurement list, and
> > the TPM PCR data. This can be achieved only if the IMA measurement log
> > is carried over from the current kernel to the next kernel across
> > the kexec call.
> > 
> > powerpc already supports carrying forward the IMA measurement log on
> > kexec. This patch set adds support for carrying forward the IMA
> > measurement log on kexec on ARM64. 
> > 
> > This patch set moves the platform independent code defined for powerpc
> > such that it can be reused for other platforms as well. A chosen node
> > "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
> > the address and the size of the memory reserved to carry
> > the IMA measurement log.
> > 
> > This patch set has been tested for ARM64 platform using QEMU.
> > I would like help from the community for testing this change on powerpc.
> > Thanks.
> > 
> > This patch set is based on
> > commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
> > in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
> > "dt/kexec" branch.
> 
> This all looks good to me. I'd suggest you send the above patches out as 
> part of this series because I don't plan to do so.
> 
> I would like to also resolve the vmalloc vs. kmalloc difference for 
> allocating the FDT. Then we can further consolidate the DT kexec code.
> 
> It all needs some acks from arm64 and powerpc maintainers. As far as 
> merging, I think via the integrity tree makes the most sense.

Thanks, Rob.  Lakshmi,  please update Rob's patches to include patch
descriptions before re-posting.

Mimi


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
@ 2021-01-12 18:05     ` Mimi Zohar
  0 siblings, 0 replies; 38+ messages in thread
From: Mimi Zohar @ 2021-01-12 18:05 UTC (permalink / raw)
  To: Rob Herring, Lakshmi Ramasubramanian
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, mpe, masahiroy, jmorris, takahiro.akashi,
	linux-arm-kernel, catalin.marinas, serge, devicetree,
	pasha.tatashin, will, linuxppc-dev, prsriva, hsinyi, allison,
	christophe.leroy, mbrugger, balajib, gregkh, linux-kernel,
	james.morse, dmitry.kasatkin, linux-integrity, bauerman

On Tue, 2021-01-12 at 08:42 -0600, Rob Herring wrote:
> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
> > On kexec file load Integrity Measurement Architecture (IMA) subsystem
> > may verify the IMA signature of the kernel and initramfs, and measure
> > it. The command line parameters passed to the kernel in the kexec call
> > may also be measured by IMA. A remote attestation service can verify
> > a TPM quote based on the TPM event log, the IMA measurement list, and
> > the TPM PCR data. This can be achieved only if the IMA measurement log
> > is carried over from the current kernel to the next kernel across
> > the kexec call.
> > 
> > powerpc already supports carrying forward the IMA measurement log on
> > kexec. This patch set adds support for carrying forward the IMA
> > measurement log on kexec on ARM64. 
> > 
> > This patch set moves the platform independent code defined for powerpc
> > such that it can be reused for other platforms as well. A chosen node
> > "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
> > the address and the size of the memory reserved to carry
> > the IMA measurement log.
> > 
> > This patch set has been tested for ARM64 platform using QEMU.
> > I would like help from the community for testing this change on powerpc.
> > Thanks.
> > 
> > This patch set is based on
> > commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
> > in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
> > "dt/kexec" branch.
> 
> This all looks good to me. I'd suggest you send the above patches out as 
> part of this series because I don't plan to do so.
> 
> I would like to also resolve the vmalloc vs. kmalloc difference for 
> allocating the FDT. Then we can further consolidate the DT kexec code.
> 
> It all needs some acks from arm64 and powerpc maintainers. As far as 
> merging, I think via the integrity tree makes the most sense.

Thanks, Rob.  Lakshmi,  please update Rob's patches to include patch
descriptions before re-posting.

Mimi


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
  2021-01-12 14:42   ` Rob Herring
@ 2021-01-12 18:23     ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 18:23 UTC (permalink / raw)
  To: Rob Herring
  Cc: zohar, bauerman, takahiro.akashi, gregkh, will, catalin.marinas,
	mpe, james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree

On 1/12/21 6:42 AM, Rob Herring wrote:
> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
>> On kexec file load Integrity Measurement Architecture (IMA) subsystem
>> may verify the IMA signature of the kernel and initramfs, and measure
>> it. The command line parameters passed to the kernel in the kexec call
>> may also be measured by IMA. A remote attestation service can verify
>> a TPM quote based on the TPM event log, the IMA measurement list, and
>> the TPM PCR data. This can be achieved only if the IMA measurement log
>> is carried over from the current kernel to the next kernel across
>> the kexec call.
>>
>> powerpc already supports carrying forward the IMA measurement log on
>> kexec. This patch set adds support for carrying forward the IMA
>> measurement log on kexec on ARM64.
>>
>> This patch set moves the platform independent code defined for powerpc
>> such that it can be reused for other platforms as well. A chosen node
>> "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
>> the address and the size of the memory reserved to carry
>> the IMA measurement log.
>>
>> This patch set has been tested for ARM64 platform using QEMU.
>> I would like help from the community for testing this change on powerpc.
>> Thanks.
>>
>> This patch set is based on
>> commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
>> in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
>> "dt/kexec" branch.
> 
> This all looks good to me. I'd suggest you send the above patches out as
> part of this series because I don't plan to do so.

Thanks for reviewing the patches Rob.

Sure - I'll add your patches to this series.

> I would like to also resolve the vmalloc vs. kmalloc difference for
> allocating the FDT. Then we can further consolidate the DT kexec code.

I think FDT allocation using vmalloc for ARM64 can be changed to 
kmalloc. What are the other changes you'd like me to do in arm64/powerpc 
DT kexec code in this patch series?

@AKASHI Takahiro - could you please let me know if the above sounds right?

> 
> It all needs some acks from arm64 and powerpc maintainers. As far as
> merging, I think via the integrity tree makes the most sense.

I'll create the patch series in "next-integrity" branch.

Thiago/Mimi have acked some of the patches. Please review the remaining 
patches in this version.

Could arm64 maintainers please review the patches and respond?

thanks,
  -lakshmi



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
@ 2021-01-12 18:23     ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 18:23 UTC (permalink / raw)
  To: Rob Herring
  Cc: mark.rutland, benh, bhsharma, tao.li, zohar, paulus,
	vincenzo.frascino, frowand.list, sashal, mpe, masahiroy, jmorris,
	takahiro.akashi, linux-arm-kernel, catalin.marinas, serge,
	devicetree, pasha.tatashin, will, prsriva, hsinyi, allison,
	christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, gregkh, linux-integrity, bauerman

On 1/12/21 6:42 AM, Rob Herring wrote:
> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
>> On kexec file load Integrity Measurement Architecture (IMA) subsystem
>> may verify the IMA signature of the kernel and initramfs, and measure
>> it. The command line parameters passed to the kernel in the kexec call
>> may also be measured by IMA. A remote attestation service can verify
>> a TPM quote based on the TPM event log, the IMA measurement list, and
>> the TPM PCR data. This can be achieved only if the IMA measurement log
>> is carried over from the current kernel to the next kernel across
>> the kexec call.
>>
>> powerpc already supports carrying forward the IMA measurement log on
>> kexec. This patch set adds support for carrying forward the IMA
>> measurement log on kexec on ARM64.
>>
>> This patch set moves the platform independent code defined for powerpc
>> such that it can be reused for other platforms as well. A chosen node
>> "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
>> the address and the size of the memory reserved to carry
>> the IMA measurement log.
>>
>> This patch set has been tested for ARM64 platform using QEMU.
>> I would like help from the community for testing this change on powerpc.
>> Thanks.
>>
>> This patch set is based on
>> commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
>> in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
>> "dt/kexec" branch.
> 
> This all looks good to me. I'd suggest you send the above patches out as
> part of this series because I don't plan to do so.

Thanks for reviewing the patches Rob.

Sure - I'll add your patches to this series.

> I would like to also resolve the vmalloc vs. kmalloc difference for
> allocating the FDT. Then we can further consolidate the DT kexec code.

I think FDT allocation using vmalloc for ARM64 can be changed to 
kmalloc. What are the other changes you'd like me to do in arm64/powerpc 
DT kexec code in this patch series?

@AKASHI Takahiro - could you please let me know if the above sounds right?

> 
> It all needs some acks from arm64 and powerpc maintainers. As far as
> merging, I think via the integrity tree makes the most sense.

I'll create the patch series in "next-integrity" branch.

Thiago/Mimi have acked some of the patches. Please review the remaining 
patches in this version.

Could arm64 maintainers please review the patches and respond?

thanks,
  -lakshmi



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
  2021-01-12 18:05     ` Mimi Zohar
@ 2021-01-12 18:24       ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 18:24 UTC (permalink / raw)
  To: Mimi Zohar, Rob Herring
  Cc: bauerman, takahiro.akashi, gregkh, will, catalin.marinas, mpe,
	james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

On 1/12/21 10:05 AM, Mimi Zohar wrote:
> On Tue, 2021-01-12 at 08:42 -0600, Rob Herring wrote:
>> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
>>> On kexec file load Integrity Measurement Architecture (IMA) subsystem
>>> may verify the IMA signature of the kernel and initramfs, and measure
>>> it. The command line parameters passed to the kernel in the kexec call
>>> may also be measured by IMA. A remote attestation service can verify
>>> a TPM quote based on the TPM event log, the IMA measurement list, and
>>> the TPM PCR data. This can be achieved only if the IMA measurement log
>>> is carried over from the current kernel to the next kernel across
>>> the kexec call.
>>>
>>> powerpc already supports carrying forward the IMA measurement log on
>>> kexec. This patch set adds support for carrying forward the IMA
>>> measurement log on kexec on ARM64.
>>>
>>> This patch set moves the platform independent code defined for powerpc
>>> such that it can be reused for other platforms as well. A chosen node
>>> "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
>>> the address and the size of the memory reserved to carry
>>> the IMA measurement log.
>>>
>>> This patch set has been tested for ARM64 platform using QEMU.
>>> I would like help from the community for testing this change on powerpc.
>>> Thanks.
>>>
>>> This patch set is based on
>>> commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
>>> in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
>>> "dt/kexec" branch.
>>
>> This all looks good to me. I'd suggest you send the above patches out as
>> part of this series because I don't plan to do so.
>>
>> I would like to also resolve the vmalloc vs. kmalloc difference for
>> allocating the FDT. Then we can further consolidate the DT kexec code.
>>
>> It all needs some acks from arm64 and powerpc maintainers. As far as
>> merging, I think via the integrity tree makes the most sense.
> 
> Thanks, Rob.  Lakshmi,  please update Rob's patches to include patch
> descriptions before re-posting.
> 

Will do Mimi.

thanks,
  -lakshmi



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
@ 2021-01-12 18:24       ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 18:24 UTC (permalink / raw)
  To: Mimi Zohar, Rob Herring
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, mpe, masahiroy, jmorris, takahiro.akashi,
	linux-arm-kernel, catalin.marinas, serge, devicetree,
	pasha.tatashin, will, linuxppc-dev, prsriva, hsinyi, allison,
	christophe.leroy, mbrugger, balajib, gregkh, linux-kernel,
	james.morse, dmitry.kasatkin, linux-integrity, bauerman

On 1/12/21 10:05 AM, Mimi Zohar wrote:
> On Tue, 2021-01-12 at 08:42 -0600, Rob Herring wrote:
>> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
>>> On kexec file load Integrity Measurement Architecture (IMA) subsystem
>>> may verify the IMA signature of the kernel and initramfs, and measure
>>> it. The command line parameters passed to the kernel in the kexec call
>>> may also be measured by IMA. A remote attestation service can verify
>>> a TPM quote based on the TPM event log, the IMA measurement list, and
>>> the TPM PCR data. This can be achieved only if the IMA measurement log
>>> is carried over from the current kernel to the next kernel across
>>> the kexec call.
>>>
>>> powerpc already supports carrying forward the IMA measurement log on
>>> kexec. This patch set adds support for carrying forward the IMA
>>> measurement log on kexec on ARM64.
>>>
>>> This patch set moves the platform independent code defined for powerpc
>>> such that it can be reused for other platforms as well. A chosen node
>>> "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
>>> the address and the size of the memory reserved to carry
>>> the IMA measurement log.
>>>
>>> This patch set has been tested for ARM64 platform using QEMU.
>>> I would like help from the community for testing this change on powerpc.
>>> Thanks.
>>>
>>> This patch set is based on
>>> commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
>>> in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
>>> "dt/kexec" branch.
>>
>> This all looks good to me. I'd suggest you send the above patches out as
>> part of this series because I don't plan to do so.
>>
>> I would like to also resolve the vmalloc vs. kmalloc difference for
>> allocating the FDT. Then we can further consolidate the DT kexec code.
>>
>> It all needs some acks from arm64 and powerpc maintainers. As far as
>> merging, I think via the integrity tree makes the most sense.
> 
> Thanks, Rob.  Lakshmi,  please update Rob's patches to include patch
> descriptions before re-posting.
> 

Will do Mimi.

thanks,
  -lakshmi



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
  2021-01-12 18:05     ` Mimi Zohar
@ 2021-01-12 18:45       ` Thiago Jung Bauermann
  -1 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-12 18:45 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Rob Herring, Lakshmi Ramasubramanian, takahiro.akashi, gregkh,
	will, catalin.marinas, mpe, james.morse, sashal, benh, paulus,
	frowand.list, vincenzo.frascino, mark.rutland, dmitry.kasatkin,
	jmorris, serge, pasha.tatashin, allison, masahiroy, bhsharma,
	mbrugger, hsinyi, tao.li, christophe.leroy, prsriva, balajib,
	linux-integrity, linux-kernel, linux-arm-kernel, devicetree


Mimi Zohar <zohar@linux.ibm.com> writes:

> On Tue, 2021-01-12 at 08:42 -0600, Rob Herring wrote:
>> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
>> > On kexec file load Integrity Measurement Architecture (IMA) subsystem
>> > may verify the IMA signature of the kernel and initramfs, and measure
>> > it. The command line parameters passed to the kernel in the kexec call
>> > may also be measured by IMA. A remote attestation service can verify
>> > a TPM quote based on the TPM event log, the IMA measurement list, and
>> > the TPM PCR data. This can be achieved only if the IMA measurement log
>> > is carried over from the current kernel to the next kernel across
>> > the kexec call.
>> > 
>> > powerpc already supports carrying forward the IMA measurement log on
>> > kexec. This patch set adds support for carrying forward the IMA
>> > measurement log on kexec on ARM64. 
>> > 
>> > This patch set moves the platform independent code defined for powerpc
>> > such that it can be reused for other platforms as well. A chosen node
>> > "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
>> > the address and the size of the memory reserved to carry
>> > the IMA measurement log.
>> > 
>> > This patch set has been tested for ARM64 platform using QEMU.
>> > I would like help from the community for testing this change on powerpc.
>> > Thanks.
>> > 
>> > This patch set is based on
>> > commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
>> > in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
>> > "dt/kexec" branch.
>> 
>> This all looks good to me. I'd suggest you send the above patches out as 
>> part of this series because I don't plan to do so.
>> 
>> I would like to also resolve the vmalloc vs. kmalloc difference for 
>> allocating the FDT. Then we can further consolidate the DT kexec code.
>> 
>> It all needs some acks from arm64 and powerpc maintainers. As far as 
>> merging, I think via the integrity tree makes the most sense.
>
> Thanks, Rob.  Lakshmi,  please update Rob's patches to include patch
> descriptions before re-posting.

Also please update the powerpc mailing list address to
linuxppc-dev@lists.ozlabs.org

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64
@ 2021-01-12 18:45       ` Thiago Jung Bauermann
  0 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-12 18:45 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, takahiro.akashi, mpe, masahiroy, jmorris,
	Lakshmi Ramasubramanian, linux-arm-kernel, catalin.marinas,
	serge, devicetree, pasha.tatashin, will, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, gregkh, linux-integrity


Mimi Zohar <zohar@linux.ibm.com> writes:

> On Tue, 2021-01-12 at 08:42 -0600, Rob Herring wrote:
>> On Mon, Jan 04, 2021 at 11:25:56AM -0800, Lakshmi Ramasubramanian wrote:
>> > On kexec file load Integrity Measurement Architecture (IMA) subsystem
>> > may verify the IMA signature of the kernel and initramfs, and measure
>> > it. The command line parameters passed to the kernel in the kexec call
>> > may also be measured by IMA. A remote attestation service can verify
>> > a TPM quote based on the TPM event log, the IMA measurement list, and
>> > the TPM PCR data. This can be achieved only if the IMA measurement log
>> > is carried over from the current kernel to the next kernel across
>> > the kexec call.
>> > 
>> > powerpc already supports carrying forward the IMA measurement log on
>> > kexec. This patch set adds support for carrying forward the IMA
>> > measurement log on kexec on ARM64. 
>> > 
>> > This patch set moves the platform independent code defined for powerpc
>> > such that it can be reused for other platforms as well. A chosen node
>> > "linux,ima-kexec-buffer" is added to the DTB for ARM64 to hold
>> > the address and the size of the memory reserved to carry
>> > the IMA measurement log.
>> > 
>> > This patch set has been tested for ARM64 platform using QEMU.
>> > I would like help from the community for testing this change on powerpc.
>> > Thanks.
>> > 
>> > This patch set is based on
>> > commit a29a64445089 ("powerpc: Use common of_kexec_setup_new_fdt()")
>> > in https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
>> > "dt/kexec" branch.
>> 
>> This all looks good to me. I'd suggest you send the above patches out as 
>> part of this series because I don't plan to do so.
>> 
>> I would like to also resolve the vmalloc vs. kmalloc difference for 
>> allocating the FDT. Then we can further consolidate the DT kexec code.
>> 
>> It all needs some acks from arm64 and powerpc maintainers. As far as 
>> merging, I think via the integrity tree makes the most sense.
>
> Thanks, Rob.  Lakshmi,  please update Rob's patches to include patch
> descriptions before re-posting.

Also please update the powerpc mailing list address to
linuxppc-dev@lists.ozlabs.org

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
  2021-01-04 19:26   ` Lakshmi Ramasubramanian
@ 2021-01-12 23:28     ` Mimi Zohar
  -1 siblings, 0 replies; 38+ messages in thread
From: Mimi Zohar @ 2021-01-12 23:28 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian, bauerman, robh, takahiro.akashi, gregkh,
	will, catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

Hi Lakshmi,

On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:
> Address and size of the buffer containing the IMA measurement log need
> to be passed from the current kernel to the next kernel on kexec.
> 
> Any existing "linux,ima-kexec-buffer" property in the device tree
> needs to be removed and its corresponding memory reservation in
> the currently running kernel needs to be freed. The address and
> size of the current kernel's IMA measurement log need to be added
> to the device tree's IMA kexec buffer node and memory for the buffer
> needs to be reserved for the log to be carried over to the next kernel
> on the kexec call.
> 
> Add address and size fields to "struct kimage_arch" for ARM64 platform
> to hold the address and size of the IMA measurement log buffer. Remove
> any existing "linux,ima-kexec-buffer" property in the device tree and
> free the corresponding memory reservation in the currently running
> kernel. Add "linux,ima-kexec-buffer" property to the device tree and
> reserve the memory for storing the IMA log that needs to be passed from
> the current kernel to the next one.
> 
> Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
> that the IMA measurement log information is present in the device tree
> for ARM64.

Perhaps for some previous version of this patch set, this patch
description was appropriate, but for the code below it's kind of
overkill.

Mimi
> 
> 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/arm64/Kconfig             | 1 +
>  arch/arm64/include/asm/kexec.h | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index a6b5b7ef40ae..312b4d5ad232 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1095,6 +1095,7 @@ config KEXEC
>  config KEXEC_FILE
>  	bool "kexec file based system call"
>  	select KEXEC_CORE
> +	select HAVE_IMA_KEXEC if IMA
>  	help
>  	  This is new version of kexec system call. This system call is
>  	  file based and takes file descriptors as system call argument
> diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h
> index d24b527e8c00..2bd19ccb6c43 100644
> --- a/arch/arm64/include/asm/kexec.h
> +++ b/arch/arm64/include/asm/kexec.h
> @@ -100,6 +100,11 @@ struct kimage_arch {
>  	void *elf_headers;
>  	unsigned long elf_headers_mem;
>  	unsigned long elf_headers_sz;
> +
> +#ifdef CONFIG_IMA_KEXEC
> +	phys_addr_t ima_buffer_addr;
> +	size_t ima_buffer_size;
> +#endif
>  };
>  
>  extern const struct kexec_file_ops kexec_image_ops;



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
@ 2021-01-12 23:28     ` Mimi Zohar
  0 siblings, 0 replies; 38+ messages in thread
From: Mimi Zohar @ 2021-01-12 23:28 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian, bauerman, robh, takahiro.akashi, gregkh,
	will, catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

Hi Lakshmi,

On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:
> Address and size of the buffer containing the IMA measurement log need
> to be passed from the current kernel to the next kernel on kexec.
> 
> Any existing "linux,ima-kexec-buffer" property in the device tree
> needs to be removed and its corresponding memory reservation in
> the currently running kernel needs to be freed. The address and
> size of the current kernel's IMA measurement log need to be added
> to the device tree's IMA kexec buffer node and memory for the buffer
> needs to be reserved for the log to be carried over to the next kernel
> on the kexec call.
> 
> Add address and size fields to "struct kimage_arch" for ARM64 platform
> to hold the address and size of the IMA measurement log buffer. Remove
> any existing "linux,ima-kexec-buffer" property in the device tree and
> free the corresponding memory reservation in the currently running
> kernel. Add "linux,ima-kexec-buffer" property to the device tree and
> reserve the memory for storing the IMA log that needs to be passed from
> the current kernel to the next one.
> 
> Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
> that the IMA measurement log information is present in the device tree
> for ARM64.

Perhaps for some previous version of this patch set, this patch
description was appropriate, but for the code below it's kind of
overkill.

Mimi
> 
> 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/arm64/Kconfig             | 1 +
>  arch/arm64/include/asm/kexec.h | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index a6b5b7ef40ae..312b4d5ad232 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1095,6 +1095,7 @@ config KEXEC
>  config KEXEC_FILE
>  	bool "kexec file based system call"
>  	select KEXEC_CORE
> +	select HAVE_IMA_KEXEC if IMA
>  	help
>  	  This is new version of kexec system call. This system call is
>  	  file based and takes file descriptors as system call argument
> diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h
> index d24b527e8c00..2bd19ccb6c43 100644
> --- a/arch/arm64/include/asm/kexec.h
> +++ b/arch/arm64/include/asm/kexec.h
> @@ -100,6 +100,11 @@ struct kimage_arch {
>  	void *elf_headers;
>  	unsigned long elf_headers_mem;
>  	unsigned long elf_headers_sz;
> +
> +#ifdef CONFIG_IMA_KEXEC
> +	phys_addr_t ima_buffer_addr;
> +	size_t ima_buffer_size;
> +#endif
>  };
>  
>  extern const struct kexec_file_ops kexec_image_ops;



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 4/6] powerpc: Delete unused functions
  2021-01-04 19:26   ` Lakshmi Ramasubramanian
@ 2021-01-12 23:30     ` Mimi Zohar
  -1 siblings, 0 replies; 38+ messages in thread
From: Mimi Zohar @ 2021-01-12 23:30 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian, bauerman, robh, takahiro.akashi, gregkh,
	will, catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

Hi Lakshmi,

On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:

> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> index a05c19b3cc60..3cab318aa3b9 100644
> --- a/arch/powerpc/kexec/file_load_64.c
> +++ b/arch/powerpc/kexec/file_load_64.c
> @@ -17,6 +17,7 @@
>  #include <linux/kexec.h>
>  #include <linux/of_fdt.h>
>  #include <linux/libfdt.h>
> +#include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/memblock.h>
>  #include <linux/slab.h>
> @@ -944,7 +945,8 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
>  	struct crash_mem *umem = NULL, *rmem = NULL;
>  	int i, nr_ranges, ret;
>  
> -	ret = setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
> +	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len,
> +				     cmdline);
>  	if (ret)
>  		goto out;
>  

The "powerpc: Move arch independent ima kexec functions to
drivers/of/kexec.c" moved setup_ima_buffer() to
of_kexec_setup_new_fdt().  Defering making the change from
setup_new_fdt() to of_kexec_setup_new_fdt() here, is not bisect safe.

Mimi


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 4/6] powerpc: Delete unused functions
@ 2021-01-12 23:30     ` Mimi Zohar
  0 siblings, 0 replies; 38+ messages in thread
From: Mimi Zohar @ 2021-01-12 23:30 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian, bauerman, robh, takahiro.akashi, gregkh,
	will, catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

Hi Lakshmi,

On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:

> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> index a05c19b3cc60..3cab318aa3b9 100644
> --- a/arch/powerpc/kexec/file_load_64.c
> +++ b/arch/powerpc/kexec/file_load_64.c
> @@ -17,6 +17,7 @@
>  #include <linux/kexec.h>
>  #include <linux/of_fdt.h>
>  #include <linux/libfdt.h>
> +#include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/memblock.h>
>  #include <linux/slab.h>
> @@ -944,7 +945,8 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
>  	struct crash_mem *umem = NULL, *rmem = NULL;
>  	int i, nr_ranges, ret;
>  
> -	ret = setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
> +	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len,
> +				     cmdline);
>  	if (ret)
>  		goto out;
>  

The "powerpc: Move arch independent ima kexec functions to
drivers/of/kexec.c" moved setup_ima_buffer() to
of_kexec_setup_new_fdt().  Defering making the change from
setup_new_fdt() to of_kexec_setup_new_fdt() here, is not bisect safe.

Mimi


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
  2021-01-12 23:28     ` Mimi Zohar
@ 2021-01-12 23:54       ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 23:54 UTC (permalink / raw)
  To: Mimi Zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev

On 1/12/21 3:28 PM, Mimi Zohar wrote:
> Hi Lakshmi,
> 
> On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:
>> Address and size of the buffer containing the IMA measurement log need
>> to be passed from the current kernel to the next kernel on kexec.
>>
>> Any existing "linux,ima-kexec-buffer" property in the device tree
>> needs to be removed and its corresponding memory reservation in
>> the currently running kernel needs to be freed. The address and
>> size of the current kernel's IMA measurement log need to be added
>> to the device tree's IMA kexec buffer node and memory for the buffer
>> needs to be reserved for the log to be carried over to the next kernel
>> on the kexec call.
>>
>> Add address and size fields to "struct kimage_arch" for ARM64 platform
>> to hold the address and size of the IMA measurement log buffer. Remove
>> any existing "linux,ima-kexec-buffer" property in the device tree and
>> free the corresponding memory reservation in the currently running
>> kernel. Add "linux,ima-kexec-buffer" property to the device tree and
>> reserve the memory for storing the IMA log that needs to be passed from
>> the current kernel to the next one.
>>
>> Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
>> that the IMA measurement log information is present in the device tree
>> for ARM64.
> 
> Perhaps for some previous version of this patch set, this patch
> description was appropriate, but for the code below it's kind of
> overkill.
> 

I agree Mimi. Will edit the patch description.

thanks,
  -lakshmi

>>
>> 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/arm64/Kconfig             | 1 +
>>   arch/arm64/include/asm/kexec.h | 5 +++++
>>   2 files changed, 6 insertions(+)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index a6b5b7ef40ae..312b4d5ad232 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -1095,6 +1095,7 @@ config KEXEC
>>   config KEXEC_FILE
>>   	bool "kexec file based system call"
>>   	select KEXEC_CORE
>> +	select HAVE_IMA_KEXEC if IMA
>>   	help
>>   	  This is new version of kexec system call. This system call is
>>   	  file based and takes file descriptors as system call argument
>> diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h
>> index d24b527e8c00..2bd19ccb6c43 100644
>> --- a/arch/arm64/include/asm/kexec.h
>> +++ b/arch/arm64/include/asm/kexec.h
>> @@ -100,6 +100,11 @@ struct kimage_arch {
>>   	void *elf_headers;
>>   	unsigned long elf_headers_mem;
>>   	unsigned long elf_headers_sz;
>> +
>> +#ifdef CONFIG_IMA_KEXEC
>> +	phys_addr_t ima_buffer_addr;
>> +	size_t ima_buffer_size;
>> +#endif
>>   };
>>   
>>   extern const struct kexec_file_ops kexec_image_ops;
> 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
@ 2021-01-12 23:54       ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 23:54 UTC (permalink / raw)
  To: Mimi Zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

On 1/12/21 3:28 PM, Mimi Zohar wrote:
> Hi Lakshmi,
> 
> On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:
>> Address and size of the buffer containing the IMA measurement log need
>> to be passed from the current kernel to the next kernel on kexec.
>>
>> Any existing "linux,ima-kexec-buffer" property in the device tree
>> needs to be removed and its corresponding memory reservation in
>> the currently running kernel needs to be freed. The address and
>> size of the current kernel's IMA measurement log need to be added
>> to the device tree's IMA kexec buffer node and memory for the buffer
>> needs to be reserved for the log to be carried over to the next kernel
>> on the kexec call.
>>
>> Add address and size fields to "struct kimage_arch" for ARM64 platform
>> to hold the address and size of the IMA measurement log buffer. Remove
>> any existing "linux,ima-kexec-buffer" property in the device tree and
>> free the corresponding memory reservation in the currently running
>> kernel. Add "linux,ima-kexec-buffer" property to the device tree and
>> reserve the memory for storing the IMA log that needs to be passed from
>> the current kernel to the next one.
>>
>> Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
>> that the IMA measurement log information is present in the device tree
>> for ARM64.
> 
> Perhaps for some previous version of this patch set, this patch
> description was appropriate, but for the code below it's kind of
> overkill.
> 

I agree Mimi. Will edit the patch description.

thanks,
  -lakshmi

>>
>> 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/arm64/Kconfig             | 1 +
>>   arch/arm64/include/asm/kexec.h | 5 +++++
>>   2 files changed, 6 insertions(+)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index a6b5b7ef40ae..312b4d5ad232 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -1095,6 +1095,7 @@ config KEXEC
>>   config KEXEC_FILE
>>   	bool "kexec file based system call"
>>   	select KEXEC_CORE
>> +	select HAVE_IMA_KEXEC if IMA
>>   	help
>>   	  This is new version of kexec system call. This system call is
>>   	  file based and takes file descriptors as system call argument
>> diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h
>> index d24b527e8c00..2bd19ccb6c43 100644
>> --- a/arch/arm64/include/asm/kexec.h
>> +++ b/arch/arm64/include/asm/kexec.h
>> @@ -100,6 +100,11 @@ struct kimage_arch {
>>   	void *elf_headers;
>>   	unsigned long elf_headers_mem;
>>   	unsigned long elf_headers_sz;
>> +
>> +#ifdef CONFIG_IMA_KEXEC
>> +	phys_addr_t ima_buffer_addr;
>> +	size_t ima_buffer_size;
>> +#endif
>>   };
>>   
>>   extern const struct kexec_file_ops kexec_image_ops;
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 4/6] powerpc: Delete unused functions
  2021-01-12 23:30     ` Mimi Zohar
@ 2021-01-12 23:57       ` Lakshmi Ramasubramanian
  -1 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 23:57 UTC (permalink / raw)
  To: Mimi Zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree

On 1/12/21 3:30 PM, Mimi Zohar wrote:
> Hi Lakshmi,
> 
> On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:
> 
>> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
>> index a05c19b3cc60..3cab318aa3b9 100644
>> --- a/arch/powerpc/kexec/file_load_64.c
>> +++ b/arch/powerpc/kexec/file_load_64.c
>> @@ -17,6 +17,7 @@
>>   #include <linux/kexec.h>
>>   #include <linux/of_fdt.h>
>>   #include <linux/libfdt.h>
>> +#include <linux/of.h>
>>   #include <linux/of_device.h>
>>   #include <linux/memblock.h>
>>   #include <linux/slab.h>
>> @@ -944,7 +945,8 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
>>   	struct crash_mem *umem = NULL, *rmem = NULL;
>>   	int i, nr_ranges, ret;
>>   
>> -	ret = setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
>> +	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len,
>> +				     cmdline);
>>   	if (ret)
>>   		goto out;
>>   
> 
> The "powerpc: Move arch independent ima kexec functions to
> drivers/of/kexec.c" moved setup_ima_buffer() to
> of_kexec_setup_new_fdt().  Defering making the change from
> setup_new_fdt() to of_kexec_setup_new_fdt() here, is not bisect safe.
> 

Agreed - I will move this change to "powerpc: Move arch independent ima 
kexec functions to drivers/of/kexec.c" patch.

thanks,
  -lakshmi

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 4/6] powerpc: Delete unused functions
@ 2021-01-12 23:57       ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 38+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-01-12 23:57 UTC (permalink / raw)
  To: Mimi Zohar, bauerman, robh, takahiro.akashi, gregkh, will,
	catalin.marinas, mpe
  Cc: mark.rutland, benh, bhsharma, tao.li, paulus, vincenzo.frascino,
	frowand.list, sashal, masahiroy, jmorris, linux-arm-kernel,
	serge, devicetree, pasha.tatashin, prsriva, hsinyi, allison,
	christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, linux-integrity

On 1/12/21 3:30 PM, Mimi Zohar wrote:
> Hi Lakshmi,
> 
> On Mon, 2021-01-04 at 11:26 -0800, Lakshmi Ramasubramanian wrote:
> 
>> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
>> index a05c19b3cc60..3cab318aa3b9 100644
>> --- a/arch/powerpc/kexec/file_load_64.c
>> +++ b/arch/powerpc/kexec/file_load_64.c
>> @@ -17,6 +17,7 @@
>>   #include <linux/kexec.h>
>>   #include <linux/of_fdt.h>
>>   #include <linux/libfdt.h>
>> +#include <linux/of.h>
>>   #include <linux/of_device.h>
>>   #include <linux/memblock.h>
>>   #include <linux/slab.h>
>> @@ -944,7 +945,8 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
>>   	struct crash_mem *umem = NULL, *rmem = NULL;
>>   	int i, nr_ranges, ret;
>>   
>> -	ret = setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);
>> +	ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len,
>> +				     cmdline);
>>   	if (ret)
>>   		goto out;
>>   
> 
> The "powerpc: Move arch independent ima kexec functions to
> drivers/of/kexec.c" moved setup_ima_buffer() to
> of_kexec_setup_new_fdt().  Defering making the change from
> setup_new_fdt() to of_kexec_setup_new_fdt() here, is not bisect safe.
> 

Agreed - I will move this change to "powerpc: Move arch independent ima 
kexec functions to drivers/of/kexec.c" patch.

thanks,
  -lakshmi

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c
  2021-01-04 19:25   ` Lakshmi Ramasubramanian
@ 2021-01-13  2:14     ` Thiago Jung Bauermann
  -1 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-13  2:14 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: zohar, robh, takahiro.akashi, gregkh, will, catalin.marinas, mpe,
	james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev


Lakshmi Ramasubramanian <nramas@linux.microsoft.com> writes:

> The functions defined in "arch/powerpc/kexec/ima.c" handle setting up
> and freeing the resources required to carry over the IMA measurement
> list from the current kernel to the next kernel across kexec system call.
> These functions do not have architecture specific code, but are
> currently limited to powerpc.
>
> Move setup_ima_buffer() call into of_kexec_setup_new_fdt() defined in
> "drivers/of/kexec.c".
>
> Move the remaining architecture independent functions from
> "arch/powerpc/kexec/ima.c" to "drivers/of/kexec.c".
> Delete "arch/powerpc/kexec/ima.c" and "arch/powerpc/include/asm/ima.h".
> Remove references to the deleted files in powerpc and in 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/Kconfig               |   2 +-
>  arch/powerpc/include/asm/ima.h     |  27 ----
>  arch/powerpc/kexec/Makefile        |   7 -
>  arch/powerpc/kexec/file_load.c     |   7 -
>  arch/powerpc/kexec/ima.c           | 202 ------------------------
>  drivers/of/kexec.c                 | 240 +++++++++++++++++++++++++++++
>  include/linux/of.h                 |   2 +
>  security/integrity/ima/ima.h       |   4 -
>  security/integrity/ima/ima_kexec.c |   1 +
>  9 files changed, 244 insertions(+), 248 deletions(-)
>  delete mode 100644 arch/powerpc/include/asm/ima.h
>  delete mode 100644 arch/powerpc/kexec/ima.c

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

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c
@ 2021-01-13  2:14     ` Thiago Jung Bauermann
  0 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-13  2:14 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: mark.rutland, benh, bhsharma, tao.li, zohar, paulus,
	vincenzo.frascino, frowand.list, sashal, mpe, masahiroy, jmorris,
	takahiro.akashi, linux-arm-kernel, catalin.marinas, serge,
	devicetree, pasha.tatashin, will, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, gregkh, linux-integrity


Lakshmi Ramasubramanian <nramas@linux.microsoft.com> writes:

> The functions defined in "arch/powerpc/kexec/ima.c" handle setting up
> and freeing the resources required to carry over the IMA measurement
> list from the current kernel to the next kernel across kexec system call.
> These functions do not have architecture specific code, but are
> currently limited to powerpc.
>
> Move setup_ima_buffer() call into of_kexec_setup_new_fdt() defined in
> "drivers/of/kexec.c".
>
> Move the remaining architecture independent functions from
> "arch/powerpc/kexec/ima.c" to "drivers/of/kexec.c".
> Delete "arch/powerpc/kexec/ima.c" and "arch/powerpc/include/asm/ima.h".
> Remove references to the deleted files in powerpc and in 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/Kconfig               |   2 +-
>  arch/powerpc/include/asm/ima.h     |  27 ----
>  arch/powerpc/kexec/Makefile        |   7 -
>  arch/powerpc/kexec/file_load.c     |   7 -
>  arch/powerpc/kexec/ima.c           | 202 ------------------------
>  drivers/of/kexec.c                 | 240 +++++++++++++++++++++++++++++
>  include/linux/of.h                 |   2 +
>  security/integrity/ima/ima.h       |   4 -
>  security/integrity/ima/ima_kexec.c |   1 +
>  9 files changed, 244 insertions(+), 248 deletions(-)
>  delete mode 100644 arch/powerpc/include/asm/ima.h
>  delete mode 100644 arch/powerpc/kexec/ima.c

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

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 4/6] powerpc: Delete unused functions
  2021-01-04 19:26   ` Lakshmi Ramasubramanian
@ 2021-01-13  2:15     ` Thiago Jung Bauermann
  -1 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-13  2:15 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: zohar, robh, takahiro.akashi, gregkh, will, catalin.marinas, mpe,
	james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev


Lakshmi Ramasubramanian <nramas@linux.microsoft.com> writes:

> delete_fdt_mem_rsv() defined in "arch/powerpc/kexec/file_load.c"
> has been renamed to fdt_find_and_del_mem_rsv(), and moved to
> "drivers/of/kexec.c".
>
> Remove delete_fdt_mem_rsv() in "arch/powerpc/kexec/file_load.c".
>
> Call of_kexec_setup_new_fdt() from setup_new_fdt_ppc64() and
> remove setup_new_fdt() in "arch/powerpc/kexec/file_load.c".
>
> 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/kexec.h  |  4 ---
>  arch/powerpc/kexec/file_load.c    | 60 -------------------------------
>  arch/powerpc/kexec/file_load_64.c |  4 ++-
>  3 files changed, 3 insertions(+), 65 deletions(-)

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

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 4/6] powerpc: Delete unused functions
@ 2021-01-13  2:15     ` Thiago Jung Bauermann
  0 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-13  2:15 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: mark.rutland, benh, bhsharma, tao.li, zohar, paulus,
	vincenzo.frascino, frowand.list, sashal, mpe, masahiroy, jmorris,
	takahiro.akashi, linux-arm-kernel, catalin.marinas, serge,
	devicetree, pasha.tatashin, will, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, gregkh, linux-integrity


Lakshmi Ramasubramanian <nramas@linux.microsoft.com> writes:

> delete_fdt_mem_rsv() defined in "arch/powerpc/kexec/file_load.c"
> has been renamed to fdt_find_and_del_mem_rsv(), and moved to
> "drivers/of/kexec.c".
>
> Remove delete_fdt_mem_rsv() in "arch/powerpc/kexec/file_load.c".
>
> Call of_kexec_setup_new_fdt() from setup_new_fdt_ppc64() and
> remove setup_new_fdt() in "arch/powerpc/kexec/file_load.c".
>
> 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/kexec.h  |  4 ---
>  arch/powerpc/kexec/file_load.c    | 60 -------------------------------
>  arch/powerpc/kexec/file_load_64.c |  4 ++-
>  3 files changed, 3 insertions(+), 65 deletions(-)

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

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
  2021-01-04 19:26   ` Lakshmi Ramasubramanian
@ 2021-01-13  2:16     ` Thiago Jung Bauermann
  -1 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-13  2:16 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: zohar, robh, takahiro.akashi, gregkh, will, catalin.marinas, mpe,
	james.morse, sashal, benh, paulus, frowand.list,
	vincenzo.frascino, mark.rutland, dmitry.kasatkin, jmorris, serge,
	pasha.tatashin, allison, masahiroy, bhsharma, mbrugger, hsinyi,
	tao.li, christophe.leroy, prsriva, balajib, linux-integrity,
	linux-kernel, linux-arm-kernel, devicetree, linuxppc-dev


Lakshmi Ramasubramanian <nramas@linux.microsoft.com> writes:

> Address and size of the buffer containing the IMA measurement log need
> to be passed from the current kernel to the next kernel on kexec.
>
> Any existing "linux,ima-kexec-buffer" property in the device tree
> needs to be removed and its corresponding memory reservation in
> the currently running kernel needs to be freed. The address and
> size of the current kernel's IMA measurement log need to be added
> to the device tree's IMA kexec buffer node and memory for the buffer
> needs to be reserved for the log to be carried over to the next kernel
> on the kexec call.
>
> Add address and size fields to "struct kimage_arch" for ARM64 platform
> to hold the address and size of the IMA measurement log buffer. Remove
> any existing "linux,ima-kexec-buffer" property in the device tree and
> free the corresponding memory reservation in the currently running
> kernel. Add "linux,ima-kexec-buffer" property to the device tree and
> reserve the memory for storing the IMA log that needs to be passed from
> the current kernel to the next one.
>
> Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
> that the IMA measurement log information is present in the device tree
> for ARM64.
>
> 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/arm64/Kconfig             | 1 +
>  arch/arm64/include/asm/kexec.h | 5 +++++
>  2 files changed, 6 insertions(+)

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

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec
@ 2021-01-13  2:16     ` Thiago Jung Bauermann
  0 siblings, 0 replies; 38+ messages in thread
From: Thiago Jung Bauermann @ 2021-01-13  2:16 UTC (permalink / raw)
  To: Lakshmi Ramasubramanian
  Cc: mark.rutland, benh, bhsharma, tao.li, zohar, paulus,
	vincenzo.frascino, frowand.list, sashal, mpe, masahiroy, jmorris,
	takahiro.akashi, linux-arm-kernel, catalin.marinas, serge,
	devicetree, pasha.tatashin, will, linuxppc-dev, prsriva, hsinyi,
	allison, christophe.leroy, mbrugger, balajib, dmitry.kasatkin,
	linux-kernel, james.morse, gregkh, linux-integrity


Lakshmi Ramasubramanian <nramas@linux.microsoft.com> writes:

> Address and size of the buffer containing the IMA measurement log need
> to be passed from the current kernel to the next kernel on kexec.
>
> Any existing "linux,ima-kexec-buffer" property in the device tree
> needs to be removed and its corresponding memory reservation in
> the currently running kernel needs to be freed. The address and
> size of the current kernel's IMA measurement log need to be added
> to the device tree's IMA kexec buffer node and memory for the buffer
> needs to be reserved for the log to be carried over to the next kernel
> on the kexec call.
>
> Add address and size fields to "struct kimage_arch" for ARM64 platform
> to hold the address and size of the IMA measurement log buffer. Remove
> any existing "linux,ima-kexec-buffer" property in the device tree and
> free the corresponding memory reservation in the currently running
> kernel. Add "linux,ima-kexec-buffer" property to the device tree and
> reserve the memory for storing the IMA log that needs to be passed from
> the current kernel to the next one.
>
> Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate
> that the IMA measurement log information is present in the device tree
> for ARM64.
>
> 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/arm64/Kconfig             | 1 +
>  arch/arm64/include/asm/kexec.h | 5 +++++
>  2 files changed, 6 insertions(+)

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

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2021-01-13  2:18 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 19:25 [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64 Lakshmi Ramasubramanian
2021-01-04 19:25 ` Lakshmi Ramasubramanian
2021-01-04 19:25 ` [PATCH v14 1/6] ima: Move arch_ima_add_kexec_buffer() to ima Lakshmi Ramasubramanian
2021-01-04 19:25   ` Lakshmi Ramasubramanian
2021-01-04 19:25 ` [PATCH v14 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c Lakshmi Ramasubramanian
2021-01-04 19:25   ` Lakshmi Ramasubramanian
2021-01-13  2:14   ` Thiago Jung Bauermann
2021-01-13  2:14     ` Thiago Jung Bauermann
2021-01-04 19:25 ` [PATCH v14 3/6] kexec: Use fdt_appendprop_addrrange() to add ima buffer to FDT Lakshmi Ramasubramanian
2021-01-04 19:25   ` Lakshmi Ramasubramanian
2021-01-04 19:26 ` [PATCH v14 4/6] powerpc: Delete unused functions Lakshmi Ramasubramanian
2021-01-04 19:26   ` Lakshmi Ramasubramanian
2021-01-12 23:30   ` Mimi Zohar
2021-01-12 23:30     ` Mimi Zohar
2021-01-12 23:57     ` Lakshmi Ramasubramanian
2021-01-12 23:57       ` Lakshmi Ramasubramanian
2021-01-13  2:15   ` Thiago Jung Bauermann
2021-01-13  2:15     ` Thiago Jung Bauermann
2021-01-04 19:26 ` [PATCH v14 5/6] arm64: Free DTB buffer if fdt_open_into() fails Lakshmi Ramasubramanian
2021-01-04 19:26   ` Lakshmi Ramasubramanian
2021-01-04 19:26 ` [PATCH v14 6/6] arm64: Add IMA log information in kimage used for kexec Lakshmi Ramasubramanian
2021-01-04 19:26   ` Lakshmi Ramasubramanian
2021-01-12 23:28   ` Mimi Zohar
2021-01-12 23:28     ` Mimi Zohar
2021-01-12 23:54     ` Lakshmi Ramasubramanian
2021-01-12 23:54       ` Lakshmi Ramasubramanian
2021-01-13  2:16   ` Thiago Jung Bauermann
2021-01-13  2:16     ` Thiago Jung Bauermann
2021-01-12 14:42 ` [PATCH v14 0/6] Carry forward IMA measurement log on kexec on ARM64 Rob Herring
2021-01-12 14:42   ` Rob Herring
2021-01-12 18:05   ` Mimi Zohar
2021-01-12 18:05     ` Mimi Zohar
2021-01-12 18:24     ` Lakshmi Ramasubramanian
2021-01-12 18:24       ` Lakshmi Ramasubramanian
2021-01-12 18:45     ` Thiago Jung Bauermann
2021-01-12 18:45       ` Thiago Jung Bauermann
2021-01-12 18:23   ` Lakshmi Ramasubramanian
2021-01-12 18:23     ` Lakshmi Ramasubramanian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.