Skip to content

Commit 100193f

Browse files
committed
Merge tag 'dt-for-linus' of git://git.secretlab.ca/git/linux
Pull devicetree bugfix from Grant Likely: "Important bug fix for parsing 64-bit addresses on 32-bit platforms. Without this patch the kernel will try to use memory ranges that cannot be reached" * tag 'dt-for-linus' of git://git.secretlab.ca/git/linux: of: Check for phys_addr_t overflows in early_init_dt_add_memory_arch
2 parents 8addf0c + a67a6ed commit 100193f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/of/fdt.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,21 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
880880
const u64 phys_offset = __pa(PAGE_OFFSET);
881881
base &= PAGE_MASK;
882882
size &= PAGE_MASK;
883+
884+
if (sizeof(phys_addr_t) < sizeof(u64)) {
885+
if (base > ULONG_MAX) {
886+
pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
887+
base, base + size);
888+
return;
889+
}
890+
891+
if (base + size > ULONG_MAX) {
892+
pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
893+
ULONG_MAX, base + size);
894+
size = ULONG_MAX - base;
895+
}
896+
}
897+
883898
if (base + size < phys_offset) {
884899
pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
885900
base, base + size);

0 commit comments

Comments
 (0)