From: Greg Kroah-Hartman Date: Thu, 17 Apr 2025 14:51:34 +0000 (+0200) Subject: 6.12-stable patches X-Git-Tag: v6.12.24~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5069d93f7be1168b25df6624b40e837520043df2;p=thirdparty%2Fkernel%2Fstable-queue.git 6.12-stable patches added patches: libbpf-prevent-compiler-warnings-errors.patch x86-e820-fix-handling-of-subpage-regions-when-calculating-nosave-ranges-in-e820__register_nosave_regions.patch --- diff --git a/queue-6.12/libbpf-prevent-compiler-warnings-errors.patch b/queue-6.12/libbpf-prevent-compiler-warnings-errors.patch new file mode 100644 index 0000000000..3a8d3af0d8 --- /dev/null +++ b/queue-6.12/libbpf-prevent-compiler-warnings-errors.patch @@ -0,0 +1,71 @@ +From 7f4ec77f3fee41dd6a41f03a40703889e6e8f7b2 Mon Sep 17 00:00:00 2001 +From: Eder Zulian +Date: Tue, 22 Oct 2024 19:23:28 +0200 +Subject: libbpf: Prevent compiler warnings/errors +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Eder Zulian + +commit 7f4ec77f3fee41dd6a41f03a40703889e6e8f7b2 upstream. + +Initialize 'new_off' and 'pad_bits' to 0 and 'pad_type' to NULL in +btf_dump_emit_bit_padding to prevent compiler warnings/errors which are +observed when compiling with 'EXTRA_CFLAGS=-g -Og' options, but do not +happen when compiling with current default options. + +For example, when compiling libbpf with + + $ make "EXTRA_CFLAGS=-g -Og" -C tools/lib/bpf/ clean all + +Clang version 17.0.6 and GCC 13.3.1 fail to compile btf_dump.c due to +following errors: + + btf_dump.c: In function ‘btf_dump_emit_bit_padding’: + btf_dump.c:903:42: error: ‘new_off’ may be used uninitialized [-Werror=maybe-uninitialized] + 903 | if (new_off > cur_off && new_off <= next_off) { + | ~~~~~~~~^~~~~~~~~~~ + btf_dump.c:870:13: note: ‘new_off’ was declared here + 870 | int new_off, pad_bits, bits, i; + | ^~~~~~~ + btf_dump.c:917:25: error: ‘pad_type’ may be used uninitialized [-Werror=maybe-uninitialized] + 917 | btf_dump_printf(d, "\n%s%s: %d;", pfx(lvl), pad_type, + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 918 | in_bitfield ? new_off - cur_off : 0); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + btf_dump.c:871:21: note: ‘pad_type’ was declared here + 871 | const char *pad_type; + | ^~~~~~~~ + btf_dump.c:930:20: error: ‘pad_bits’ may be used uninitialized [-Werror=maybe-uninitialized] + 930 | if (bits == pad_bits) { + | ^ + btf_dump.c:870:22: note: ‘pad_bits’ was declared here + 870 | int new_off, pad_bits, bits, i; + | ^~~~~~~~ + cc1: all warnings being treated as errors + +Signed-off-by: Eder Zulian +Signed-off-by: Andrii Nakryiko +Acked-by: Jiri Olsa +Link: https://lore.kernel.org/bpf/20241022172329.3871958-3-ezulian@redhat.com +Signed-off-by: He Zhe +Signed-off-by: Xiangyu Chen +Signed-off-by: Greg Kroah-Hartman +--- + tools/lib/bpf/btf_dump.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/tools/lib/bpf/btf_dump.c ++++ b/tools/lib/bpf/btf_dump.c +@@ -867,8 +867,8 @@ static void btf_dump_emit_bit_padding(co + } pads[] = { + {"long", d->ptr_sz * 8}, {"int", 32}, {"short", 16}, {"char", 8} + }; +- int new_off, pad_bits, bits, i; +- const char *pad_type; ++ int new_off = 0, pad_bits = 0, bits, i; ++ const char *pad_type = NULL; + + if (cur_off >= next_off) + return; /* no gap */ diff --git a/queue-6.12/series b/queue-6.12/series index bcfc44833b..8015f32ca0 100644 --- a/queue-6.12/series +++ b/queue-6.12/series @@ -385,3 +385,5 @@ acpi-platform-profile-fix-cfi-violation-when-accessing-sysfs-files.patch nfsd-fix-decoding-in-nfs4_xdr_dec_cb_getattr.patch nfsd-fix-cb_getattr-status-fix.patch nfsd-don-t-ignore-the-return-code-of-svc_proc_register.patch +x86-e820-fix-handling-of-subpage-regions-when-calculating-nosave-ranges-in-e820__register_nosave_regions.patch +libbpf-prevent-compiler-warnings-errors.patch diff --git a/queue-6.12/x86-e820-fix-handling-of-subpage-regions-when-calculating-nosave-ranges-in-e820__register_nosave_regions.patch b/queue-6.12/x86-e820-fix-handling-of-subpage-regions-when-calculating-nosave-ranges-in-e820__register_nosave_regions.patch new file mode 100644 index 0000000000..f366fcfa48 --- /dev/null +++ b/queue-6.12/x86-e820-fix-handling-of-subpage-regions-when-calculating-nosave-ranges-in-e820__register_nosave_regions.patch @@ -0,0 +1,89 @@ +From f2f29da9f0d4367f6ff35e0d9d021257bb53e273 Mon Sep 17 00:00:00 2001 +From: Myrrh Periwinkle +Date: Sun, 6 Apr 2025 11:45:22 +0700 +Subject: x86/e820: Fix handling of subpage regions when calculating nosave ranges in e820__register_nosave_regions() + +From: Myrrh Periwinkle + +commit f2f29da9f0d4367f6ff35e0d9d021257bb53e273 upstream. + +While debugging kexec/hibernation hangs and crashes, it turned out that +the current implementation of e820__register_nosave_regions() suffers from +multiple serious issues: + + - The end of last region is tracked by PFN, causing it to find holes + that aren't there if two consecutive subpage regions are present + + - The nosave PFN ranges derived from holes are rounded out (instead of + rounded in) which makes it inconsistent with how explicitly reserved + regions are handled + +Fix this by: + + - Treating reserved regions as if they were holes, to ensure consistent + handling (rounding out nosave PFN ranges is more correct as the + kernel does not use partial pages) + + - Tracking the end of the last RAM region by address instead of pages + to detect holes more precisely + +These bugs appear to have been introduced about ~18 years ago with the very +first version of e820_mark_nosave_regions(), and its flawed assumptions were +carried forward uninterrupted through various waves of rewrites and renames. + +[ mingo: Added Git archeology details, for kicks and giggles. ] + +Fixes: e8eff5ac294e ("[PATCH] Make swsusp avoid memory holes and reserved memory regions on x86_64") +Reported-by: Roberto Ricci +Tested-by: Roberto Ricci +Signed-off-by: Myrrh Periwinkle +Signed-off-by: Ingo Molnar +Cc: Rafael J. Wysocki +Cc: Ard Biesheuvel +Cc: H. Peter Anvin +Cc: Kees Cook +Cc: Linus Torvalds +Cc: David Woodhouse +Cc: Len Brown +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/r/20250406-fix-e820-nosave-v3-1-f3787bc1ee1d@qtmlabs.xyz +Closes: https://lore.kernel.org/all/Z4WFjBVHpndct7br@desktop0a/ +Signed-off-by: Myrrh Periwinkle +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/kernel/e820.c | 17 ++++++++--------- + 1 file changed, 8 insertions(+), 9 deletions(-) + +--- a/arch/x86/kernel/e820.c ++++ b/arch/x86/kernel/e820.c +@@ -754,22 +754,21 @@ void __init e820__memory_setup_extended( + void __init e820__register_nosave_regions(unsigned long limit_pfn) + { + int i; +- unsigned long pfn = 0; ++ u64 last_addr = 0; + + for (i = 0; i < e820_table->nr_entries; i++) { + struct e820_entry *entry = &e820_table->entries[i]; + +- if (pfn < PFN_UP(entry->addr)) +- register_nosave_region(pfn, PFN_UP(entry->addr)); +- +- pfn = PFN_DOWN(entry->addr + entry->size); +- + if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN) +- register_nosave_region(PFN_UP(entry->addr), pfn); ++ continue; + +- if (pfn >= limit_pfn) +- break; ++ if (last_addr < entry->addr) ++ register_nosave_region(PFN_DOWN(last_addr), PFN_UP(entry->addr)); ++ ++ last_addr = entry->addr + entry->size; + } ++ ++ register_nosave_region(PFN_DOWN(last_addr), limit_pfn); + } + + #ifdef CONFIG_ACPI