| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/07 17:56 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": [
"MEMORY_FAILURE",
"KEXEC",
"KEXEC_FILE"
],
"FocusSymbols": [
"sanity_check_segment_list",
"kexec_locate_mem_hole",
"range_first_hwpoison",
"range_last_hwpoison"
],
"KMSANReasoning": "The patch introduces logic to avoid hardware-poisoned memory pages during kexec operations by checking if the target physical memory ranges contain poisoned pages. It does not introduce any new data structures copied to user space, nor does it allocate or manipulate memory buffers in a way that could expose uninitialized memory. The changes are purely related to physical memory management and kexec segment placement. Therefore, there is no risk of uninitialized memory usage or info-leaks that would require KMSAN to detect.",
"NeedsKMSAN": false,
"Reasoning": "The patch adds hardware-poisoned memory checks to kexec segment loading and memory hole location logic. These changes are reachable via the kexec_load and kexec_file_load system calls, and hardware poisoning can be simulated in virtualized environments (e.g., via madvise MADV_HWPOISON). Therefore, the functional changes are testable and worth fuzzing.",
"WorthFuzzing": true
} |
| 1/1 | 2026/08/07 17:56 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 4599f069b01276d9290dc69ec87c1ffe67189e70\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Fri Aug 7 17:56:43 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/linux/mm.h b/include/linux/mm.h\nindex 7fabe6c66b4b7..41b923901b193 100644\n--- a/include/linux/mm.h\n+++ b/include/linux/mm.h\n@@ -5192,6 +5192,8 @@ extern const struct attribute_group memory_failure_attr_group;\n extern void memory_failure_queue(unsigned long pfn, int flags);\n void num_poisoned_pages_inc(unsigned long pfn);\n void num_poisoned_pages_sub(unsigned long pfn, long i);\n+phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size);\n+phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size);\n #else\n static inline void memory_failure_queue(unsigned long pfn, int flags)\n {\n@@ -5204,6 +5206,18 @@ static inline void num_poisoned_pages_inc(unsigned long pfn)\n static inline void num_poisoned_pages_sub(unsigned long pfn, long i)\n {\n }\n+\n+static inline phys_addr_t range_first_hwpoison(phys_addr_t start,\n+\t\t\t\t\t unsigned long size)\n+{\n+\treturn PHYS_ADDR_MAX;\n+}\n+\n+static inline phys_addr_t range_last_hwpoison(phys_addr_t start,\n+\t\t\t\t\t unsigned long size)\n+{\n+\treturn PHYS_ADDR_MAX;\n+}\n #endif\n \n #if defined(CONFIG_MEMORY_FAILURE) \u0026\u0026 defined(CONFIG_MEMORY_HOTPLUG)\ndiff --git a/kernel/kexec_core.c b/kernel/kexec_core.c\nindex dc770b9a6d053..e097e980b1439 100644\n--- a/kernel/kexec_core.c\n+++ b/kernel/kexec_core.c\n@@ -212,6 +212,16 @@ int sanity_check_segment_list(struct kimage *image)\n \t}\n #endif\n \n+\t/*\n+\t * Reject destinations that land on hardware-poisoned memory: the\n+\t * relocation copy would machine-check on the bad frame.\n+\t */\n+\tfor (i = 0; i \u003c nr_segments; i++) {\n+\t\tif (range_first_hwpoison(image-\u003esegment[i].mem,\n+\t\t\t\t\t image-\u003esegment[i].memsz) != PHYS_ADDR_MAX)\n+\t\t\treturn -EADDRNOTAVAIL;\n+\t}\n+\n \t/*\n \t * The destination addresses are searched from system RAM rather than\n \t * being allocated from the buddy allocator, so they are not guaranteed\ndiff --git a/kernel/kexec_file.c b/kernel/kexec_file.c\nindex 59fb9d71e9d86..9ba6cc01af929 100644\n--- a/kernel/kexec_file.c\n+++ b/kernel/kexec_file.c\n@@ -475,6 +475,7 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,\n {\n \tstruct kimage *image = kbuf-\u003eimage;\n \tunsigned long temp_start, temp_end;\n+\tphys_addr_t poison;\n \n \ttemp_end = min(end, kbuf-\u003ebuf_max);\n \ttemp_start = temp_end - kbuf-\u003ememsz + 1;\n@@ -504,6 +505,15 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,\n \t\t\tcontinue;\n \t\t}\n \n+\t\tpoison = range_first_hwpoison(temp_start, kbuf-\u003ememsz);\n+\t\tif (poison != PHYS_ADDR_MAX) {\n+\t\t\t/* we hit a poisoned page */\n+\t\t\tif (poison \u003c kbuf-\u003ememsz)\n+\t\t\t\treturn 0;\n+\t\t\ttemp_start = poison - kbuf-\u003ememsz;\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\t/* We found a suitable memory range */\n \t\tbreak;\n \t} while (1);\n@@ -520,6 +530,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,\n {\n \tstruct kimage *image = kbuf-\u003eimage;\n \tunsigned long temp_start, temp_end;\n+\tphys_addr_t poison;\n \n \ttemp_start = max(start, kbuf-\u003ebuf_min);\n \n@@ -546,6 +557,13 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,\n \t\t\tcontinue;\n \t\t}\n \n+\t\tpoison = range_last_hwpoison(temp_start, kbuf-\u003ememsz);\n+\t\tif (poison != PHYS_ADDR_MAX) {\n+\t\t\t/* we hit a poisoned page */\n+\t\t\ttemp_start = poison + PAGE_SIZE;\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\t/* We found a suitable memory range */\n \t\tbreak;\n \t} while (1);\ndiff --git a/mm/memory-failure.c b/mm/memory-failure.c\nindex a8b03e2920ba8..c485e205fb633 100644\n--- a/mm/memory-failure.c\n+++ b/mm/memory-failure.c\n@@ -96,6 +96,78 @@ void num_poisoned_pages_sub(unsigned long pfn, long i)\n \t\tmemblk_nr_poison_sub(pfn, i);\n }\n \n+/*\n+ * Return the first or the last hardware-poisoned online page in [start,\n+ * start + size), or PHYS_ADDR_MAX if the range is clean.\n+ */\n+static phys_addr_t range_hwpoison(phys_addr_t start, unsigned long size,\n+\t\t\t\t bool first)\n+{\n+\tphys_addr_t poison = PHYS_ADDR_MAX;\n+\tunsigned long pfn, end_pfn;\n+\n+\tif (!size || !atomic_long_read(\u0026num_poisoned_pages))\n+\t\treturn poison;\n+\n+\tend_pfn = PHYS_PFN(start + size - 1);\n+\tfor (pfn = PHYS_PFN(start); pfn \u003c= end_pfn; pfn++) {\n+\t\tstruct page *page = pfn_to_online_page(pfn);\n+\t\tstruct folio *folio;\n+\n+\t\tcond_resched();\n+\n+\t\tif (!page)\n+\t\t\tcontinue;\n+\n+\t\tfolio = page_folio(page);\n+\t\tif (folio_test_hugetlb(folio)) {\n+\t\t\t/*\n+\t\t\t * hugetlbfs is a bit special, given the poison\n+\t\t\t * information is at the folio, not at the page\n+\t\t\t */\n+\t\t\tunsigned long folio_end;\n+\n+\t\t\t/*\n+\t\t\t * No hugetlb_lock: the scan is racy either way, a frame\n+\t\t\t * can be poisoned right after it. Just don't let a folio\n+\t\t\t * dissolved under us walk the scan backwards.\n+\t\t\t */\n+\t\t\tfolio_end = folio_pfn(folio) + folio_nr_pages(folio) - 1;\n+\t\t\tfolio_end = max(folio_end, pfn);\n+\n+\t\t\tif (folio_test_hwpoison(folio)) {\n+\t\t\t\tif (first)\n+\t\t\t\t\treturn PFN_PHYS(pfn);\n+\t\t\t\tpoison = PFN_PHYS(min(folio_end, end_pfn));\n+\t\t\t}\n+\t\t\t/* skip all the pfns that belong to hugetlb */\n+\t\t\tpfn = folio_end;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (!PageHWPoison(page))\n+\t\t\t/* page is good, let's go to the next one */\n+\t\t\tcontinue;\n+\n+\t\tif (first)\n+\t\t\treturn PFN_PHYS(pfn);\n+\n+\t\tpoison = PFN_PHYS(pfn);\n+\t}\n+\n+\treturn poison;\n+}\n+\n+phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size)\n+{\n+\treturn range_hwpoison(start, size, true);\n+}\n+\n+phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size)\n+{\n+\treturn range_hwpoison(start, size, false);\n+}\n+\n /**\n * MF_ATTR_RO - Create sysfs entry for each memory failure statistics.\n * @_name: name of the file in the per NUMA sysfs directory.\n"
} |
| 2/1 | 2026/08/07 17:56 | agent | patch-evaluator |
0mModel:best-expensive Args: null Results: {
"EnableConfigs": [
"MEMORY_FAILURE",
"KEXEC",
"KEXEC_FILE"
],
"FocusSymbols": [
"sanity_check_segment_list",
"kexec_locate_mem_hole",
"range_first_hwpoison",
"range_last_hwpoison"
],
"Reasoning": "The patch adds hardware-poisoned memory checks to kexec segment loading and memory hole location logic. These changes are reachable via the kexec_load and kexec_file_load system calls, and hardware poisoning can be simulated in virtualized environments (e.g., via madvise MADV_HWPOISON). Therefore, the functional changes are testable and worth fuzzing.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). - Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU. - Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove) that are executed only during PCI hot-unplug or sysfs driver unbind operations. If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. Prefer non-static, non-inlined API entrypoint functions over internal static helper functions (which are inlined by the compiler and do not have distinct symbol addresses). 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 4599f069b01276d9290dc69ec87c1ffe67189e70
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Aug 7 17:56:43 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7fabe6c66b4b7..41b923901b193 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -5192,6 +5192,8 @@ extern const struct attribute_group memory_failure_attr_group;
extern void memory_failure_queue(unsigned long pfn, int flags);
void num_poisoned_pages_inc(unsigned long pfn);
void num_poisoned_pages_sub(unsigned long pfn, long i);
+phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size);
+phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size);
#else
static inline void memory_failure_queue(unsigned long pfn, int flags)
{
@@ -5204,6 +5206,18 @@ static inline void num_poisoned_pages_inc(unsigned long pfn)
static inline void num_poisoned_pages_sub(unsigned long pfn, long i)
{
}
+
+static inline phys_addr_t range_first_hwpoison(phys_addr_t start,
+ unsigned long size)
+{
+ return PHYS_ADDR_MAX;
+}
+
+static inline phys_addr_t range_last_hwpoison(phys_addr_t start,
+ unsigned long size)
+{
+ return PHYS_ADDR_MAX;
+}
#endif
#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index dc770b9a6d053..e097e980b1439 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -212,6 +212,16 @@ int sanity_check_segment_list(struct kimage *image)
}
#endif
+ /*
+ * Reject destinations that land on hardware-poisoned memory: the
+ * relocation copy would machine-check on the bad frame.
+ */
+ for (i = 0; i < nr_segments; i++) {
+ if (range_first_hwpoison(image->segment[i].mem,
+ image->segment[i].memsz) != PHYS_ADDR_MAX)
+ return -EADDRNOTAVAIL;
+ }
+
/*
* The destination addresses are searched from system RAM rather than
* being allocated from the buddy allocator, so they are not guaranteed
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 59fb9d71e9d86..9ba6cc01af929 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -475,6 +475,7 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
{
struct kimage *image = kbuf->image;
unsigned long temp_start, temp_end;
+ phys_addr_t poison;
temp_end = min(end, kbuf->buf_max);
temp_start = temp_end - kbuf->memsz + 1;
@@ -504,6 +505,15 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
continue;
}
+ poison = range_first_hwpoison(temp_start, kbuf->memsz);
+ if (poison != PHYS_ADDR_MAX) {
+ /* we hit a poisoned page */
+ if (poison < kbuf->memsz)
+ return 0;
+ temp_start = poison - kbuf->memsz;
+ continue;
+ }
+
/* We found a suitable memory range */
break;
} while (1);
@@ -520,6 +530,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
{
struct kimage *image = kbuf->image;
unsigned long temp_start, temp_end;
+ phys_addr_t poison;
temp_start = max(start, kbuf->buf_min);
@@ -546,6 +557,13 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
continue;
}
+ poison = range_last_hwpoison(temp_start, kbuf->memsz);
+ if (poison != PHYS_ADDR_MAX) {
+ /* we hit a poisoned page */
+ temp_start = poison + PAGE_SIZE;
+ continue;
+ }
+
/* We found a suitable memory range */
break;
} while (1);
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index a8b03e2920ba8..c485e205fb633 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -96,6 +96,78 @@ void num_poisoned_pages_sub(unsigned long pfn, long i)
memblk_nr_poison_sub(pfn, i);
}
+/*
+ * Return the first or the last hardware-poisoned online page in [start,
+ * start + size), or PHYS_ADDR_MAX if the range is clean.
+ */
+static phys_addr_t range_hwpoison(phys_addr_t start, unsigned long size,
+ bool first)
+{
+ phys_addr_t poison = PHYS_ADDR_MAX;
+ unsigned long pfn, end_pfn;
+
+ if (!size || !atomic_long_read(&num_poisoned_pages))
+ return poison;
+
+ end_pfn = PHYS_PFN(start + size - 1);
+ for (pfn = PHYS_PFN(start); pfn <= end_pfn; pfn++) {
+ struct page *page = pfn_to_online_page(pfn);
+ struct folio *folio;
+
+ cond_resched();
+
+ if (!page)
+ continue;
+
+ folio = page_folio(page);
+ if (folio_test_hugetlb(folio)) {
+ /*
+ * hugetlbfs is a bit special, given the poison
+ * information is at the folio, not at the page
+ */
+ unsigned long folio_end;
+
+ /*
+ * No hugetlb_lock: the scan is racy either way, a frame
+ * can be poisoned right after it. Just don't let a folio
+ * dissolved under us walk the scan backwards.
+ */
+ folio_end = folio_pfn(folio) + folio_nr_pages(folio) - 1;
+ folio_end = max(folio_end, pfn);
+
+ if (folio_test_hwpoison(folio)) {
+ if (first)
+ return PFN_PHYS(pfn);
+ poison = PFN_PHYS(min(folio_end, end_pfn));
+ }
+ /* skip all the pfns that belong to hugetlb */
+ pfn = folio_end;
+ continue;
+ }
+
+ if (!PageHWPoison(page))
+ /* page is good, let's go to the next one */
+ continue;
+
+ if (first)
+ return PFN_PHYS(pfn);
+
+ poison = PFN_PHYS(pfn);
+ }
+
+ return poison;
+}
+
+phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size)
+{
+ return range_hwpoison(start, size, true);
+}
+
+phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size)
+{
+ return range_hwpoison(start, size, false);
+}
+
/**
* MF_ATTR_RO - Create sysfs entry for each memory failure statistics.
* @_name: name of the file in the per NUMA sysfs directory.
|
| 3/2 | 2026/08/07 17:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 3930 output: 37 thoughts: 404 Thoughts: **Fuzzing the Hardware Poisoning Checks in kexec** Okay, so we have this patch, and it looks like it's adding some critical checks for hardware-poisoned memory within kexec. It's touching `kexec_core.c`, `kexec_file.c`, and `mm/memory-failure.c`, which tells me it's potentially quite significant. It introduces those `range_first_hwpoison` and `range_last_hwpoison` functions, and they're being used in `sanity_check_segment_list` (kexec_core.c) and the hole-finding functions `locate_mem_hole_top_down` and `locate_mem_hole_bottom_up` (kexec_file.c). My immediate thought is, can we actually *reach* this code in a virtualized environment? Hardware poisoning can be simulated, either through `sysfs` or `madvise(MADV_HWPOISON)`. And, yes, the kexec system calls themselves – `kexec_load`, `kexec_file_load` – are definitely accessible and testable in something like QEMU. That makes this a prime target for fuzzing. Now, let's get specific. What are the key functions to focus on? Alright, `sanity_check_segment_list` in `kexec_core.c` is definitely modified. Then, in `kexec_file.c`, we have `locate_mem_hole_top_down` and `locate_mem_hole_bottom_up`. And of course, the new `range_first_hwpoison` and `range_last_hwpoison` functions in `mm/memory-failure.c` are vital for initial analysis. Let me just quickly check something. Is `sanity_check_segment_list` static or not? Good, it's non-static. The hole-finding functions are, however, static, which means they are probably only called from within kexec_file.c, probably by something like `kexec_walk_memblock`. Better check that and make sure. Okay, I'll dive into `kexec_file.c` to see how those are invoked. |
| 4/2 | 2026/08/07 17:56 | tool | grepper |
0mArgs:{
"Expression": "locate_mem_hole_top_down",
"PathPrefix": "kernel/kexec_file.c"
}Results: {
"Output": "kernel/kexec_file.c=365=SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,\n--\nkernel/kexec_file.c-472-\nkernel/kexec_file.c:473:static int locate_mem_hole_top_down(unsigned long start, unsigned long end,\nkernel/kexec_file.c-474-\t\t\t\t struct kexec_buf *kbuf)\n--\nkernel/kexec_file.c=578=static int locate_mem_hole_callback(struct resource *res, void *arg)\n--\nkernel/kexec_file.c-600-\tif (kbuf-\u003etop_down)\nkernel/kexec_file.c:601:\t\treturn locate_mem_hole_top_down(start, end, kbuf);\nkernel/kexec_file.c-602-\treturn locate_mem_hole_bottom_up(start, end, kbuf);\n"
} |
| 5/2 | 2026/08/07 17:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 5106 output: 35 thoughts: 16 Thoughts: **My Inquiry About `locate_mem_hole_callback`** Okay, so I'm looking at this `locate_mem_hole_callback` function, and the first thing that jumps out at me is that it's declared as `static`. This immediately triggers a mental query: who or what is calling *this* specific function? That `static` keyword suggests it's likely scoped within a single compilation unit, which means its visibility and potential callers are limited. I need to trace the call paths to understand its role within the larger memory management scheme. I'll need to use my debugging tools to identify the function or module that's invoking it. Understanding *where* this callback is being used is crucial to understanding *why* it exists and its impact on performance and correctness. Time to dig in and find those call sites! |
| 6/2 | 2026/08/07 17:56 | tool | grepper |
0mArgs:{
"Expression": "locate_mem_hole_callback",
"PathPrefix": "kernel/kexec_file.c"
}Results: {
"Output": "kernel/kexec_file.c=528=static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,\n--\nkernel/kexec_file.c-577-\nkernel/kexec_file.c:578:static int locate_mem_hole_callback(struct resource *res, void *arg)\nkernel/kexec_file.c-579-{\n--\nkernel/kexec_file.c=606=static int kexec_walk_memblock(struct kexec_buf *kbuf,\n--\nkernel/kexec_file.c-621-\t * IORESOURCE_SYSRAM_DRIVER_MANAGED handling in\nkernel/kexec_file.c:622:\t * locate_mem_hole_callback().\nkernel/kexec_file.c-623-\t */\n--\nkernel/kexec_file.c=734=int kexec_locate_mem_hole(struct kexec_buf *kbuf)\n--\nkernel/kexec_file.c-745-\t */\nkernel/kexec_file.c:746:\tret = kho_locate_mem_hole(kbuf, locate_mem_hole_callback);\nkernel/kexec_file.c-747-\tif (ret \u003c= 0)\n--\nkernel/kexec_file.c-757-\tif (!IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))\nkernel/kexec_file.c:758:\t\tret = kexec_walk_resources(kbuf, locate_mem_hole_callback);\nkernel/kexec_file.c-759-\telse\nkernel/kexec_file.c:760:\t\tret = kexec_walk_memblock(kbuf, locate_mem_hole_callback);\nkernel/kexec_file.c-761-\n"
} |
| 7/2 | 2026/08/07 17:56 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 5791 output: 35 thoughts: 29 Thoughts: Here's my take on those thoughts: **Analyzing `kexec_locate_mem_hole` and Segment Lists** Okay, so I'm looking at `kexec_locate_mem_hole`, and the first thing that jumps out is that it's *not* a static function. That immediately makes me think about potential visibility and usage throughout the kernel, which I need to keep in mind for any analysis. It's a key function, if not local to a module. I need to understand where else this is used. Next, I want to take a look at `sanity_check_segment_list`. Considering the name, I'd bet it's involved in validating the segments of memory the system's working with. This function's probably critical to making sure the memory maps are correct before or after a kexec reboot, so the system doesn't crash or get corrupted. I bet it makes sure there aren't conflicting memory regions or holes that could cause problems. Definitely going to want to understand what conditions would trigger any issues there, to look for vulnerabilities. It's a key piece of the puzzle here. |
| 8/2 | 2026/08/07 17:57 | tool | grepper |
0mArgs:{
"Expression": "sanity_check_segment_list",
"PathPrefix": "kernel/kexec_core.c"
}Results: {
"Output": "kernel/kexec_core.c=106=static struct page *kimage_alloc_page(struct kimage *image,\n--\nkernel/kexec_core.c-109-\nkernel/kexec_core.c:110:int sanity_check_segment_list(struct kimage *image)\nkernel/kexec_core.c-111-{\n"
} |
| 9/2 | 2026/08/07 17:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 6197 output: 25 thoughts: 506 Thoughts: **Analyzing Patch Dependencies for Memory Failure and Kexec Functionality**
Okay, so I've identified a few key symbols here: `sanity_check_segment_list`, `kexec_locate_mem_hole`, and, specifically within `mm/memory-failure.c`, `range_first_hwpoison` and `range_last_hwpoison`. I need to verify the necessary configuration options. My first instinct is to check `include/linux/mm.h`.
Looking at the code, I see a conditional block:
```c
#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)
```
However, the patch I'm examining *only* includes `range_first_hwpoison` and `range_last_hwpoison` under an `#ifdef CONFIG_MEMORY_FAILURE`. I need to confirm this. Let me double-check the patch itself against `include/linux/mm.h`.
Ah, here's the relevant section from the patch:
```c
@@ -5192,6 +5192,8 @@ extern const struct attribute_group memory_failure_attr_group;
extern void memory_failure_queue(unsigned long pfn, int flags);
void num_poisoned_pages_inc(unsigned long pfn);
void num_poisoned_pages_sub(unsigned long pfn, long i);
+phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size);
+phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size);
#else
static inline void memory_failure_queue(unsigned long pfn, int flags)
{
@@ -5204,6 +5206,18 @@ static inline void num_poisoned_pages_inc(unsigned long pfn)
static inline void num_poisoned_pages_sub(unsigned long pfn, long i)
{
}
+
+static inline phys_addr_t range_first_hwpoison(phys_addr_t start,
+ unsigned long size)
+{
+ return PHYS_ADDR_MAX;
+}
+
+static inline phys_addr_t range_last_hwpoison(phys_addr_t start,
+ unsigned long size)
+{
+ return PHYS_ADDR_MAX;
+}
#endif
```
Yes, that confirms it: `CONFIG_MEMORY_FAILURE` is the *primary* dependency for these functions. To test the kexec-related components, I'll also need to verify that `CONFIG_KEXEC` and `CONFIG_KEXEC_FILE` are enabled as well.
|
| 10/2 | 2026/08/07 17:57 | tool | grepper |
0mArgs:{
"Expression": "config MEMORY_FAILURE",
"PathPrefix": ""
}Results: {
"Output": "mm/Kconfig=762=config ARCH_SUPPORTS_MEMORY_FAILURE\n--\nmm/Kconfig-764-\nmm/Kconfig:765:config MEMORY_FAILURE\nmm/Kconfig-766-\tdepends on MMU\n"
} |
| 11/2 | 2026/08/07 17:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 7397 output: 23 thoughts: 10 Thoughts: Okay, let's dive into this. Here's my thought process on this: **Examining kexec Configurations** Alright, the next logical step in this investigation is to specifically examine the `kexec` configurations. I need to understand how the system is set up to handle kernel transitions. This is crucial because `kexec` is the mechanism we use for quickly switching between kernels, and if there's a problem there, it could explain the observed behavior. I'll need to look at the relevant configuration files and maybe even some kernel parameters that control `kexec`'s operation. I want to see how it's being invoked, what kernels it's pointing to, and if there are any obvious misconfigurations or potential conflicts. I'm thinking I'll start with `/etc/kexec.conf` (or wherever the distribution places it), and I'll probably also check the kernel command-line for anything interesting related to `kexec` options. This needs to be a focused exploration, looking for anything that might prevent a smooth kernel swap or introduce instability during the transition. I'll need to keep in mind possible interactions with the bootloader too, like GRUB, as this can play a significant role. |
| 12/2 | 2026/08/07 17:57 | tool | grepper |
0mArgs:{
"Expression": "config KEXEC",
"PathPrefix": ""
}Results: {
"Output": "kernel/Kconfig.kexec=8=config VMCORE_INFO\n--\nkernel/Kconfig.kexec-10-\nkernel/Kconfig.kexec:11:config KEXEC_CORE\nkernel/Kconfig.kexec-12-\tbool\nkernel/Kconfig.kexec-13-\nkernel/Kconfig.kexec:14:config KEXEC_ELF\nkernel/Kconfig.kexec-15-\tbool\n--\nkernel/Kconfig.kexec=17=config HAVE_IMA_KEXEC\n--\nkernel/Kconfig.kexec-19-\nkernel/Kconfig.kexec:20:config KEXEC\nkernel/Kconfig.kexec-21-\tbool \"Enable kexec system call\"\n--\nkernel/Kconfig.kexec-37-\nkernel/Kconfig.kexec:38:config KEXEC_FILE\nkernel/Kconfig.kexec-39-\tbool \"Enable kexec file based system call\"\n--\nkernel/Kconfig.kexec-48-\nkernel/Kconfig.kexec:49:config KEXEC_SIG\nkernel/Kconfig.kexec-50-\tbool \"Verify kernel signature during kexec_file_load() syscall\"\n--\nkernel/Kconfig.kexec-62-\nkernel/Kconfig.kexec:63:config KEXEC_SIG_FORCE\nkernel/Kconfig.kexec-64-\tbool \"Require a valid signature in kexec_file_load() syscall\"\n--\nkernel/Kconfig.kexec-70-\nkernel/Kconfig.kexec:71:config KEXEC_IMAGE_VERIFY_SIG\nkernel/Kconfig.kexec-72-\tbool \"Enable Image signature verification support (ARM)\"\n--\nkernel/Kconfig.kexec-79-\nkernel/Kconfig.kexec:80:config KEXEC_BZIMAGE_VERIFY_SIG\nkernel/Kconfig.kexec-81-\tbool \"Enable bzImage signature verification support\"\n--\nkernel/Kconfig.kexec-88-\nkernel/Kconfig.kexec:89:config KEXEC_JUMP\nkernel/Kconfig.kexec-90-\tbool \"kexec jump\"\n--\nkernel/liveupdate/Kconfig=3=menu \"Live Update and Kexec HandOver\"\nkernel/liveupdate/Kconfig-4-\nkernel/liveupdate/Kconfig:5:config KEXEC_HANDOVER\nkernel/liveupdate/Kconfig-6-\tbool \"kexec handover\"\n--\nkernel/liveupdate/Kconfig-17-\nkernel/liveupdate/Kconfig:18:config KEXEC_HANDOVER_DEBUG\nkernel/liveupdate/Kconfig-19-\tbool \"Enable Kexec Handover debug checks\"\n--\nkernel/liveupdate/Kconfig-26-\nkernel/liveupdate/Kconfig:27:config KEXEC_HANDOVER_DEBUGFS\nkernel/liveupdate/Kconfig-28-\tbool \"kexec handover debugfs interface\"\n--\nkernel/liveupdate/Kconfig-37-\nkernel/liveupdate/Kconfig:38:config KEXEC_HANDOVER_ENABLE_DEFAULT\nkernel/liveupdate/Kconfig-39-\tbool \"Enable kexec handover by default\"\n"
} |
| 13/2 | 2026/08/07 17:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 8459 output: 36 thoughts: 720 Thoughts: **My Analysis of Kexec and Memory Failure Integration** Okay, so I'm zeroing in on this kexec and memory failure integration. Let's start with the configurations. I see that the relevant configs are `MEMORY_FAILURE`, `KEXEC`, and `KEXEC_FILE`. Those are the core enablers. Now, for the key functions, here's what I've identified as critical to examine: * `sanity_check_segment_list` * `kexec_locate_mem_hole` * `range_first_hwpoison` * `range_last_hwpoison` I quickly double-checked that `range_first_hwpoison` and `range_last_hwpoison` are, in fact, non-static. Yes, they are in `mm/memory-failure.c`. Good, that means they're exported and accessible. I scanned for any other relevant configs, but `MEMORY_FAILURE` depends on `MMU`, which is standard. `KEXEC` and `KEXEC_FILE` are also typical, so no surprises there. I started digging deeper into functions. `sanity_check_segment_list` is in `kexec_core.c` and `kexec_locate_mem_hole` is in `kexec_file.c`. Wait, about `kexec_locate_mem_hole`. I need to be careful here because, directly, it looks like `locate_mem_hole_top_down` and `locate_mem_hole_bottom_up` were modified which are static. However, `kexec_locate_mem_hole` is a good proxy because it calls `locate_mem_hole_callback` which then calls the static functions. Okay. I also considered `kexec_walk_memblock` and `kexec_walk_resources`, but they're not the primary focus here. Focusing on `sanity_check_segment_list`, it appears to be called by `kimage_alloc_init`, which itself is called by `do_kexec_load`. So, to summarize my critical targets: * `sanity_check_segment_list` (kexec\_core.c) * `kexec_locate_mem_hole` (kexec\_file.c) * `range_first_hwpoison` (mm/memory-failure.c) * `range_last_hwpoison` (mm/memory-failure.c) The Relevant configs I am focusing on are: * `MEMORY_FAILURE` * `KEXEC` * `KEXEC_FILE` My reasoning? The patch introduces checks for hardware-poisoned memory during kexec segment loading and memory hole location. These changes are reachable through system calls, specifically `kexec_load` and `kexec_file_load`. The thing is, this can be simulated in virtualized environments using madvise's MADV_HWPOISON, so this is testable and fuzzing these points seems very worthwhile. Okay, let me quickly verify that `kexec_locate_mem_hole` is actually defined where I expect it to be. |
| 14/2 | 2026/08/07 17:57 | tool | grepper |
0mArgs:{
"Expression": "kexec_locate_mem_hole",
"PathPrefix": "kernel/kexec_file.c"
}Results: {
"Output": "kernel/kexec_file.c=689=static int kexec_alloc_contig(struct kexec_buf *kbuf)\n--\nkernel/kexec_file.c-726-/**\nkernel/kexec_file.c:727: * kexec_locate_mem_hole - find free memory for the purgatory or the next kernel\nkernel/kexec_file.c-728- * @kbuf:\tParameters for the memory search.\n--\nkernel/kexec_file.c-733- */\nkernel/kexec_file.c:734:int kexec_locate_mem_hole(struct kexec_buf *kbuf)\nkernel/kexec_file.c-735-{\n--\nkernel/kexec_file.c=775=int kexec_add_buffer(struct kexec_buf *kbuf)\n--\nkernel/kexec_file.c-804-\t/* Walk the RAM ranges and allocate a suitable range for the buffer */\nkernel/kexec_file.c:805:\tret = arch_kexec_locate_mem_hole(kbuf);\nkernel/kexec_file.c-806-\tif (ret)\n"
} |
| 15/2 | 2026/08/07 17:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 10208 output: 35 thoughts: 35 Thoughts: Okay, here's my summary, presented as a stream of thought: **Confirming Function Existence for Kernel Boot Operations** Alright, let's see. First, I remember that `kexec_locate_mem_hole` is indeed a function in the kernel and, more importantly for this particular scenario, it isn't defined as static. That's good; it confirms that it's accessible externally, which is essential for what I'm planning. Now, just to be absolutely certain and to avoid any silly misinterpretations down the line, I'm going to quickly double-check the existence of `sanity_check_segment_list`. I need to ensure that specific function is also present and available, as it's a critical component in this part of the boot process. Better safe than sorry, and a quick check now can save a headache later. |
| 16/2 | 2026/08/07 17:57 | tool | grepper |
0mArgs:{
"Expression": "sanity_check_segment_list",
"PathPrefix": "kernel/kexec_core.c"
}Results: {
"Output": "kernel/kexec_core.c=106=static struct page *kimage_alloc_page(struct kimage *image,\n--\nkernel/kexec_core.c-109-\nkernel/kexec_core.c:110:int sanity_check_segment_list(struct kimage *image)\nkernel/kexec_core.c-111-{\n"
} |
| 17/2 | 2026/08/07 17:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 10563 output: 33 thoughts: 29 Thoughts: Okay, here's my summary, presented as a direct, internal monologue, aimed at a colleague: **Verification Check: Poison Ranges** Right, so it's confirmed. This thing *does* exist. Now, before we go any further, I need to absolutely nail down these range definitions. Let's make sure that `range_first_hwpoison` and `range_last_hwpoison` are, in fact, present. I need to guarantee their existence before relying on them. We don't want any surprises when we start moving forward on this particular project. Let’s confirm before we start any assumptions. |
| 18/2 | 2026/08/07 17:57 | tool | grepper |
0mArgs:{
"Expression": "range_first_hwpoison",
"PathPrefix": "mm/memory-failure.c"
}Results: {
"Output": "mm/memory-failure.c=103=static phys_addr_t range_hwpoison(phys_addr_t start, unsigned long size,\n--\nmm/memory-failure.c-160-\nmm/memory-failure.c:161:phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size)\nmm/memory-failure.c-162-{\n"
} |
| 19/2 | 2026/08/07 17:57 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 10868 output: 164 thoughts: 15 Thoughts: Here's your summary: **The Reality of the Data** Okay, so yes, the results are definitely there. I can see the data and confirm the output. Now that I have confirmation, my next step is clear. I'm going to formulate that `set-results` call, precisely and efficiently. I'll make sure it's structured in the optimal way for the system to process the information, considering all the relevant parameters and ensuring the correct linkage. It's time to build the next layer of this process. |
| 20/2 | 2026/08/07 17:57 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"MEMORY_FAILURE",
"KEXEC",
"KEXEC_FILE"
],
"FocusSymbols": [
"sanity_check_segment_list",
"kexec_locate_mem_hole",
"range_first_hwpoison",
"range_last_hwpoison"
],
"Reasoning": "The patch adds hardware-poisoned memory checks to kexec segment loading and memory hole location logic. These changes are reachable via the kexec_load and kexec_file_load system calls, and hardware poisoning can be simulated in virtualized environments (e.g., via madvise MADV_HWPOISON). Therefore, the functional changes are testable and worth fuzzing.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"MEMORY_FAILURE",
"KEXEC",
"KEXEC_FILE"
],
"FocusSymbols": [
"sanity_check_segment_list",
"kexec_locate_mem_hole",
"range_first_hwpoison",
"range_last_hwpoison"
],
"Reasoning": "The patch adds hardware-poisoned memory checks to kexec segment loading and memory hole location logic. These changes are reachable via the kexec_load and kexec_file_load system calls, and hardware poisoning can be simulated in virtualized environments (e.g., via madvise MADV_HWPOISON). Therefore, the functional changes are testable and worth fuzzing.",
"WorthFuzzing": true
} |
| 21/1 | 2026/08/07 17:57 | action | If |
0mArgs:{
"WorthFuzzing": true
}Results: null |
| 22/2 | 2026/08/07 17:57 | agent | kmsan-evaluator |
0mModel:best-expensive Args: null Results: {
"KMSANReasoning": "The patch introduces logic to avoid hardware-poisoned memory pages during kexec operations by checking if the target physical memory ranges contain poisoned pages. It does not introduce any new data structures copied to user space, nor does it allocate or manipulate memory buffers in a way that could expose uninitialized memory. The changes are purely related to physical memory management and kexec segment placement. Therefore, there is no risk of uninitialized memory usage or info-leaks that would require KMSAN to detect.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: For your convenience, here is the diff of the changes:
commit 4599f069b01276d9290dc69ec87c1ffe67189e70
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Aug 7 17:56:43 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7fabe6c66b4b7..41b923901b193 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -5192,6 +5192,8 @@ extern const struct attribute_group memory_failure_attr_group;
extern void memory_failure_queue(unsigned long pfn, int flags);
void num_poisoned_pages_inc(unsigned long pfn);
void num_poisoned_pages_sub(unsigned long pfn, long i);
+phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size);
+phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size);
#else
static inline void memory_failure_queue(unsigned long pfn, int flags)
{
@@ -5204,6 +5206,18 @@ static inline void num_poisoned_pages_inc(unsigned long pfn)
static inline void num_poisoned_pages_sub(unsigned long pfn, long i)
{
}
+
+static inline phys_addr_t range_first_hwpoison(phys_addr_t start,
+ unsigned long size)
+{
+ return PHYS_ADDR_MAX;
+}
+
+static inline phys_addr_t range_last_hwpoison(phys_addr_t start,
+ unsigned long size)
+{
+ return PHYS_ADDR_MAX;
+}
#endif
#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index dc770b9a6d053..e097e980b1439 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -212,6 +212,16 @@ int sanity_check_segment_list(struct kimage *image)
}
#endif
+ /*
+ * Reject destinations that land on hardware-poisoned memory: the
+ * relocation copy would machine-check on the bad frame.
+ */
+ for (i = 0; i < nr_segments; i++) {
+ if (range_first_hwpoison(image->segment[i].mem,
+ image->segment[i].memsz) != PHYS_ADDR_MAX)
+ return -EADDRNOTAVAIL;
+ }
+
/*
* The destination addresses are searched from system RAM rather than
* being allocated from the buddy allocator, so they are not guaranteed
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 59fb9d71e9d86..9ba6cc01af929 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -475,6 +475,7 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
{
struct kimage *image = kbuf->image;
unsigned long temp_start, temp_end;
+ phys_addr_t poison;
temp_end = min(end, kbuf->buf_max);
temp_start = temp_end - kbuf->memsz + 1;
@@ -504,6 +505,15 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
continue;
}
+ poison = range_first_hwpoison(temp_start, kbuf->memsz);
+ if (poison != PHYS_ADDR_MAX) {
+ /* we hit a poisoned page */
+ if (poison < kbuf->memsz)
+ return 0;
+ temp_start = poison - kbuf->memsz;
+ continue;
+ }
+
/* We found a suitable memory range */
break;
} while (1);
@@ -520,6 +530,7 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
{
struct kimage *image = kbuf->image;
unsigned long temp_start, temp_end;
+ phys_addr_t poison;
temp_start = max(start, kbuf->buf_min);
@@ -546,6 +557,13 @@ static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
continue;
}
+ poison = range_last_hwpoison(temp_start, kbuf->memsz);
+ if (poison != PHYS_ADDR_MAX) {
+ /* we hit a poisoned page */
+ temp_start = poison + PAGE_SIZE;
+ continue;
+ }
+
/* We found a suitable memory range */
break;
} while (1);
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index a8b03e2920ba8..c485e205fb633 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -96,6 +96,78 @@ void num_poisoned_pages_sub(unsigned long pfn, long i)
memblk_nr_poison_sub(pfn, i);
}
+/*
+ * Return the first or the last hardware-poisoned online page in [start,
+ * start + size), or PHYS_ADDR_MAX if the range is clean.
+ */
+static phys_addr_t range_hwpoison(phys_addr_t start, unsigned long size,
+ bool first)
+{
+ phys_addr_t poison = PHYS_ADDR_MAX;
+ unsigned long pfn, end_pfn;
+
+ if (!size || !atomic_long_read(&num_poisoned_pages))
+ return poison;
+
+ end_pfn = PHYS_PFN(start + size - 1);
+ for (pfn = PHYS_PFN(start); pfn <= end_pfn; pfn++) {
+ struct page *page = pfn_to_online_page(pfn);
+ struct folio *folio;
+
+ cond_resched();
+
+ if (!page)
+ continue;
+
+ folio = page_folio(page);
+ if (folio_test_hugetlb(folio)) {
+ /*
+ * hugetlbfs is a bit special, given the poison
+ * information is at the folio, not at the page
+ */
+ unsigned long folio_end;
+
+ /*
+ * No hugetlb_lock: the scan is racy either way, a frame
+ * can be poisoned right after it. Just don't let a folio
+ * dissolved under us walk the scan backwards.
+ */
+ folio_end = folio_pfn(folio) + folio_nr_pages(folio) - 1;
+ folio_end = max(folio_end, pfn);
+
+ if (folio_test_hwpoison(folio)) {
+ if (first)
+ return PFN_PHYS(pfn);
+ poison = PFN_PHYS(min(folio_end, end_pfn));
+ }
+ /* skip all the pfns that belong to hugetlb */
+ pfn = folio_end;
+ continue;
+ }
+
+ if (!PageHWPoison(page))
+ /* page is good, let's go to the next one */
+ continue;
+
+ if (first)
+ return PFN_PHYS(pfn);
+
+ poison = PFN_PHYS(pfn);
+ }
+
+ return poison;
+}
+
+phys_addr_t range_first_hwpoison(phys_addr_t start, unsigned long size)
+{
+ return range_hwpoison(start, size, true);
+}
+
+phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size)
+{
+ return range_hwpoison(start, size, false);
+}
+
/**
* MF_ATTR_RO - Create sysfs entry for each memory failure statistics.
* @_name: name of the file in the per NUMA sysfs directory.
|
| 23/3 | 2026/08/07 17:57 | llm | kmsan-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 3927 output: 124 thoughts: 482 Thoughts: **KMSAN Fuzzing Session Assessment** Okay, let's break this down. My initial assessment is that a dedicated KMSAN fuzzing session isn't justified for this patch series. We need to be thorough, but based on my understanding of KMSAN's purpose, this seems unlikely to trigger any relevant issues. The core of the patch revolves around the addition of `range_first_hwpoison` and `range_last_hwpoison` functions. These functions are being introduced to detect hardware-poisoned memory within a given range. They're being implemented and then incorporated into `kexec_core.c` and `kexec_file.c` to prevent kexec destinations from landing on problematic memory regions, specifically those with physical memory errors like ECC errors. This also enables skipping of those ranges when locating memory holes. Here's the change analysis, step by step: 1. We have declarations and stub implementations in `mm.h`. 2. In `kexec_core.c`, the patch is integrated into `sanity_check_segment_list` to prevent segments from landing on hardware-poisoned memory. 3. `kexec_file.c` utilizes the functions to adjust search ranges, preventing the selection of hardware-poisoned regions. 4. `mm/memory-failure.c` adds the `range_hwpoison` implementation, the core logic behind the hwpoison checks. Now, does this *expose* any uninitialized memory risks? That's the KMSAN question. Looking at it, I see: * No new structures are being passed to userspace. * No uninitialized variables are being used in conditional logic, which is a major KMSAN concern. * No complex data structures are being allocated or initialized where uninitialized fields could be read. * The code doesn't introduce any new bounds checks that might allow us to access uninitialized bytes in existing buffers. Basically, this patch is entirely about *avoiding* hardware-poisoned memory pages. This is a very different thing from uninitialized memory in the software sense, which is what KMSAN detects. These hardware-poisoned pages have nothing to do with software bugs of uninitialized memory. It's an issue of physical memory integrity, not software initialization. KASAN and LOCKDEP aren't really relevant here either, but KMSAN is definitely not the right tool for this job. Therefore, I'm going to mark this as `NeedsKMSAN=false`. The reasoning is that the patch focuses exclusively on identifying and avoiding hardware-poisoned memory pages and does not introduce or expose any new risks related to uninitialized memory in the software sense. |
| 24/3 | 2026/08/07 17:57 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch introduces logic to avoid hardware-poisoned memory pages during kexec operations by checking if the target physical memory ranges contain poisoned pages. It does not introduce any new data structures copied to user space, nor does it allocate or manipulate memory buffers in a way that could expose uninitialized memory. The changes are purely related to physical memory management and kexec segment placement. Therefore, there is no risk of uninitialized memory usage or info-leaks that would require KMSAN to detect.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch introduces logic to avoid hardware-poisoned memory pages during kexec operations by checking if the target physical memory ranges contain poisoned pages. It does not introduce any new data structures copied to user space, nor does it allocate or manipulate memory buffers in a way that could expose uninitialized memory. The changes are purely related to physical memory management and kexec segment placement. Therefore, there is no risk of uninitialized memory usage or info-leaks that would require KMSAN to detect.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|