Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of/kexec: refactor ima_get_kexec_buffer() to use ima_validate_range()

Refactor the OF/DT ima_get_kexec_buffer() to use a generic helper to
validate the address range. No functional change intended.

Link: https://lkml.kernel.org/r/20251231061609.907170-3-harshit.m.mogalapalli@oracle.com
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Cc: Alexander Graf <graf@amazon.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Borislav Betkov <bp@alien8.de>
Cc: guoweikang <guoweikang.kernel@gmail.com>
Cc: Henry Willard <henry.willard@oracle.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Bohac <jbohac@suse.cz>
Cc: Joel Granados <joel.granados@kernel.org>
Cc: Jonathan McDowell <noodles@fb.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Paul Webb <paul.x.webb@oracle.com>
Cc: Sohil Mehta <sohil.mehta@intel.com>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Yifei Liu <yifei.l.liu@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Harshit Mogalapalli and committed by
Andrew Morton
4d022332 10d1c75e

+3 -12
+3 -12
drivers/of/kexec.c
··· 128 128 { 129 129 int ret, len; 130 130 unsigned long tmp_addr; 131 - unsigned long start_pfn, end_pfn; 132 131 size_t tmp_size; 133 132 const void *prop; 134 133 ··· 143 144 if (!tmp_size) 144 145 return -ENOENT; 145 146 146 - /* 147 - * Calculate the PFNs for the buffer and ensure 148 - * they are with in addressable memory. 149 - */ 150 - start_pfn = PHYS_PFN(tmp_addr); 151 - end_pfn = PHYS_PFN(tmp_addr + tmp_size - 1); 152 - if (!page_is_ram(start_pfn) || !page_is_ram(end_pfn)) { 153 - pr_warn("IMA buffer at 0x%lx, size = 0x%zx beyond memory\n", 154 - tmp_addr, tmp_size); 155 - return -EINVAL; 156 - } 147 + ret = ima_validate_range(tmp_addr, tmp_size); 148 + if (ret) 149 + return ret; 157 150 158 151 *addr = __va(tmp_addr); 159 152 *size = tmp_size;