]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
of/kexec: refactor ima_get_kexec_buffer() to use ima_validate_range()
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Wed, 31 Dec 2025 06:16:08 +0000 (22:16 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 27 Jan 2026 03:07:11 +0000 (19:07 -0800)
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>
drivers/of/kexec.c

index 1ee2d31816aebe6a039346c22e08d754bad06977..c4cf3552c0183887583dff6ee04a85f89c424489 100644 (file)
@@ -128,7 +128,6 @@ int __init ima_get_kexec_buffer(void **addr, size_t *size)
 {
        int ret, len;
        unsigned long tmp_addr;
-       unsigned long start_pfn, end_pfn;
        size_t tmp_size;
        const void *prop;
 
@@ -144,17 +143,9 @@ int __init ima_get_kexec_buffer(void **addr, size_t *size)
        if (!tmp_size)
                return -ENOENT;
 
-       /*
-        * Calculate the PFNs for the buffer and ensure
-        * they are with in addressable memory.
-        */
-       start_pfn = PHYS_PFN(tmp_addr);
-       end_pfn = PHYS_PFN(tmp_addr + tmp_size - 1);
-       if (!page_is_ram(start_pfn) || !page_is_ram(end_pfn)) {
-               pr_warn("IMA buffer at 0x%lx, size = 0x%zx beyond memory\n",
-                       tmp_addr, tmp_size);
-               return -EINVAL;
-       }
+       ret = ima_validate_range(tmp_addr, tmp_size);
+       if (ret)
+               return ret;
 
        *addr = __va(tmp_addr);
        *size = tmp_size;