| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/11/09 13:23 | flow | patch-triage |
3mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "All functions modified, added, or removed in this patch (cma_declare_contiguous_multi, cma_find_free_range, and cma_range_cmp) are marked __init and are exclusively called during early boot initialization (via mm_core_init_early() -\u003e hugetlb_cma_reserve()). All __init text and data are freed and unmapped by free_initmem() before userspace starts and syzkaller begins runtime syscall fuzzing. No runtime CMA logic, data structures, or post-boot execution paths are modified. Because the altered code is structurally unreachable during fuzzing, fuzzing with syzkaller is not warranted.",
"WorthFuzzing": false
} |
| 1/1 | 2026/11/09 13:23 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 004485537f6569208178db1559a6bfc920a98500\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Mon Nov 9 13:23:46 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/mm/cma.c b/mm/cma.c\nindex f61d52796f4ef7..ef0c49985067d2 100644\n--- a/mm/cma.c\n+++ b/mm/cma.c\n@@ -23,8 +23,8 @@\n #include \u003clinux/sizes.h\u003e\n #include \u003clinux/slab.h\u003e\n #include \u003clinux/string.h\u003e\n-#include \u003clinux/string_choices.h\u003e\n #include \u003clinux/log2.h\u003e\n+#include \u003clinux/sort.h\u003e\n #include \u003clinux/cma.h\u003e\n #include \u003clinux/highmem.h\u003e\n #include \u003clinux/io.h\u003e\n@@ -310,56 +310,6 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,\n \treturn 0;\n }\n \n-/*\n- * Structure used while walking physical memory ranges and finding out\n- * which one(s) to use for a CMA area.\n- */\n-struct cma_init_memrange {\n-\tphys_addr_t base;\n-\tphys_addr_t size;\n-\tstruct list_head list;\n-};\n-\n-/*\n- * Work array used during CMA initialization.\n- */\n-static struct cma_init_memrange memranges[CMA_MAX_RANGES] __initdata;\n-\n-static bool __init revsizecmp(struct cma_init_memrange *mlp,\n-\t\t\t struct cma_init_memrange *mrp)\n-{\n-\treturn mlp-\u003esize \u003e mrp-\u003esize;\n-}\n-\n-static bool __init basecmp(struct cma_init_memrange *mlp,\n-\t\t\t struct cma_init_memrange *mrp)\n-{\n-\treturn mlp-\u003ebase \u003c mrp-\u003ebase;\n-}\n-\n-/*\n- * Helper function to create sorted lists.\n- */\n-static void __init list_insert_sorted(\n-\tstruct list_head *ranges,\n-\tstruct cma_init_memrange *mrp,\n-\tbool (*cmp)(struct cma_init_memrange *lh, struct cma_init_memrange *rh))\n-{\n-\tstruct list_head *mp;\n-\tstruct cma_init_memrange *mlp;\n-\n-\tif (list_empty(ranges))\n-\t\tlist_add(\u0026mrp-\u003elist, ranges);\n-\telse {\n-\t\tlist_for_each(mp, ranges) {\n-\t\t\tmlp = list_entry(mp, struct cma_init_memrange, list);\n-\t\t\tif (cmp(mlp, mrp))\n-\t\t\t\tbreak;\n-\t\t}\n-\t\t__list_add(\u0026mrp-\u003elist, mlp-\u003elist.prev, \u0026mlp-\u003elist);\n-\t}\n-}\n-\n static int __init cma_fixed_reserve(phys_addr_t base, phys_addr_t size)\n {\n \tif (IS_ENABLED(CONFIG_HIGHMEM)) {\n@@ -524,37 +474,71 @@ static int __init __cma_declare_contiguous_nid(phys_addr_t *basep,\n \treturn 0;\n }\n \n+/*\n+ * Find the largest free range above 4G that can hold a part of a multi-range\n+ * CMA area.\n+ */\n+static phys_addr_t __init cma_find_free_range(phys_addr_t align,\n+\t\tphys_addr_t size_align, int nid, phys_addr_t *basep)\n+{\n+\tphys_addr_t start, end, size;\n+\tphys_addr_t max = 0;\n+\tu64 i;\n+\n+\tfor_each_free_mem_range(i, nid, MEMBLOCK_NONE, \u0026start, \u0026end, NULL) {\n+\t\tif (start \u003c SZ_4G)\n+\t\t\tcontinue;\n+\n+\t\tstart = ALIGN(start, align);\n+\t\tif (start \u003e= end)\n+\t\t\tcontinue;\n+\n+\t\tsize = ALIGN_DOWN(end - start, size_align);\n+\t\tif (size \u003e max) {\n+\t\t\tmax = size;\n+\t\t\t*basep = start;\n+\t\t}\n+\t}\n+\n+\treturn max;\n+}\n+\n+static int __init cma_range_cmp(const void *a, const void *b)\n+{\n+\tconst struct cma_memrange *cmr_a = a;\n+\tconst struct cma_memrange *cmr_b = b;\n+\n+\treturn cmp_int(cmr_a-\u003ebase_pfn, cmr_b-\u003ebase_pfn);\n+}\n+\n /*\n * Create CMA areas with a total size of @total_size. A normal allocation\n- * for one area is tried first. If that fails, the biggest memblock\n- * ranges above 4G are selected, and allocated bottom up.\n- *\n- * The complexity here is not great, but this function will only be\n- * called during boot, and the lists operated on have fewer than\n- * CMA_MAX_RANGES elements (default value: 8).\n+ * for one area is tried first. If that fails, the area is assembled from\n+ * up to CMA_MAX_RANGES of the biggest free memblock ranges above 4G.\n */\n int __init cma_declare_contiguous_multi(phys_addr_t total_size,\n \t\t\tphys_addr_t align, unsigned int order_per_bit,\n \t\t\tconst char *name, struct cma **res_cma, int nid)\n {\n-\tphys_addr_t start = 0, end;\n-\tphys_addr_t size, sizesum, sizeleft;\n-\tstruct cma_init_memrange *mrp, *mlp, *failed;\n+\tunsigned long size_mb = (unsigned long)total_size / SZ_1M;\n+\tphys_addr_t size, remaining, size_align;\n \tstruct cma_memrange *cmrp;\n-\tLIST_HEAD(ranges);\n-\tLIST_HEAD(final_ranges);\n-\tstruct list_head *mp, *next;\n-\tint ret, nr = 1;\n-\tu64 i;\n+\tphys_addr_t start = 0;\n \tstruct cma *cma;\n+\tint nr = 0;\n+\tint ret;\n \n \t/*\n \t * First, try it the normal way, producing just one range.\n \t */\n \tret = __cma_declare_contiguous_nid(\u0026start, total_size, 0, align,\n \t\t\torder_per_bit, false, name, res_cma, nid);\n+\tif (!ret) {\n+\t\tpr_info(\"Reserved %lu MiB at %pa\\n\", size_mb, \u0026start);\n+\t\treturn 0;\n+\t}\n \tif (ret != -ENOMEM)\n-\t\tgoto out;\n+\t\tgoto err;\n \n \t/*\n \t * Couldn't find one range that fits our needs, so try multiple\n@@ -572,151 +556,56 @@ int __init cma_declare_contiguous_multi(phys_addr_t total_size,\n \t * aligned to @align, and a size that is aligned to\n \t * both @align and @order_to_bit, things will work out.\n \t */\n-\tnr = 0;\n-\tsizesum = 0;\n-\tfailed = NULL;\n-\n \tret = cma_new_area(name, total_size, order_per_bit, \u0026cma);\n-\tif (ret != 0)\n-\t\tgoto out;\n+\tif (ret)\n+\t\tgoto err;\n \n \talign = max_t(phys_addr_t, align, CMA_MIN_ALIGNMENT_BYTES);\n-\t/*\n-\t * Create a list of ranges above 4G, largest range first.\n-\t */\n-\tfor_each_free_mem_range(i, nid, MEMBLOCK_NONE, \u0026start, \u0026end, NULL) {\n-\t\tif (upper_32_bits(start) == 0)\n-\t\t\tcontinue;\n-\n-\t\tstart = ALIGN(start, align);\n-\t\tif (start \u003e= end)\n-\t\t\tcontinue;\n-\n-\t\tend = ALIGN_DOWN(end, align);\n-\t\tif (end \u003c= start)\n-\t\t\tcontinue;\n+\tsize_align = max_t(phys_addr_t, align, PAGE_SIZE \u003c\u003c order_per_bit);\n \n-\t\tsize = end - start;\n-\t\tsize = ALIGN_DOWN(size, (PAGE_SIZE \u003c\u003c order_per_bit));\n+\tremaining = total_size;\n+\twhile (remaining \u0026\u0026 nr \u003c CMA_MAX_RANGES) {\n+\t\tsize = cma_find_free_range(align, size_align, nid, \u0026start);\n \t\tif (!size)\n-\t\t\tcontinue;\n-\t\tsizesum += size;\n-\n-\t\tpr_debug(\"consider %016llx - %016llx\\n\", (u64)start, (u64)end);\n-\n-\t\t/*\n-\t\t * If we don't yet have used the maximum number of\n-\t\t * areas, grab a new one.\n-\t\t *\n-\t\t * If we can't use anymore, see if this range is not\n-\t\t * smaller than the smallest one already recorded. If\n-\t\t * not, re-use the smallest element.\n-\t\t */\n-\t\tif (nr \u003c CMA_MAX_RANGES)\n-\t\t\tmrp = \u0026memranges[nr++];\n-\t\telse {\n-\t\t\tmrp = list_last_entry(\u0026ranges,\n-\t\t\t\t\t struct cma_init_memrange, list);\n-\t\t\tif (size \u003c mrp-\u003esize)\n-\t\t\t\tcontinue;\n-\t\t\tlist_del(\u0026mrp-\u003elist);\n-\t\t\tsizesum -= mrp-\u003esize;\n-\t\t\tpr_debug(\"deleted %016llx - %016llx from the list\\n\",\n-\t\t\t\t(u64)mrp-\u003ebase, (u64)mrp-\u003ebase + size);\n-\t\t}\n-\t\tmrp-\u003ebase = start;\n-\t\tmrp-\u003esize = size;\n-\n-\t\t/*\n-\t\t * Now do a sorted insert.\n-\t\t */\n-\t\tlist_insert_sorted(\u0026ranges, mrp, revsizecmp);\n-\t\tpr_debug(\"added %016llx - %016llx to the list\\n\",\n-\t\t (u64)mrp-\u003ebase, (u64)mrp-\u003ebase + size);\n-\t\tpr_debug(\"total size now %llu\\n\", (u64)sizesum);\n-\t}\n-\n-\t/*\n-\t * There is not enough room in the CMA_MAX_RANGES largest\n-\t * ranges, so bail out.\n-\t */\n-\tif (sizesum \u003c total_size) {\n-\t\tcma_drop_area(cma);\n-\t\tret = -ENOMEM;\n-\t\tgoto out;\n-\t}\n-\n-\t/*\n-\t * Found ranges that provide enough combined space.\n-\t * Now, sorted them by address, smallest first, because we\n-\t * want to mimic a bottom-up memblock allocation.\n-\t */\n-\tsizesum = 0;\n-\tlist_for_each_safe(mp, next, \u0026ranges) {\n-\t\tmlp = list_entry(mp, struct cma_init_memrange, list);\n-\t\tlist_del(mp);\n-\t\tlist_insert_sorted(\u0026final_ranges, mlp, basecmp);\n-\t\tsizesum += mlp-\u003esize;\n-\t\tif (sizesum \u003e= total_size)\n \t\t\tbreak;\n-\t}\n \n-\t/*\n-\t * Walk the final list, and add a CMA range for\n-\t * each range, possibly not using the last one fully.\n-\t */\n-\tnr = 0;\n-\tsizeleft = total_size;\n-\tlist_for_each(mp, \u0026final_ranges) {\n-\t\tmlp = list_entry(mp, struct cma_init_memrange, list);\n-\t\tsize = min(sizeleft, mlp-\u003esize);\n-\t\tif (memblock_reserve(mlp-\u003ebase, size)) {\n-\t\t\t/*\n-\t\t\t * Unexpected error. Could go on to\n-\t\t\t * the next one, but just abort to\n-\t\t\t * be safe.\n-\t\t\t */\n-\t\t\tfailed = mlp;\n+\t\tsize = min(size, remaining);\n+\t\tif (memblock_reserve(start, size))\n \t\t\tbreak;\n-\t\t}\n-\n-\t\taccept_memory(mlp-\u003ebase, size);\n+\t\taccept_memory(start, size);\n \n \t\tpr_debug(\"created region %d: %016llx - %016llx\\n\",\n-\t\t nr, (u64)mlp-\u003ebase, (u64)mlp-\u003ebase + size);\n+\t\t nr, (u64)start, (u64)start + size);\n \t\tcmrp = \u0026cma-\u003eranges[nr++];\n-\t\tcmrp-\u003ebase_pfn = PHYS_PFN(mlp-\u003ebase);\n+\t\tcmrp-\u003ebase_pfn = PHYS_PFN(start);\n \t\tcmrp-\u003eearly_pfn = cmrp-\u003ebase_pfn;\n \t\tcmrp-\u003ecount = size \u003e\u003e PAGE_SHIFT;\n \n-\t\tsizeleft -= size;\n-\t\tif (sizeleft == 0)\n-\t\t\tbreak;\n+\t\tremaining -= size;\n \t}\n \n-\tif (failed) {\n-\t\tlist_for_each(mp, \u0026final_ranges) {\n-\t\t\tmlp = list_entry(mp, struct cma_init_memrange, list);\n-\t\t\tif (mlp == failed)\n-\t\t\t\tbreak;\n-\t\t\tmemblock_phys_free(mlp-\u003ebase, mlp-\u003esize);\n-\t\t}\n-\t\tcma_drop_area(cma);\n+\tif (remaining) {\n \t\tret = -ENOMEM;\n-\t\tgoto out;\n+\t\tgoto err_free_ranges;\n \t}\n \n+\t/* allocate from lower addresses first */\n+\tsort(cma-\u003eranges, nr, sizeof(cma-\u003eranges[0]), cma_range_cmp, NULL);\n+\n \tcma-\u003enranges = nr;\n \tcma-\u003enid = nid;\n \t*res_cma = cma;\n \n-out:\n-\tif (ret != 0)\n-\t\tpr_err(\"Failed to reserve %lu MiB\\n\",\n-\t\t\t(unsigned long)total_size / SZ_1M);\n-\telse\n-\t\tpr_info(\"Reserved %lu MiB in %d range%s\\n\",\n-\t\t\t(unsigned long)total_size / SZ_1M, nr, str_plural(nr));\n+\tpr_info(\"Reserved %lu MiB in %d ranges\\n\", size_mb, nr);\n+\treturn 0;\n+\n+err_free_ranges:\n+\tfor (int i = 0; i \u003c nr; i++)\n+\t\tmemblock_phys_free(PFN_PHYS(cma-\u003eranges[i].base_pfn),\n+\t\t\t\t PFN_PHYS(cma-\u003eranges[i].count));\n+\tcma_drop_area(cma);\n+err:\n+\tpr_err(\"Failed to reserve %lu MiB\\n\", size_mb);\n \treturn ret;\n }\n \n"
} |
| 2/1 | 2026/11/09 13:23 | agent | patch-evaluator |
3mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "All functions modified, added, or removed in this patch (cma_declare_contiguous_multi, cma_find_free_range, and cma_range_cmp) are marked __init and are exclusively called during early boot initialization (via mm_core_init_early() -\u003e hugetlb_cma_reserve()). All __init text and data are freed and unmapped by free_initmem() before userspace starts and syzkaller begins runtime syscall fuzzing. No runtime CMA logic, data structures, or post-boot execution paths are modified. Because the altered code is structurally unreachable during fuzzing, fuzzing with syzkaller is not warranted.",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any '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: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 004485537f6569208178db1559a6bfc920a98500
Author: syz-cluster <triage@syzkaller.com>
Date: Mon Nov 9 13:23:46 2026 +0000
syz-cluster: applied patch under review
diff --git a/mm/cma.c b/mm/cma.c
index f61d52796f4ef7..ef0c49985067d2 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -23,8 +23,8 @@
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/string.h>
-#include <linux/string_choices.h>
#include <linux/log2.h>
+#include <linux/sort.h>
#include <linux/cma.h>
#include <linux/highmem.h>
#include <linux/io.h>
@@ -310,56 +310,6 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
return 0;
}
-/*
- * Structure used while walking physical memory ranges and finding out
- * which one(s) to use for a CMA area.
- */
-struct cma_init_memrange {
- phys_addr_t base;
- phys_addr_t size;
- struct list_head list;
-};
-
-/*
- * Work array used during CMA initialization.
- */
-static struct cma_init_memrange memranges[CMA_MAX_RANGES] __initdata;
-
-static bool __init revsizecmp(struct cma_init_memrange *mlp,
- struct cma_init_memrange *mrp)
-{
- return mlp->size > mrp->size;
-}
-
-static bool __init basecmp(struct cma_init_memrange *mlp,
- struct cma_init_memrange *mrp)
-{
- return mlp->base < mrp->base;
-}
-
-/*
- * Helper function to create sorted lists.
- */
-static void __init list_insert_sorted(
- struct list_head *ranges,
- struct cma_init_memrange *mrp,
- bool (*cmp)(struct cma_init_memrange *lh, struct cma_init_memrange *rh))
-{
- struct list_head *mp;
- struct cma_init_memrange *mlp;
-
- if (list_empty(ranges))
- list_add(&mrp->list, ranges);
- else {
- list_for_each(mp, ranges) {
- mlp = list_entry(mp, struct cma_init_memrange, list);
- if (cmp(mlp, mrp))
- break;
- }
- __list_add(&mrp->list, mlp->list.prev, &mlp->list);
- }
-}
-
static int __init cma_fixed_reserve(phys_addr_t base, phys_addr_t size)
{
if (IS_ENABLED(CONFIG_HIGHMEM)) {
@@ -524,37 +474,71 @@ static int __init __cma_declare_contiguous_nid(phys_addr_t *basep,
return 0;
}
+/*
+ * Find the largest free range above 4G that can hold a part of a multi-range
+ * CMA area.
+ */
+static phys_addr_t __init cma_find_free_range(phys_addr_t align,
+ phys_addr_t size_align, int nid, phys_addr_t *basep)
+{
+ phys_addr_t start, end, size;
+ phys_addr_t max = 0;
+ u64 i;
+
+ for_each_free_mem_range(i, nid, MEMBLOCK_NONE, &start, &end, NULL) {
+ if (start < SZ_4G)
+ continue;
+
+ start = ALIGN(start, align);
+ if (start >= end)
+ continue;
+
+ size = ALIGN_DOWN(end - start, size_align);
+ if (size > max) {
+ max = size;
+ *basep = start;
+ }
+ }
+
+ return max;
+}
+
+static int __init cma_range_cmp(const void *a, const void *b)
+{
+ const struct cma_memrange *cmr_a = a;
+ const struct cma_memrange *cmr_b = b;
+
+ return cmp_int(cmr_a->base_pfn, cmr_b->base_pfn);
+}
+
/*
* Create CMA areas with a total size of @total_size. A normal allocation
- * for one area is tried first. If that fails, the biggest memblock
- * ranges above 4G are selected, and allocated bottom up.
- *
- * The complexity here is not great, but this function will only be
- * called during boot, and the lists operated on have fewer than
- * CMA_MAX_RANGES elements (default value: 8).
+ * for one area is tried first. If that fails, the area is assembled from
+ * up to CMA_MAX_RANGES of the biggest free memblock ranges above 4G.
*/
int __init cma_declare_contiguous_multi(phys_addr_t total_size,
phys_addr_t align, unsigned int order_per_bit,
const char *name, struct cma **res_cma, int nid)
{
- phys_addr_t start = 0, end;
- phys_addr_t size, sizesum, sizeleft;
- struct cma_init_memrange *mrp, *mlp, *failed;
+ unsigned long size_mb = (unsigned long)total_size / SZ_1M;
+ phys_addr_t size, remaining, size_align;
struct cma_memrange *cmrp;
- LIST_HEAD(ranges);
- LIST_HEAD(final_ranges);
- struct list_head *mp, *next;
- int ret, nr = 1;
- u64 i;
+ phys_addr_t start = 0;
struct cma *cma;
+ int nr = 0;
+ int ret;
/*
* First, try it the normal way, producing just one range.
*/
ret = __cma_declare_contiguous_nid(&start, total_size, 0, align,
order_per_bit, false, name, res_cma, nid);
+ if (!ret) {
+ pr_info("Reserved %lu MiB at %pa\n", size_mb, &start);
+ return 0;
+ }
if (ret != -ENOMEM)
- goto out;
+ goto err;
/*
* Couldn't find one range that fits our needs, so try multiple
@@ -572,151 +556,56 @@ int __init cma_declare_contiguous_multi(phys_addr_t total_size,
* aligned to @align, and a size that is aligned to
* both @align and @order_to_bit, things will work out.
*/
- nr = 0;
- sizesum = 0;
- failed = NULL;
-
ret = cma_new_area(name, total_size, order_per_bit, &cma);
- if (ret != 0)
- goto out;
+ if (ret)
+ goto err;
align = max_t(phys_addr_t, align, CMA_MIN_ALIGNMENT_BYTES);
- /*
- * Create a list of ranges above 4G, largest range first.
- */
- for_each_free_mem_range(i, nid, MEMBLOCK_NONE, &start, &end, NULL) {
- if (upper_32_bits(start) == 0)
- continue;
-
- start = ALIGN(start, align);
- if (start >= end)
- continue;
-
- end = ALIGN_DOWN(end, align);
- if (end <= start)
- continue;
+ size_align = max_t(phys_addr_t, align, PAGE_SIZE << order_per_bit);
- size = end - start;
- size = ALIGN_DOWN(size, (PAGE_SIZE << order_per_bit));
+ remaining = total_size;
+ while (remaining && nr < CMA_MAX_RANGES) {
+ size = cma_find_free_range(align, size_align, nid, &start);
if (!size)
- continue;
- sizesum += size;
-
- pr_debug("consider %016llx - %016llx\n", (u64)start, (u64)end);
-
- /*
- * If we don't yet have used the maximum number of
- * areas, grab a new one.
- *
- * If we can't use anymore, see if this range is not
- * smaller than the smallest one already recorded. If
- * not, re-use the smallest element.
- */
- if (nr < CMA_MAX_RANGES)
- mrp = &memranges[nr++];
- else {
- mrp = list_last_entry(&ranges,
- struct cma_init_memrange, list);
- if (size < mrp->size)
- continue;
- list_del(&mrp->list);
- sizesum -= mrp->size;
- pr_debug("deleted %016llx - %016llx from the list\n",
- (u64)mrp->base, (u64)mrp->base + size);
- }
- mrp->base = start;
- mrp->size = size;
-
- /*
- * Now do a sorted insert.
- */
- list_insert_sorted(&ranges, mrp, revsizecmp);
- pr_debug("added %016llx - %016llx to the list\n",
- (u64)mrp->base, (u64)mrp->base + size);
- pr_debug("total size now %llu\n", (u64)sizesum);
- }
-
- /*
- * There is not enough room in the CMA_MAX_RANGES largest
- * ranges, so bail out.
- */
- if (sizesum < total_size) {
- cma_drop_area(cma);
- ret = -ENOMEM;
- goto out;
- }
-
- /*
- * Found ranges that provide enough combined space.
- * Now, sorted them by address, smallest first, because we
- * want to mimic a bottom-up memblock allocation.
- */
- sizesum = 0;
- list_for_each_safe(mp, next, &ranges) {
- mlp = list_entry(mp, struct cma_init_memrange, list);
- list_del(mp);
- list_insert_sorted(&final_ranges, mlp, basecmp);
- sizesum += mlp->size;
- if (sizesum >= total_size)
break;
- }
- /*
- * Walk the final list, and add a CMA range for
- * each range, possibly not using the last one fully.
- */
- nr = 0;
- sizeleft = total_size;
- list_for_each(mp, &final_ranges) {
- mlp = list_entry(mp, struct cma_init_memrange, list);
- size = min(sizeleft, mlp->size);
- if (memblock_reserve(mlp->base, size)) {
- /*
- * Unexpected error. Could go on to
- * the next one, but just abort to
- * be safe.
- */
- failed = mlp;
+ size = min(size, remaining);
+ if (memblock_reserve(start, size))
break;
- }
-
- accept_memory(mlp->base, size);
+ accept_memory(start, size);
pr_debug("created region %d: %016llx - %016llx\n",
- nr, (u64)mlp->base, (u64)mlp->base + size);
+ nr, (u64)start, (u64)start + size);
cmrp = &cma->ranges[nr++];
- cmrp->base_pfn = PHYS_PFN(mlp->base);
+ cmrp->base_pfn = PHYS_PFN(start);
cmrp->early_pfn = cmrp->base_pfn;
cmrp->count = size >> PAGE_SHIFT;
- sizeleft -= size;
- if (sizeleft == 0)
- break;
+ remaining -= size;
}
- if (failed) {
- list_for_each(mp, &final_ranges) {
- mlp = list_entry(mp, struct cma_init_memrange, list);
- if (mlp == failed)
- break;
- memblock_phys_free(mlp->base, mlp->size);
- }
- cma_drop_area(cma);
+ if (remaining) {
ret = -ENOMEM;
- goto out;
+ goto err_free_ranges;
}
+ /* allocate from lower addresses first */
+ sort(cma->ranges, nr, sizeof(cma->ranges[0]), cma_range_cmp, NULL);
+
cma->nranges = nr;
cma->nid = nid;
*res_cma = cma;
-out:
- if (ret != 0)
- pr_err("Failed to reserve %lu MiB\n",
- (unsigned long)total_size / SZ_1M);
- else
- pr_info("Reserved %lu MiB in %d range%s\n",
- (unsigned long)total_size / SZ_1M, nr, str_plural(nr));
+ pr_info("Reserved %lu MiB in %d ranges\n", size_mb, nr);
+ return 0;
+
+err_free_ranges:
+ for (int i = 0; i < nr; i++)
+ memblock_phys_free(PFN_PHYS(cma->ranges[i].base_pfn),
+ PFN_PHYS(cma->ranges[i].count));
+ cma_drop_area(cma);
+err:
+ pr_err("Failed to reserve %lu MiB\n", size_mb);
return ret;
}
|
| 3/2 | 2026/11/09 13:23 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 6563 output: 22 thoughts: 230 Thoughts: **Analyzing the CMA Patch** Okay, let's dive into this patch. My immediate focus is understanding the scope of these modifications. First, I see the target is `mm/cma.c`, which, if I recall correctly, handles Contiguous Memory Allocator functionality. That's a critical area; any change here needs careful scrutiny. Now, the changes are targeting `cma_declare_contiguous_multi`. I'm also seeing added and removed helper functions. Hmm, it looks like `struct cma_init_memrange`, `memranges`, `revsizecmp`, `basecmp`, and `list_insert_sorted` are out, and `cma_find_free_range` and `cma_range_cmp` are in. This strongly suggests a change in how memory ranges are managed and sorted within the CMA. We're likely moving towards a different, possibly more efficient, allocation strategy. Ah, and I see the function annotations: `cma_declare_contiguous_multi` is marked as `__init`, and the helpers are also `__init`. This means these functions are only used during boot-up, which is important context. Wait a second, the fact that `cma_declare_contiguous_multi` is an `__init` function suggests it's involved in initializing the CMA memory regions. That's a key detail to confirm. I should quickly check the callers of `cma_declare_contiguous_multi` to get a better handle on this, I'll run `grepper` right away. This will give me immediate insight into what is calling this function and, thus, what this patch is impacting. |
| 4/2 | 2026/11/09 13:24 | tool | grepper |
0mArgs:{
"Expression": "cma_declare_contiguous_multi"
}Results: {
"Output": "include/linux/cma.h=35=static inline int __init cma_declare_contiguous(phys_addr_t base,\n--\ninclude/linux/cma.h-42-}\ninclude/linux/cma.h:43:extern int __init cma_declare_contiguous_multi(phys_addr_t size,\ninclude/linux/cma.h-44-\t\t\tphys_addr_t align, unsigned int order_per_bit,\n--\nmm/cma.c=506=static int __init cma_range_cmp(const void *a, const void *b)\n--\nmm/cma.c-518- */\nmm/cma.c:519:int __init cma_declare_contiguous_multi(phys_addr_t total_size,\nmm/cma.c-520-\t\t\tphys_addr_t align, unsigned int order_per_bit,\n--\nmm/hugetlb_cma.c=211=void __init hugetlb_cma_reserve(void)\n--\nmm/hugetlb_cma.c-357-\t\t */\nmm/hugetlb_cma.c:358:\t\tres = cma_declare_contiguous_multi(size, gigantic_page_size,\nmm/hugetlb_cma.c-359-\t\t\t\t\tHUGETLB_PAGE_ORDER, name,\n"
} |
| 5/2 | 2026/11/09 13:24 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 7514 output: 22 thoughts: 40 Thoughts: Here's my analysis of the provided snippet, tailored for an expert like you: **Deduction on Contiguous Memory Allocation** Right, so `cma_declare_contiguous_multi` is exclusively invoked by `hugetlb_cma_reserve`. That's an immediate, significant narrowing of the scope. Given that dependency, the next logical step is to dive into `hugetlb_cma_reserve`. Understanding the purpose and functionality of that routine should illuminate the context in which this contiguous memory declaration takes place. We need to dissect that function to grasp *why* this specific declaration is happening, and *what* it is meant to accomplish in the larger picture of hugetlb and CMA integration. My focus now is purely on what `hugetlb_cma_reserve` is doing with `cma_declare_contiguous_multi`. Let's see... |
| 6/2 | 2026/11/09 13:24 | tool | grepper |
0mArgs:{
"Expression": "hugetlb_cma_reserve"
}Results: {
"Output": "Documentation/driver-api/cxl/linux/early-boot.rst=126=on NUMA nodes that are not online during early boot. ::\nDocumentation/driver-api/cxl/linux/early-boot.rst-127-\nDocumentation/driver-api/cxl/linux/early-boot.rst:128: void __init hugetlb_cma_reserve(void) {\nDocumentation/driver-api/cxl/linux/early-boot.rst-129- if (!node_online(nid))\n--\ninclude/linux/hugetlb.h=1342=static inline spinlock_t *huge_pte_lock(struct hstate *h,\n--\ninclude/linux/hugetlb.h-1352-#if defined(CONFIG_HUGETLB_PAGE) \u0026\u0026 defined(CONFIG_CMA)\ninclude/linux/hugetlb.h:1353:extern void __init hugetlb_cma_reserve(void);\ninclude/linux/hugetlb.h-1354-#else\ninclude/linux/hugetlb.h:1355:static inline __init void hugetlb_cma_reserve(void)\ninclude/linux/hugetlb.h-1356-{\n--\nmm/hugetlb.c=3165=static bool __init alloc_bootmem_huge_page(struct hstate *h, int nid)\n--\nmm/hugetlb.c-3185-\nmm/hugetlb.c:3186:\t/* CMA pages: zone-crossing is validated in hugetlb_cma_reserve(). */\nmm/hugetlb.c-3187-\tif (!hugetlb_early_cma(h) \u0026\u0026\n--\nmm/hugetlb_cma.c=206=unsigned int __weak arch_hugetlb_cma_order(void)\n--\nmm/hugetlb_cma.c-210-\nmm/hugetlb_cma.c:211:void __init hugetlb_cma_reserve(void)\nmm/hugetlb_cma.c-212-{\n--\nmm/mm_init.c=2681=void __init mm_core_init_early(void)\n--\nmm/mm_init.c-2687-\nmm/mm_init.c:2688:\thugetlb_cma_reserve();\nmm/mm_init.c-2689-\thugetlb_bootmem_alloc();\n"
} |
| 7/2 | 2026/11/09 13:24 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 8379 output: 21 thoughts: 49 Thoughts: Okay, let's dive into this. Here's how I'd approach this analysis: **Analyzing `mm_core_init_early` During System Boot** My immediate focus is on the function `mm_core_init_early`. I need to understand its role and when it's executed within the system initialization process. The fact that it's tagged with `__init` is a critical clue – that tells me it's called early, right during the boot sequence. Knowing that it's an initialization function, I need to pinpoint the exact call site. So, my next step is clear: I need to trace the call graph to see precisely where `mm_core_init_early` is invoked during the kernel's startup. That's the key to understanding its place in the overall memory management strategy. |
| 8/2 | 2026/11/09 13:24 | tool | grepper |
0mArgs:{
"Expression": "mm_core_init_early"
}Results: {
"Output": "arch/parisc/kernel/setup.c=101=void __init setup_arch(char **cmdline_p)\n--\narch/parisc/kernel/setup.c-135-\t/*\narch/parisc/kernel/setup.c:136:\t * Parse early parameters before mm_core_init_early() runs.\narch/parisc/kernel/setup.c-137-\t * Several early_param() handlers only record data that is consumed\n--\ninclude/linux/mm.h=50=void arch_mm_preinit(void);\ninclude/linux/mm.h:51:void mm_core_init_early(void);\ninclude/linux/mm.h-52-void mm_core_init(void);\n--\ninit/main.c=1044=void start_kernel(void)\n--\ninit/main.c-1066-\tsetup_arch(\u0026command_line);\ninit/main.c:1067:\tmm_core_init_early();\ninit/main.c-1068-\t/* Static keys and static calls are needed by LSMs */\n--\nmm/mm_init.c=2677=void __init __weak mem_init(void)\n--\nmm/mm_init.c-2680-\nmm/mm_init.c:2681:void __init mm_core_init_early(void)\nmm/mm_init.c-2682-{\n"
} |
| 9/2 | 2026/11/09 13:24 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 8990 output: 29 thoughts: 1322 Thoughts: **Triage Decision: Not Worth Fuzzing** Okay, so here's the situation. I'm looking at this patch and my initial thought is: can syzkaller even reach this code? `cma_declare_contiguous_multi` is an `__init` function. That means it's only called during kernel boot in `start_kernel()`. Syzkaller runs *after* boot, right? It's a runtime syscall fuzzer. All the `__init` stuff is long gone – `free_initmem()` has wiped it all out. Let's double-check, though. Is there *any* other place this function is called, or *could* be called, *after* boot? I need to be absolutely sure. Okay, I've checked all references. Nope, no other callers. It's only called from `hugetlb_cma_reserve` which itself is only called from `mm_core_init_early()` which is only called from `start_kernel()`. All `__init`. So, the code is definitively discarded, right? Time for the triage philosophy! "Reachability is the primary gate," it says. "Fuzzing can only discover bugs in code that can actually execute in standard virtualized environments. If the modified code is structurally unreachable, it MUST NOT be fuzzed." Then there's the list of negative criteria – and one of them is "Unreachable execution paths." And that *has* to include early boot `__init` functions for a runtime fuzzer like syzkaller! But wait, what about the patch itself? What's *actually* changed? It's easy to get caught up in the control flow, but I need to examine the *data*. Does this patch introduce new data structures or change existing ones that might affect runtime behavior? I need to meticulously inspect the diff. Alright, the diff shows removals and additions of functions and a data structure, but all of them are marked `__init`. It's been confirmed that all functions added, removed, or modified are marked `__init`: - `struct cma_init_memrange` (removed) - `memranges` (removed) - `revsizecmp` (removed) - `basecmp` (removed) - `list_insert_sorted` (removed) - `cma_find_free_range` (added, `__init`) - `cma_range_cmp` (added, `__init`) - `cma_declare_contiguous_multi` (modified, `__init`) Okay, so `cma_declare_contiguous_multi` reserves CMA ranges during boot. How does hugetlb CMA work at runtime? Is the way CMA areas are configured by `cma_declare_contiguous_multi` changed in such a way that affects runtime allocations? Nope, it doesn't. No runtime changes. Therefore, this patch is *definitely* unreachable by syzkaller. **This is not worth fuzzing.** |
| 10/2 | 2026/11/09 13:25 | tool | grepper |
0mArgs:{
"Expression": "hugetlb_cma",
"PathPrefixes": [
"mm/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 390 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (6 files in total):\nmm/Makefile:1\nmm/cma.h:1\nmm/hugetlb.c:15\nmm/hugetlb_cma.c:106\nmm/hugetlb_cma.h:12\nmm/mm_init.c:1\n\nmm/Makefile=83=ifdef CONFIG_CMA\nmm/Makefile:84:obj-$(CONFIG_HUGETLBFS)\t+= hugetlb_cma.o\nmm/Makefile-85-endif\n--\nmm/cma.h=18=struct cma_kobject {\n--\nmm/cma.h-25- * Multi-range support. This can be useful if the size of the allocation\nmm/cma.h:26: * is not expected to be larger than the alignment (like with hugetlb_cma),\nmm/cma.h-27- * and the total amount of memory requested, while smaller than the total\n--\nmm/hugetlb.c-55-#include \"hugetlb_vmemmap.h\"\nmm/hugetlb.c:56:#include \"hugetlb_cma.h\"\nmm/hugetlb.c-57-#include \"hugetlb_internal.h\"\n--\nmm/hugetlb.c=1366=static struct folio *alloc_gigantic_frozen_folio(int order, gfp_t gfp_mask,\n--\nmm/hugetlb.c-1370-\nmm/hugetlb.c:1371:\tfolio = hugetlb_cma_alloc_frozen_folio(order, gfp_mask, nid, nodemask);\nmm/hugetlb.c-1372-\tif (folio)\n--\nmm/hugetlb.c-1374-\nmm/hugetlb.c:1375:\tif (hugetlb_cma_exclusive_alloc())\nmm/hugetlb.c-1376-\t\treturn NULL;\n--\nmm/hugetlb.c=1464=static void __update_and_free_hugetlb_folio(struct hstate *h,\n--\nmm/hugetlb.c-1516-\tVM_BUG_ON_FOLIO(folio_ref_count(folio), folio);\nmm/hugetlb.c:1517:\tif (folio_test_hugetlb_cma(folio))\nmm/hugetlb.c:1518:\t\thugetlb_cma_free_frozen_folio(folio);\nmm/hugetlb.c-1519-\telse\n--\nmm/hugetlb.c=3139=static __init void *alloc_bootmem(struct hstate *h, int nid, bool node_exact)\n--\nmm/hugetlb.c-3141-\tif (hugetlb_early_cma(h))\nmm/hugetlb.c:3142:\t\treturn hugetlb_cma_alloc_bootmem(h, nid, node_exact);\nmm/hugetlb.c-3143-\n--\nmm/hugetlb.c=3165=static bool __init alloc_bootmem_huge_page(struct hstate *h, int nid)\n--\nmm/hugetlb.c-3185-\nmm/hugetlb.c:3186:\t/* CMA pages: zone-crossing is validated in hugetlb_cma_reserve(). */\nmm/hugetlb.c-3187-\tif (!hugetlb_early_cma(h) \u0026\u0026\n--\nmm/hugetlb.c=3270=static void __init hugetlb_bootmem_init_migratetype(struct folio *folio,\n--\nmm/hugetlb.c-3277-\tfor (i = 0; i \u003c nr_pages; i += pageblock_nr_pages) {\nmm/hugetlb.c:3278:\t\tif (folio_test_hugetlb_cma(folio))\nmm/hugetlb.c-3279-\t\t\tinit_cma_pageblock(folio_page(folio, i));\n--\nmm/hugetlb.c=3320=static void __init gather_bootmem_prealloc_node(unsigned long nid)\n--\nmm/hugetlb.c-3361-\t\tif (hugetlb_early_cma(h))\nmm/hugetlb.c:3362:\t\t\tfolio_set_hugetlb_cma(folio);\nmm/hugetlb.c-3363-\t\telse\n--\nmm/hugetlb.c=3623=static void __init hugetlb_hstate_alloc_pages(struct hstate *h)\n--\nmm/hugetlb.c-3630-\t */\nmm/hugetlb.c:3631:\tif (hstate_is_gigantic(h) \u0026\u0026 hugetlb_cma_total_size() \u0026\u0026\nmm/hugetlb.c-3632-\t !hugetlb_early_cma(h)) {\nmm/hugetlb.c:3633:\t\tpr_warn_once(\"hugetlb_cma is enabled, skip boot time allocation\\n\");\nmm/hugetlb.c-3634-\t\treturn;\n--\nmm/hugetlb.c=3653=static void __init hugetlb_init_hstates(void)\n--\nmm/hugetlb.c-3680-\t\t\tcontinue;\nmm/hugetlb.c:3681:\t\tif (hugetlb_cma_total_size() \u0026\u0026 h-\u003eorder \u003c= HUGETLB_PAGE_ORDER)\nmm/hugetlb.c-3682-\t\t\tcontinue;\n--\nmm/hugetlb.c=3970=static long demote_free_hugetlb_folios(struct hstate *src, struct hstate *dst,\n--\nmm/hugetlb.c-3997-\nmm/hugetlb.c:3998:\t\tcma = folio_test_hugetlb_cma(folio);\nmm/hugetlb.c-3999-\n--\nmm/hugetlb.c-4016-\t\t\tif (cma)\nmm/hugetlb.c:4017:\t\t\t\tfolio_set_hugetlb_cma(new_folio);\nmm/hugetlb.c-4018-\t\t\tlist_add(\u0026new_folio-\u003elru, \u0026dst_list);\n--\nmm/hugetlb.c=4324=static __init void hugetlb_parse_params(void)\n--\nmm/hugetlb.c-4334-\nmm/hugetlb.c:4335:\thugetlb_cma_validate_params();\nmm/hugetlb.c-4336-}\n--\nmm/hugetlb_cma.c-16-#include \"internal.h\"\nmm/hugetlb_cma.c:17:#include \"hugetlb_cma.h\"\nmm/hugetlb_cma.c-18-\nmm/hugetlb_cma.c-19-\nmm/hugetlb_cma.c:20:static struct cma *hugetlb_cma[MAX_NUMNODES] __ro_after_init;\nmm/hugetlb_cma.c:21:static unsigned long hugetlb_cma_size_in_node[MAX_NUMNODES] __initdata;\nmm/hugetlb_cma.c:22:static bool hugetlb_cma_only __ro_after_init;\nmm/hugetlb_cma.c:23:static unsigned long hugetlb_cma_size __ro_after_init;\nmm/hugetlb_cma.c-24-\nmm/hugetlb_cma.c:25:static unsigned int hugetlb_cma_percent __initdata;\nmm/hugetlb_cma.c:26:static unsigned int hugetlb_cma_percent_in_node[MAX_NUMNODES] __initdata;\nmm/hugetlb_cma.c-27-\n--\nmm/hugetlb_cma.c=41=static phys_addr_t __init memblock_node_memory_size(int nid)\n--\nmm/hugetlb_cma.c-46-\nmm/hugetlb_cma.c:47:void hugetlb_cma_free_frozen_folio(struct folio *folio)\nmm/hugetlb_cma.c-48-{\nmm/hugetlb_cma.c:49:\tWARN_ON_ONCE(!cma_release_frozen(hugetlb_cma[folio_nid(folio)],\nmm/hugetlb_cma.c-50-\t\t\t\t\t \u0026folio-\u003epage, folio_nr_pages(folio)));\n--\nmm/hugetlb_cma.c-52-\nmm/hugetlb_cma.c:53:struct folio *hugetlb_cma_alloc_frozen_folio(int order, gfp_t gfp_mask,\nmm/hugetlb_cma.c-54-\t\tint nid, nodemask_t *nodemask)\n--\nmm/hugetlb_cma.c-61-\nmm/hugetlb_cma.c:62:\tif (!hugetlb_cma_size)\nmm/hugetlb_cma.c-63-\t\treturn NULL;\n--\nmm/hugetlb_cma.c-72-\nmm/hugetlb_cma.c:73:\tif (hugetlb_cma[nid] \u0026\u0026 node_isset(nid, *nmask))\nmm/hugetlb_cma.c:74:\t\tpage = cma_alloc_frozen_compound(hugetlb_cma[nid], order);\nmm/hugetlb_cma.c-75-\n--\nmm/hugetlb_cma.c-77-\t\tfor_each_node_mask(node, *nmask) {\nmm/hugetlb_cma.c:78:\t\t\tif (node == nid || !hugetlb_cma[node])\nmm/hugetlb_cma.c-79-\t\t\t\tcontinue;\nmm/hugetlb_cma.c-80-\nmm/hugetlb_cma.c:81:\t\t\tpage = cma_alloc_frozen_compound(hugetlb_cma[node], order);\nmm/hugetlb_cma.c-82-\t\t\tif (page)\n--\nmm/hugetlb_cma.c-94-\tfolio = page_folio(page);\nmm/hugetlb_cma.c:95:\tfolio_set_hugetlb_cma(folio);\nmm/hugetlb_cma.c-96-\treturn folio;\n--\nmm/hugetlb_cma.c-98-\nmm/hugetlb_cma.c:99:void * __init hugetlb_cma_alloc_bootmem(struct hstate *h, int nid, bool node_exact)\nmm/hugetlb_cma.c-100-{\n--\nmm/hugetlb_cma.c-104-\nmm/hugetlb_cma.c:105:\tcma = hugetlb_cma[nid];\nmm/hugetlb_cma.c-106-\tm = cma_reserve_early(cma, huge_page_size(h));\n--\nmm/hugetlb_cma.c-110-\tfor_each_node_mask(node, hugetlb_bootmem_nodes) {\nmm/hugetlb_cma.c:111:\t\tcma = hugetlb_cma[node];\nmm/hugetlb_cma.c-112-\t\tif (!cma || node == nid)\n--\nmm/hugetlb_cma.c-121-\nmm/hugetlb_cma.c:122:static int __init cmdline_parse_hugetlb_cma(char *p)\nmm/hugetlb_cma.c-123-{\n--\nmm/hugetlb_cma.c-138-\nmm/hugetlb_cma.c:139:\t\t\thugetlb_cma_size = 0;\nmm/hugetlb_cma.c:140:\t\t\thugetlb_cma_percent = 0;\nmm/hugetlb_cma.c-141-\n--\nmm/hugetlb_cma.c-145-\t\t\t\tif (tmp \u003e 100) {\nmm/hugetlb_cma.c:146:\t\t\t\t\tpr_warn(\"hugetlb_cma: invalid percentage %lu for node %d\\n\",\nmm/hugetlb_cma.c-147-\t\t\t\t\t\ttmp, nid);\n--\nmm/hugetlb_cma.c-149-\t\t\t\t}\nmm/hugetlb_cma.c:150:\t\t\t\thugetlb_cma_percent_in_node[nid] = tmp;\nmm/hugetlb_cma.c:151:\t\t\t\thugetlb_cma_size_in_node[nid] = 0;\nmm/hugetlb_cma.c-152-\t\t\t\ts = next + 1;\nmm/hugetlb_cma.c-153-\t\t\t} else {\nmm/hugetlb_cma.c:154:\t\t\t\thugetlb_cma_size_in_node[nid] = tmp;\nmm/hugetlb_cma.c:155:\t\t\t\thugetlb_cma_percent_in_node[nid] = 0;\nmm/hugetlb_cma.c-156-\t\t\t\ts = next;\n--\nmm/hugetlb_cma.c-172-\t\t\t\tif (tmp \u003e 100) {\nmm/hugetlb_cma.c:173:\t\t\t\t\tpr_warn(\"hugetlb_cma: invalid percentage %lu\\n\", tmp);\nmm/hugetlb_cma.c-174-\t\t\t\t} else {\nmm/hugetlb_cma.c:175:\t\t\t\t\thugetlb_cma_percent = tmp;\nmm/hugetlb_cma.c:176:\t\t\t\t\thugetlb_cma_size = 0;\nmm/hugetlb_cma.c-177-\t\t\t\t\tfor (nid = 0; nid \u003c MAX_NUMNODES; nid++) {\nmm/hugetlb_cma.c:178:\t\t\t\t\t\thugetlb_cma_size_in_node[nid] = 0;\nmm/hugetlb_cma.c:179:\t\t\t\t\t\thugetlb_cma_percent_in_node[nid] = 0;\nmm/hugetlb_cma.c-180-\t\t\t\t\t}\n--\nmm/hugetlb_cma.c-182-\t\t\t} else {\nmm/hugetlb_cma.c:183:\t\t\t\thugetlb_cma_size = tmp;\nmm/hugetlb_cma.c:184:\t\t\t\thugetlb_cma_percent = 0;\nmm/hugetlb_cma.c-185-\t\t\t\tfor (nid = 0; nid \u003c MAX_NUMNODES; nid++) {\nmm/hugetlb_cma.c:186:\t\t\t\t\thugetlb_cma_size_in_node[nid] = 0;\nmm/hugetlb_cma.c:187:\t\t\t\t\thugetlb_cma_percent_in_node[nid] = 0;\nmm/hugetlb_cma.c-188-\t\t\t\t}\n--\nmm/hugetlb_cma.c-196-\nmm/hugetlb_cma.c:197:early_param(\"hugetlb_cma\", cmdline_parse_hugetlb_cma);\nmm/hugetlb_cma.c-198-\nmm/hugetlb_cma.c:199:static int __init cmdline_parse_hugetlb_cma_only(char *p)\nmm/hugetlb_cma.c-200-{\nmm/hugetlb_cma.c:201:\treturn kstrtobool(p, \u0026hugetlb_cma_only);\nmm/hugetlb_cma.c-202-}\nmm/hugetlb_cma.c-203-\nmm/hugetlb_cma.c:204:early_param(\"hugetlb_cma_only\", cmdline_parse_hugetlb_cma_only);\nmm/hugetlb_cma.c-205-\nmm/hugetlb_cma.c:206:unsigned int __weak arch_hugetlb_cma_order(void)\nmm/hugetlb_cma.c-207-{\n--\nmm/hugetlb_cma.c-210-\nmm/hugetlb_cma.c:211:void __init hugetlb_cma_reserve(void)\nmm/hugetlb_cma.c-212-{\n--\nmm/hugetlb_cma.c-218-\tfor (nid = 0; nid \u003c MAX_NUMNODES; nid++) {\n\n"
} |
| 11/2 | 2026/11/09 13:25 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15315 output: 38 thoughts: 27 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person: **Diving into the `hugetlb_cma_reserve` Function** Alright, let's get down to business. Time to dig into the details of `hugetlb_cma_reserve`, specifically within `mm/hugetlb_cma.c`. I'm going to carefully dissect this function, as it's critical for understanding how the kernel handles the allocation and reservation of HugeTLB pages in conjunction with CMA (Contiguous Memory Allocator). I'm particularly interested in how it interacts with the CMA infrastructure. What locking primitives are in use? How does it handle potential conflicts during allocation? And, most importantly, what are the subtle considerations for power users who are dealing with large memory blocks? I need to understand its edge cases. |
| 12/2 | 2026/11/09 13:25 | tool | read-file |
0mArgs:{
"File": "mm/hugetlb_cma.c",
"FirstLine": 211,
"LineCount": 80
}Results: {
"Contents": " 211:\tvoid __init hugetlb_cma_reserve(void)\n 212:\t{\n 213:\t\tunsigned long size, reserved, per_node, order, gigantic_page_size;\n 214:\t\tbool node_specific_cma_alloc = false;\n 215:\t\tbool has_node_specific_param = false;\n 216:\t\tint nid;\n 217:\t\n 218:\t\tfor (nid = 0; nid \u003c MAX_NUMNODES; nid++) {\n 219:\t\t\tif (hugetlb_cma_size_in_node[nid] || hugetlb_cma_percent_in_node[nid]) {\n 220:\t\t\t\thas_node_specific_param = true;\n 221:\t\t\t\tbreak;\n 222:\t\t\t}\n 223:\t\t}\n 224:\t\n 225:\t\tif (has_node_specific_param) {\n 226:\t\t\thugetlb_cma_size = 0;\n 227:\t\t\tfor (nid = 0; nid \u003c MAX_NUMNODES; nid++) {\n 228:\t\t\t\tif (hugetlb_cma_percent_in_node[nid]) {\n 229:\t\t\t\t\tphys_addr_t node_gfp_mem = memblock_node_memory_size(nid);\n 230:\t\t\t\t\tu64 s;\n 231:\t\n 232:\t\t\t\t\ts = mul_u64_u32_div((u64)node_gfp_mem,\n 233:\t\t\t\t\t\t\t hugetlb_cma_percent_in_node[nid],\n 234:\t\t\t\t\t\t\t 100);\n 235:\t\n 236:\t\t\t\t\thugetlb_cma_size_in_node[nid] = s;\n 237:\t\t\t\t}\n 238:\t\t\t\thugetlb_cma_size += hugetlb_cma_size_in_node[nid];\n 239:\t\t\t}\n 240:\t\t} else if (hugetlb_cma_percent) {\n 241:\t\t\thugetlb_cma_size = mul_u64_u32_div((u64)memblock_phys_mem_size(),\n 242:\t\t\t\t\t\t\t hugetlb_cma_percent, 100);\n 243:\t\t}\n 244:\t\n 245:\t\tif (!hugetlb_cma_size)\n 246:\t\t\treturn;\n 247:\t\n 248:\t\torder = arch_hugetlb_cma_order();\n 249:\t\tif (!order) {\n 250:\t\t\tpr_warn(\"hugetlb_cma: the option isn't supported by current arch\\n\");\n 251:\t\t\treturn;\n 252:\t\t}\n 253:\t\n 254:\t\t/*\n 255:\t\t * HugeTLB CMA reservation is required for gigantic\n 256:\t\t * huge pages which could not be allocated via the\n 257:\t\t * page allocator. Just warn if there is any change\n 258:\t\t * breaking this assumption.\n 259:\t\t */\n 260:\t\tVM_WARN_ON(order \u003c= MAX_PAGE_ORDER);\n 261:\t\tgigantic_page_size = PAGE_SIZE \u003c\u003c order;\n 262:\t\n 263:\t\tif (hugetlb_cma_percent) {\n 264:\t\t\tunsigned long orig_size = hugetlb_cma_size;\n 265:\t\n 266:\t\t\thugetlb_cma_size = ALIGN_DOWN(hugetlb_cma_size, PAGE_SIZE \u003c\u003c order);\n 267:\t\t\tif (orig_size \u0026\u0026 !hugetlb_cma_size)\n 268:\t\t\t\tpr_warn(\"hugetlb_cma: reservation size rounded down to 0 from %lu MiB (%u%%)\\n\",\n 269:\t\t\t\t\torig_size / SZ_1M, hugetlb_cma_percent);\n 270:\t\t} else if (has_node_specific_param) {\n 271:\t\t\thugetlb_cma_size = 0;\n 272:\t\t\tfor (nid = 0; nid \u003c MAX_NUMNODES; nid++) {\n 273:\t\t\t\tif (hugetlb_cma_percent_in_node[nid]) {\n 274:\t\t\t\t\tunsigned long orig_size = hugetlb_cma_size_in_node[nid];\n 275:\t\n 276:\t\t\t\t\thugetlb_cma_size_in_node[nid] =\n 277:\t\t\t\t\t\tALIGN_DOWN(hugetlb_cma_size_in_node[nid],\n 278:\t\t\t\t\t\t\t PAGE_SIZE \u003c\u003c order);\n 279:\t\t\t\t\tif (orig_size \u0026\u0026 !hugetlb_cma_size_in_node[nid])\n 280:\t\t\t\t\t\tpr_warn(\"hugetlb_cma: reservation size rounded down to 0 from %lu MiB (%u%%) on node %d\\n\",\n 281:\t\t\t\t\t\t\torig_size / SZ_1M,\n 282:\t\t\t\t\t\t\thugetlb_cma_percent_in_node[nid],\n 283:\t\t\t\t\t\t\tnid);\n 284:\t\t\t\t}\n 285:\t\t\t\thugetlb_cma_size += hugetlb_cma_size_in_node[nid];\n 286:\t\t\t}\n 287:\t\t}\n 288:\t\n 289:\t\thugetlb_bootmem_set_nodes();\n 290:\t\n"
} |
| 13/2 | 2026/11/09 13:25 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16990 output: 38 thoughts: 17 Thoughts: Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person: **Diving into `hugetlb_cma_reserve`** Alright, let's see what's going on down here in `hugetlb_cma_reserve`. I know the basics, the high-level picture, but I want to get the details straight in my head. I'm focusing on the interaction with CMA and how it's managing these huge pages. Time to dig in and see how the reservation happens. I need to understand the nuances of the memory allocation process within the context of hugetlbfs and CMA. Let's see how the interaction works and the finer points of this critical function. |
| 14/2 | 2026/11/09 13:25 | tool | read-file |
0mArgs:{
"File": "mm/hugetlb_cma.c",
"FirstLine": 291,
"LineCount": 80
}Results: {
"Contents": " 291:\t\tfor (nid = 0; nid \u003c MAX_NUMNODES; nid++) {\n 292:\t\t\tsize = hugetlb_cma_size_in_node[nid];\n 293:\t\t\tif (size == 0)\n 294:\t\t\t\tcontinue;\n 295:\t\n 296:\t\t\tif (!node_isset(nid, hugetlb_bootmem_nodes)) {\n 297:\t\t\t\tpr_warn(\"hugetlb_cma: invalid node %d specified\\n\", nid);\n 298:\t\t\t} else if (!IS_ALIGNED(size, gigantic_page_size)) {\n 299:\t\t\t\tpr_warn(\"hugetlb_cma: cma area of node %d must be a multiple of %lu MiB\\n\",\n 300:\t\t\t\t\tnid, gigantic_page_size / SZ_1M);\n 301:\t\t\t} else {\n 302:\t\t\t\tnode_specific_cma_alloc = true;\n 303:\t\t\t\tcontinue;\n 304:\t\t\t}\n 305:\t\n 306:\t\t\thugetlb_cma_size -= size;\n 307:\t\t\thugetlb_cma_size_in_node[nid] = 0;\n 308:\t\t}\n 309:\t\n 310:\t\t/* Validate the CMA size again in case some invalid nodes specified. */\n 311:\t\tif (!hugetlb_cma_size)\n 312:\t\t\treturn;\n 313:\t\n 314:\t\tif (!IS_ALIGNED(hugetlb_cma_size, gigantic_page_size)) {\n 315:\t\t\tpr_warn(\"hugetlb_cma: cma area must be a multiple of %lu MiB\\n\",\n 316:\t\t\t\tgigantic_page_size / SZ_1M);\n 317:\t\t\thugetlb_cma_size = 0;\n 318:\t\t\treturn;\n 319:\t\t}\n 320:\t\n 321:\t\tif (!node_specific_cma_alloc) {\n 322:\t\t\t/*\n 323:\t\t\t * If 3 GB area is requested on a machine with 4 numa nodes,\n 324:\t\t\t * let's allocate 1 GB on first three nodes and ignore the last one.\n 325:\t\t\t */\n 326:\t\t\tper_node = DIV_ROUND_UP(hugetlb_cma_size,\n 327:\t\t\t\t\t\tnodes_weight(hugetlb_bootmem_nodes));\n 328:\t\t\tper_node = round_up(per_node, gigantic_page_size);\n 329:\t\t\tif (hugetlb_cma_percent)\n 330:\t\t\t\tpr_info(\"hugetlb_cma: reserve %lu MiB (%u%%), up to %lu MiB per node\\n\",\n 331:\t\t\t\t\thugetlb_cma_size / SZ_1M, hugetlb_cma_percent,\n 332:\t\t\t\t\tper_node / SZ_1M);\n 333:\t\t\telse\n 334:\t\t\t\tpr_info(\"hugetlb_cma: reserve %lu MiB, up to %lu MiB per node\\n\",\n 335:\t\t\t\t\thugetlb_cma_size / SZ_1M, per_node / SZ_1M);\n 336:\t\t}\n 337:\t\n 338:\t\treserved = 0;\n 339:\t\tfor_each_node_mask(nid, hugetlb_bootmem_nodes) {\n 340:\t\t\tint res;\n 341:\t\t\tchar name[CMA_MAX_NAME];\n 342:\t\n 343:\t\t\tif (node_specific_cma_alloc) {\n 344:\t\t\t\tif (hugetlb_cma_size_in_node[nid] == 0)\n 345:\t\t\t\t\tcontinue;\n 346:\t\n 347:\t\t\t\tsize = hugetlb_cma_size_in_node[nid];\n 348:\t\t\t} else {\n 349:\t\t\t\tsize = min(per_node, hugetlb_cma_size - reserved);\n 350:\t\t\t}\n 351:\t\n 352:\t\t\tsnprintf(name, sizeof(name), \"hugetlb%d\", nid);\n 353:\t\t\t/*\n 354:\t\t\t * Note that 'order per bit' is based on smallest size that\n 355:\t\t\t * may be returned to CMA allocator in the case of\n 356:\t\t\t * huge page demotion.\n 357:\t\t\t */\n 358:\t\t\tres = cma_declare_contiguous_multi(size, gigantic_page_size,\n 359:\t\t\t\t\t\tHUGETLB_PAGE_ORDER, name,\n 360:\t\t\t\t\t\t\u0026hugetlb_cma[nid], nid);\n 361:\t\t\tif (res || !cma_validate_zones(hugetlb_cma[nid])) {\n 362:\t\t\t\tpr_warn(\"hugetlb_cma: %s: err %d, node %d\\n\",\n 363:\t\t\t\t\tres ? \"reservation failed\" : \"reserved area spans zones\",\n 364:\t\t\t\t\tres, nid);\n 365:\t\t\t\thugetlb_cma[nid] = NULL;\n 366:\t\t\t\tcontinue;\n 367:\t\t\t}\n 368:\t\n 369:\t\t\treserved += size;\n 370:\t\t\tif (hugetlb_cma_percent_in_node[nid])\n"
} |
| 15/2 | 2026/11/09 13:25 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18603 output: 170 thoughts: 8255 Thoughts: **Analysis of CMA Code Reachability for Fuzzing** Okay, so I'm looking at this patch and trying to figure out if it's worth fuzzing with syzkaller. The code touches `hugetlb_cma_reserve()`, which uses `cma_declare_contiguous_multi()`, and that calls a couple of other helper functions. My initial thought is to check if these routines can ever be called by a syzkaller test case. However, all these functions are marked with `__init`, and they live in the `.init.text` section. This makes my brain start to race! I remember from the guidelines that fuzzing is only useful for code that *actually* executes in a standard virtual environment like QEMU. Syzkaller works by sending syscalls from user space *after* the system has booted. The `.init.text` section and data are freed early during the kernel's initialization process, specifically by the `free_initmem()` function, which is called *before* syzkaller's user-space fuzzing logic can even connect to the VM. So, all this `__init` code is completely unavailable to the fuzzer. It's essentially gone by the time syzkaller starts sending syscalls. I checked the code and verified the functions and data structures. It seems like the core issue is whether or not anything modified by the patch is reachable after the kernel boots. The patch touches code in `mm/cma.c`, but it's *all* `__init` code! The changes are all boot-time memory reservation and initialization functions and data. The changes deal with reserving memory blocks during early boot and filling the `cma->ranges` array, which does get sorted, just as before. Importantly, I also did a careful review of the patch, and did not find *any* modification of runtime code, which is code that *could* be reached by syzkaller. I also double-checked to see that the `hugetlb_cma` command line parameter is required, and even if it's there, then it first tries normal allocation. I'm focusing on the reachability requirement, as it's the primary factor here. The "unreachable execution paths" category in the guidelines seems to fit exactly. The fuzzing guidance emphasizes that we only fuzz code that is actually *reachable*. The modifications in this patch are strictly for early boot, and therefore strictly unreachable. Even if someone were to try to use focus symbols on a function like `cma_declare_contiguous_multi`, it would never hit that code because syzkaller can only execute code that is active at runtime, not during early boot. I've carefully considered whether the fact that QEMU boots would make boot-time code reachable. However, that isn't the point. Fuzzing involves a syzkaller executor that is *itself* running as a user-space process and sends system calls. These early boot code paths are never entered during normal runtime operation. So, after this rigorous evaluation, it's clear: this patch doesn't warrant fuzzing. |
| 16/2 | 2026/11/09 13:27 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "All functions modified, added, or removed in this patch (cma_declare_contiguous_multi, cma_find_free_range, and cma_range_cmp) are marked __init and are exclusively called during early boot initialization (via mm_core_init_early() -\u003e hugetlb_cma_reserve()). All __init text and data are freed and unmapped by free_initmem() before userspace starts and syzkaller begins runtime syscall fuzzing. No runtime CMA logic, data structures, or post-boot execution paths are modified. Because the altered code is structurally unreachable during fuzzing, fuzzing with syzkaller is not warranted.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "All functions modified, added, or removed in this patch (cma_declare_contiguous_multi, cma_find_free_range, and cma_range_cmp) are marked __init and are exclusively called during early boot initialization (via mm_core_init_early() -\u003e hugetlb_cma_reserve()). All __init text and data are freed and unmapped by free_initmem() before userspace starts and syzkaller begins runtime syscall fuzzing. No runtime CMA logic, data structures, or post-boot execution paths are modified. Because the altered code is structurally unreachable during fuzzing, fuzzing with syzkaller is not warranted.",
"WorthFuzzing": false
} |
| 17/1 | 2026/11/09 13:27 | action | If |
0mArgs:{
"WorthFuzzing": false
}Results: null |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|