| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/11/18 16:11 | flow | patch-triage |
6mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch adds percentage and subtraction support to the 'cma_pernuma' and 'numa_cma' boot command-line parameters. All modified and newly introduced functions (numa_cma_parse_size, numa_cma_parse, early_numa_cma, early_cma_pernuma, numa_cma_node_size, numa_cma_pct_size, dma_numa_cma_reserve) and variables are marked __init or __initdata. They execute strictly during early boot before userspace initialization and are discarded (via free_initmem()). Because syzkaller executes from userspace after boot and cannot fuzz early boot command-line parsing, the modified code is structurally unreachable at runtime.",
"WorthFuzzing": false
} |
| 1/1 | 2026/11/18 16:11 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 7800a8e81038378a80b94244deac9b9082399e02\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Wed Nov 18 16:11:02 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt\nindex 0b3c140babd944..d132b14ba4f73a 100644\n--- a/Documentation/admin-guide/kernel-parameters.txt\n+++ b/Documentation/admin-guide/kernel-parameters.txt\n@@ -862,10 +862,13 @@ Kernel parameters\n \t\t\tcontiguous memory allocations and optionally the\n \t\t\tplacement constraint by the physical address range of\n \t\t\tmemory allocations. A value of 0 disables CMA\n-\t\t\taltogether. For more information, see\n+\t\t\taltogether. The size is absolute; only 'cma_pernuma='\n+\t\t\tand 'numa_cma=' accept a percentage. Without 'cma=',\n+\t\t\tCONFIG_CMA_SIZE_PERCENTAGE can size this area as a\n+\t\t\tfraction of memory. For more information, see\n \t\t\tkernel/dma/contiguous.c\n \n-\tcma_pernuma=nn[MG]\n+\tcma_pernuma=nn[MG]|nn%[-nn[MG]]\n \t\t\t[KNL,CMA,EARLY]\n \t\t\tSets the size of kernel per-numa memory area for\n \t\t\tcontiguous memory allocations. A value of 0 disables\n@@ -875,14 +878,34 @@ Kernel parameters\n \t\t\tfirst try to allocate buffer from the pernuma area\n \t\t\twhich is located in node nid, if the allocation fails,\n \t\t\tthey will fallback to the global default memory area.\n-\n-\tnuma_cma=\u003cnode\u003e:nn[MG][,\u003cnode\u003e:nn[MG]]\n+\t\t\tThe size may also be a decimal percentage of each\n+\t\t\tnode's memory as memblock sees it at boot, optionally\n+\t\t\tless a size to keep back, so cma_pernuma=95%-1G\n+\t\t\treserves 95% of each node minus 1G. Hot-added memory is\n+\t\t\tnot counted. A nonzero percentage that leaves nothing\n+\t\t\tto reserve on a node warns and reserves nothing there.\n+\t\t\tIf the option is given more than once, the last valid\n+\t\t\tvalue counts. An invalid value is ignored, and it still\n+\t\t\tstops CONFIG_CMA_SIZE_PERNUMA from mirroring the\n+\t\t\tdefault area onto every node.\n+\n+\tnuma_cma=\u003cnode\u003e:nn[MG]|nn%[-nn[MG]][,\u003cnode\u003e:nn[MG]|nn%[-nn[MG]]]\n \t\t\t[KNL,CMA,EARLY]\n \t\t\tSets the size of kernel numa memory area for\n \t\t\tcontiguous memory allocations. It will reserve CMA\n-\t\t\tarea for the specified node.\n-\n-\t\t\tIf it is setup together with upper 'cmd_pernuma='\n+\t\t\tarea for the specified node. A size may also be a\n+\t\t\tpercentage of that node's memory, optionally less a\n+\t\t\tsize to keep back, as for 'cma_pernuma='. A size of 0\n+\t\t\tor 0% is the same as not naming the node, so it falls\n+\t\t\tback to 'cma_pernuma='. A nonzero percentage that\n+\t\t\tleaves nothing to reserve does not fall back. If a node\n+\t\t\tis named more than once, also across several numa_cma=\n+\t\t\toptions, the last valid size counts. An entry that does\n+\t\t\tnot parse, including an empty list or a trailing comma,\n+\t\t\tmakes the kernel ignore that whole option, and the\n+\t\t\tdefault area is not mirrored either.\n+\n+\t\t\tIf it is set up together with upper 'cma_pernuma='\n \t\t\t(unlikely), its size setting takes priority for the\n \t\t\tspecified numa nodes.\n \ndiff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c\nindex 90937dc7c627d7..ea094d2238136d 100644\n--- a/kernel/dma/contiguous.c\n+++ b/kernel/dma/contiguous.c\n@@ -39,8 +39,10 @@\n \n #include \u003casm/page.h\u003e\n \n+#include \u003clinux/ctype.h\u003e\n #include \u003clinux/memblock.h\u003e\n #include \u003clinux/err.h\u003e\n+#include \u003clinux/math64.h\u003e\n #include \u003clinux/sizes.h\u003e\n #include \u003clinux/dma-map-ops.h\u003e\n #include \u003clinux/cma.h\u003e\n@@ -135,45 +137,135 @@ EXPORT_SYMBOL_GPL(dev_get_cma_area);\n static struct cma *dma_contiguous_numa_area[MAX_NUMNODES];\n static phys_addr_t numa_cma_size[MAX_NUMNODES] __initdata;\n static phys_addr_t pernuma_size_bytes __initdata;\n+static unsigned int numa_cma_pct[MAX_NUMNODES] __initdata;\n+static unsigned int pernuma_pct __initdata;\n+static phys_addr_t numa_cma_sub[MAX_NUMNODES] __initdata;\n+static phys_addr_t pernuma_sub __initdata;\n static bool numa_cma_configured __initdata;\n \n-static int __init early_numa_cma(char *p)\n+/*\n+ * What numa_cma_parse() does with a string it accepts: NUMA_CMA_CHECK leaves\n+ * everything outside the function as it is, so a caller can validate the\n+ * whole string before NUMA_CMA_APPLY lets any part of it take effect.\n+ */\n+enum numa_cma_action {\n+\tNUMA_CMA_CHECK,\n+\tNUMA_CMA_APPLY,\n+};\n+\n+/*\n+ * Parse one CMA size, either a size or \u003cpercent\u003e%[-\u003csize\u003e], and advance *s past\n+ * it. A percentage is a plain decimal number up to 100. Exactly one of *size and\n+ * *pct describes the result, so the last size given replaces any earlier one.\n+ */\n+static int __init numa_cma_parse_size(char **s, phys_addr_t *size,\n+\t\t\t\t unsigned int *pct, phys_addr_t *sub)\n+{\n+\tunsigned long long val;\n+\tunsigned int n;\n+\tchar *start = *s;\n+\tint count;\n+\n+\tif (isdigit(*start) \u0026\u0026 sscanf(start, \"%3u%n\", \u0026n, \u0026count) == 1 \u0026\u0026\n+\t start[count] == '%') {\n+\t\tif (n \u003e 100)\n+\t\t\treturn -EINVAL;\n+\t\t*s = start + count + 1;\n+\t\tval = 0;\n+\t\tif (**s == '-') {\n+\t\t\tstart = ++*s;\n+\t\t\tval = memparse(start, s);\n+\t\t\tif (*s == start || val != (phys_addr_t)val)\n+\t\t\t\treturn -EINVAL;\n+\t\t}\n+\t\t*size = 0;\n+\t\t*pct = n;\n+\t\t*sub = val;\n+\t\treturn 0;\n+\t}\n+\n+\tval = memparse(start, s);\n+\tif (*s == start || val != (phys_addr_t)val)\n+\t\treturn -EINVAL;\n+\t*size = val;\n+\t*pct = 0;\n+\t*sub = 0;\n+\treturn 0;\n+}\n+\n+/*\n+ * Parse one numa_cma= string: a comma separated list of \u003cnode\u003e:\u003csize\u003e, where\n+ * \u003csize\u003e is a size or \u003cpercent\u003e%[-\u003csize\u003e]. Anything else fails the parse.\n+ */\n+static int __init numa_cma_parse(char *p, enum numa_cma_action action)\n {\n \tint nid, count = 0;\n \tunsigned long node;\n-\tphys_addr_t size;\n+\tphys_addr_t size, sub;\n+\tunsigned int pct;\n \tchar *s = p;\n \n-\twhile (*s) {\n-\t\tif (sscanf(s, \"%lu%n\", \u0026node, \u0026count) != 1)\n-\t\t\tbreak;\n-\n-\t\tif (s[count] == ':') {\n-\t\t\tif (node \u003e= MAX_NUMNODES)\n-\t\t\t\tbreak;\n-\t\t\tnid = array_index_nospec(node, MAX_NUMNODES);\n-\n-\t\t\ts += count + 1;\n-\t\t\tsize = memparse(s, \u0026s);\n+\tfor (;;) {\n+\t\tif (!isdigit(*s) ||\n+\t\t sscanf(s, \"%4lu%n\", \u0026node, \u0026count) != 1 || s[count] != ':' ||\n+\t\t node \u003e= MAX_NUMNODES)\n+\t\t\treturn -EINVAL;\n+\t\tnid = array_index_nospec(node, MAX_NUMNODES);\n+\n+\t\ts += count + 1;\n+\t\tif (numa_cma_parse_size(\u0026s, \u0026size, \u0026pct, \u0026sub))\n+\t\t\treturn -EINVAL;\n+\t\tif (action == NUMA_CMA_APPLY) {\n \t\t\tnuma_cma_size[nid] = size;\n+\t\t\tnuma_cma_pct[nid] = pct;\n+\t\t\tnuma_cma_sub[nid] = sub;\n+\t\t}\n \n-\t\t\tif (*s == ',')\n-\t\t\t\ts++;\n-\t\t\telse\n-\t\t\t\tbreak;\n-\t\t} else\n-\t\t\tbreak;\n+\t\tif (!*s)\n+\t\t\treturn 0;\n+\t\tif (*s != ',')\n+\t\t\treturn -EINVAL;\n+\t\ts++;\n \t}\n+}\n \n+static int __init early_numa_cma(char *p)\n+{\n+\tint rc;\n+\n+\t/*\n+\t * Per-node CMA is configured either way. Leaving the flag clear on a\n+\t * string this rejects would tell dma_numa_cma_reserve() that nobody\n+\t * asked for per-node areas, and on a CMA_SIZE_PERNUMA kernel it would\n+\t * then clone the default area onto every node.\n+\t */\n \tnuma_cma_configured = true;\n-\treturn 0;\n+\n+\tif (!p)\n+\t\treturn -EINVAL;\n+\n+\trc = numa_cma_parse(p, NUMA_CMA_CHECK);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\treturn numa_cma_parse(p, NUMA_CMA_APPLY);\n }\n early_param(\"numa_cma\", early_numa_cma);\n \n static int __init early_cma_pernuma(char *p)\n {\n-\tpernuma_size_bytes = memparse(p, \u0026p);\n+\tphys_addr_t size, sub;\n+\tunsigned int pct;\n+\n+\t/* See early_numa_cma(): a rejected string still counts as configured. */\n \tnuma_cma_configured = true;\n+\n+\tif (!p || numa_cma_parse_size(\u0026p, \u0026size, \u0026pct, \u0026sub) || *p)\n+\t\treturn -EINVAL;\n+\n+\tpernuma_size_bytes = size;\n+\tpernuma_pct = pct;\n+\tpernuma_sub = sub;\n \treturn 0;\n }\n early_param(\"cma_pernuma\", early_cma_pernuma);\n@@ -198,6 +290,33 @@ static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)\n #endif\n \n #ifdef CONFIG_DMA_NUMA_CMA\n+static phys_addr_t __init numa_cma_node_size(int nid)\n+{\n+\tunsigned long spfn, epfn;\n+\tphys_addr_t total = 0;\n+\tint i;\n+\n+\tfor_each_mem_pfn_range(i, nid, \u0026spfn, \u0026epfn, NULL)\n+\t\ttotal += (u64)(epfn - spfn) \u003c\u003c PAGE_SHIFT;\n+\n+\treturn total;\n+}\n+\n+/*\n+ * A percentage of the node, less the size the boot line asked to keep back.\n+ * Keeping back more than the percentage came to reserves nothing.\n+ */\n+static phys_addr_t __init numa_cma_pct_size(int nid, unsigned int pct,\n+\t\t\t\t\t phys_addr_t sub)\n+{\n+\tphys_addr_t size = mul_u64_u32_div(numa_cma_node_size(nid), pct, 100);\n+\n+\tif (size \u003c= sub)\n+\t\treturn 0;\n+\n+\treturn size - sub;\n+}\n+\n static void __init dma_numa_cma_reserve(void)\n {\n \tint nid;\n@@ -214,15 +333,36 @@ static void __init dma_numa_cma_reserve(void)\n \t\tint ret;\n \n \t\tif (!node_online(nid)) {\n-\t\t\tif (pernuma_size_bytes || numa_cma_size[nid])\n+\t\t\tif (pernuma_size_bytes || pernuma_pct ||\n+\t\t\t numa_cma_size[nid] || numa_cma_pct[nid])\n \t\t\t\tpr_warn(\"invalid node %d specified\\n\", nid);\n \t\t\tcontinue;\n \t\t}\n \n \t\t/* per-node numa setting has the priority */\n-\t\tsize = numa_cma_size[nid] ?: pernuma_size_bytes;\n-\t\tif (!size)\n+\t\tif (numa_cma_size[nid])\n+\t\t\tsize = numa_cma_size[nid];\n+\t\telse if (numa_cma_pct[nid])\n+\t\t\tsize = numa_cma_pct_size(nid, numa_cma_pct[nid],\n+\t\t\t\t\t\t numa_cma_sub[nid]);\n+\t\telse if (pernuma_size_bytes)\n+\t\t\tsize = pernuma_size_bytes;\n+\t\telse if (pernuma_pct)\n+\t\t\tsize = numa_cma_pct_size(nid, pernuma_pct, pernuma_sub);\n+\t\telse\n+\t\t\tcontinue;\n+\n+\t\t/*\n+\t\t * A percentage of a memoryless online node, and a percentage\n+\t\t * entirely consumed by the size kept back, resolve to nothing\n+\t\t * to reserve. Say so, since the operator asked for memory.\n+\t\t */\n+\t\tif (!size) {\n+\t\t\tif (numa_cma_pct[nid] || pernuma_pct)\n+\t\t\t\tpr_warn(\"node %d percentage reserves nothing\\n\",\n+\t\t\t\t\tnid);\n \t\t\tcontinue;\n+\t\t}\n \n \t\tcma = \u0026dma_contiguous_numa_area[nid];\n \t\tsnprintf(name, sizeof(name), \"numa%d\", nid);\n"
} |
| 2/1 | 2026/11/18 16:11 | agent | patch-evaluator |
6mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch adds percentage and subtraction support to the 'cma_pernuma' and 'numa_cma' boot command-line parameters. All modified and newly introduced functions (numa_cma_parse_size, numa_cma_parse, early_numa_cma, early_cma_pernuma, numa_cma_node_size, numa_cma_pct_size, dma_numa_cma_reserve) and variables are marked __init or __initdata. They execute strictly during early boot before userspace initialization and are discarded (via free_initmem()). Because syzkaller executes from userspace after boot and cannot fuzz early boot command-line parsing, the modified code is structurally unreachable at runtime.",
"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 7800a8e81038378a80b94244deac9b9082399e02
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Nov 18 16:11:02 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 0b3c140babd944..d132b14ba4f73a 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -862,10 +862,13 @@ Kernel parameters
contiguous memory allocations and optionally the
placement constraint by the physical address range of
memory allocations. A value of 0 disables CMA
- altogether. For more information, see
+ altogether. The size is absolute; only 'cma_pernuma='
+ and 'numa_cma=' accept a percentage. Without 'cma=',
+ CONFIG_CMA_SIZE_PERCENTAGE can size this area as a
+ fraction of memory. For more information, see
kernel/dma/contiguous.c
- cma_pernuma=nn[MG]
+ cma_pernuma=nn[MG]|nn%[-nn[MG]]
[KNL,CMA,EARLY]
Sets the size of kernel per-numa memory area for
contiguous memory allocations. A value of 0 disables
@@ -875,14 +878,34 @@ Kernel parameters
first try to allocate buffer from the pernuma area
which is located in node nid, if the allocation fails,
they will fallback to the global default memory area.
-
- numa_cma=<node>:nn[MG][,<node>:nn[MG]]
+ The size may also be a decimal percentage of each
+ node's memory as memblock sees it at boot, optionally
+ less a size to keep back, so cma_pernuma=95%-1G
+ reserves 95% of each node minus 1G. Hot-added memory is
+ not counted. A nonzero percentage that leaves nothing
+ to reserve on a node warns and reserves nothing there.
+ If the option is given more than once, the last valid
+ value counts. An invalid value is ignored, and it still
+ stops CONFIG_CMA_SIZE_PERNUMA from mirroring the
+ default area onto every node.
+
+ numa_cma=<node>:nn[MG]|nn%[-nn[MG]][,<node>:nn[MG]|nn%[-nn[MG]]]
[KNL,CMA,EARLY]
Sets the size of kernel numa memory area for
contiguous memory allocations. It will reserve CMA
- area for the specified node.
-
- If it is setup together with upper 'cmd_pernuma='
+ area for the specified node. A size may also be a
+ percentage of that node's memory, optionally less a
+ size to keep back, as for 'cma_pernuma='. A size of 0
+ or 0% is the same as not naming the node, so it falls
+ back to 'cma_pernuma='. A nonzero percentage that
+ leaves nothing to reserve does not fall back. If a node
+ is named more than once, also across several numa_cma=
+ options, the last valid size counts. An entry that does
+ not parse, including an empty list or a trailing comma,
+ makes the kernel ignore that whole option, and the
+ default area is not mirrored either.
+
+ If it is set up together with upper 'cma_pernuma='
(unlikely), its size setting takes priority for the
specified numa nodes.
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 90937dc7c627d7..ea094d2238136d 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -39,8 +39,10 @@
#include <asm/page.h>
+#include <linux/ctype.h>
#include <linux/memblock.h>
#include <linux/err.h>
+#include <linux/math64.h>
#include <linux/sizes.h>
#include <linux/dma-map-ops.h>
#include <linux/cma.h>
@@ -135,45 +137,135 @@ EXPORT_SYMBOL_GPL(dev_get_cma_area);
static struct cma *dma_contiguous_numa_area[MAX_NUMNODES];
static phys_addr_t numa_cma_size[MAX_NUMNODES] __initdata;
static phys_addr_t pernuma_size_bytes __initdata;
+static unsigned int numa_cma_pct[MAX_NUMNODES] __initdata;
+static unsigned int pernuma_pct __initdata;
+static phys_addr_t numa_cma_sub[MAX_NUMNODES] __initdata;
+static phys_addr_t pernuma_sub __initdata;
static bool numa_cma_configured __initdata;
-static int __init early_numa_cma(char *p)
+/*
+ * What numa_cma_parse() does with a string it accepts: NUMA_CMA_CHECK leaves
+ * everything outside the function as it is, so a caller can validate the
+ * whole string before NUMA_CMA_APPLY lets any part of it take effect.
+ */
+enum numa_cma_action {
+ NUMA_CMA_CHECK,
+ NUMA_CMA_APPLY,
+};
+
+/*
+ * Parse one CMA size, either a size or <percent>%[-<size>], and advance *s past
+ * it. A percentage is a plain decimal number up to 100. Exactly one of *size and
+ * *pct describes the result, so the last size given replaces any earlier one.
+ */
+static int __init numa_cma_parse_size(char **s, phys_addr_t *size,
+ unsigned int *pct, phys_addr_t *sub)
+{
+ unsigned long long val;
+ unsigned int n;
+ char *start = *s;
+ int count;
+
+ if (isdigit(*start) && sscanf(start, "%3u%n", &n, &count) == 1 &&
+ start[count] == '%') {
+ if (n > 100)
+ return -EINVAL;
+ *s = start + count + 1;
+ val = 0;
+ if (**s == '-') {
+ start = ++*s;
+ val = memparse(start, s);
+ if (*s == start || val != (phys_addr_t)val)
+ return -EINVAL;
+ }
+ *size = 0;
+ *pct = n;
+ *sub = val;
+ return 0;
+ }
+
+ val = memparse(start, s);
+ if (*s == start || val != (phys_addr_t)val)
+ return -EINVAL;
+ *size = val;
+ *pct = 0;
+ *sub = 0;
+ return 0;
+}
+
+/*
+ * Parse one numa_cma= string: a comma separated list of <node>:<size>, where
+ * <size> is a size or <percent>%[-<size>]. Anything else fails the parse.
+ */
+static int __init numa_cma_parse(char *p, enum numa_cma_action action)
{
int nid, count = 0;
unsigned long node;
- phys_addr_t size;
+ phys_addr_t size, sub;
+ unsigned int pct;
char *s = p;
- while (*s) {
- if (sscanf(s, "%lu%n", &node, &count) != 1)
- break;
-
- if (s[count] == ':') {
- if (node >= MAX_NUMNODES)
- break;
- nid = array_index_nospec(node, MAX_NUMNODES);
-
- s += count + 1;
- size = memparse(s, &s);
+ for (;;) {
+ if (!isdigit(*s) ||
+ sscanf(s, "%4lu%n", &node, &count) != 1 || s[count] != ':' ||
+ node >= MAX_NUMNODES)
+ return -EINVAL;
+ nid = array_index_nospec(node, MAX_NUMNODES);
+
+ s += count + 1;
+ if (numa_cma_parse_size(&s, &size, &pct, &sub))
+ return -EINVAL;
+ if (action == NUMA_CMA_APPLY) {
numa_cma_size[nid] = size;
+ numa_cma_pct[nid] = pct;
+ numa_cma_sub[nid] = sub;
+ }
- if (*s == ',')
- s++;
- else
- break;
- } else
- break;
+ if (!*s)
+ return 0;
+ if (*s != ',')
+ return -EINVAL;
+ s++;
}
+}
+static int __init early_numa_cma(char *p)
+{
+ int rc;
+
+ /*
+ * Per-node CMA is configured either way. Leaving the flag clear on a
+ * string this rejects would tell dma_numa_cma_reserve() that nobody
+ * asked for per-node areas, and on a CMA_SIZE_PERNUMA kernel it would
+ * then clone the default area onto every node.
+ */
numa_cma_configured = true;
- return 0;
+
+ if (!p)
+ return -EINVAL;
+
+ rc = numa_cma_parse(p, NUMA_CMA_CHECK);
+ if (rc)
+ return rc;
+
+ return numa_cma_parse(p, NUMA_CMA_APPLY);
}
early_param("numa_cma", early_numa_cma);
static int __init early_cma_pernuma(char *p)
{
- pernuma_size_bytes = memparse(p, &p);
+ phys_addr_t size, sub;
+ unsigned int pct;
+
+ /* See early_numa_cma(): a rejected string still counts as configured. */
numa_cma_configured = true;
+
+ if (!p || numa_cma_parse_size(&p, &size, &pct, &sub) || *p)
+ return -EINVAL;
+
+ pernuma_size_bytes = size;
+ pernuma_pct = pct;
+ pernuma_sub = sub;
return 0;
}
early_param("cma_pernuma", early_cma_pernuma);
@@ -198,6 +290,33 @@ static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)
#endif
#ifdef CONFIG_DMA_NUMA_CMA
+static phys_addr_t __init numa_cma_node_size(int nid)
+{
+ unsigned long spfn, epfn;
+ phys_addr_t total = 0;
+ int i;
+
+ for_each_mem_pfn_range(i, nid, &spfn, &epfn, NULL)
+ total += (u64)(epfn - spfn) << PAGE_SHIFT;
+
+ return total;
+}
+
+/*
+ * A percentage of the node, less the size the boot line asked to keep back.
+ * Keeping back more than the percentage came to reserves nothing.
+ */
+static phys_addr_t __init numa_cma_pct_size(int nid, unsigned int pct,
+ phys_addr_t sub)
+{
+ phys_addr_t size = mul_u64_u32_div(numa_cma_node_size(nid), pct, 100);
+
+ if (size <= sub)
+ return 0;
+
+ return size - sub;
+}
+
static void __init dma_numa_cma_reserve(void)
{
int nid;
@@ -214,15 +333,36 @@ static void __init dma_numa_cma_reserve(void)
int ret;
if (!node_online(nid)) {
- if (pernuma_size_bytes || numa_cma_size[nid])
+ if (pernuma_size_bytes || pernuma_pct ||
+ numa_cma_size[nid] || numa_cma_pct[nid])
pr_warn("invalid node %d specified\n", nid);
continue;
}
/* per-node numa setting has the priority */
- size = numa_cma_size[nid] ?: pernuma_size_bytes;
- if (!size)
+ if (numa_cma_size[nid])
+ size = numa_cma_size[nid];
+ else if (numa_cma_pct[nid])
+ size = numa_cma_pct_size(nid, numa_cma_pct[nid],
+ numa_cma_sub[nid]);
+ else if (pernuma_size_bytes)
+ size = pernuma_size_bytes;
+ else if (pernuma_pct)
+ size = numa_cma_pct_size(nid, pernuma_pct, pernuma_sub);
+ else
+ continue;
+
+ /*
+ * A percentage of a memoryless online node, and a percentage
+ * entirely consumed by the size kept back, resolve to nothing
+ * to reserve. Say so, since the operator asked for memory.
+ */
+ if (!size) {
+ if (numa_cma_pct[nid] || pernuma_pct)
+ pr_warn("node %d percentage reserves nothing\n",
+ nid);
continue;
+ }
cma = &dma_contiguous_numa_area[nid];
snprintf(name, sizeof(name), "numa%d", nid);
|
| 3/2 | 2026/11/18 16:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 6444 output: 51 thoughts: 329 Thoughts: **Analyzing the Kernel Patch Series**
Okay, so I'm being asked to evaluate this kernel patch. My initial thought is to dive right into the diff and get a handle on exactly what's being changed. The file changes are in `Documentation/admin-guide/kernel-parameters.txt` and `kernel/dma/contiguous.c`, which immediately suggests changes to kernel parameters and contiguous memory allocation. Interesting!
Focusing on `kernel/dma/contiguous.c`, it looks like there's new functionality related to `cma_pernuma` and `numa_cma` kernel command-line parameters. Specifically, the patch is enabling percentage and subtraction support, which could be quite useful for finer-grained control over CMA (Contiguous Memory Allocator) reservations, especially in NUMA (Non-Uniform Memory Access) systems. I see the addition of `early_param` calls: `early_param("numa_cma", early_numa_cma);` and `early_param("cma_pernuma", early_cma_pernuma);`. This tells me these parameters are processed very early in the boot process.
I'm noting the changes involve several new functions: `numa_cma_parse_size`, `numa_cma_parse`, `early_numa_cma`, `early_cma_pernuma`, `numa_cma_node_size`, `numa_cma_pct_size`, and `dma_numa_cma_reserve`. The `__init` attribute on those functions is a key indicator. This confirms they're only executed during the early boot phase. That's good to know, and it makes sense, given these parameters affect memory allocation at the start.
Now I need to clarify how these new functions are used. Specifically, I need to see exactly how `dma_numa_cma_reserve`, `early_numa_cma`, and `early_cma_pernuma` are called within `kernel/dma/contiguous.c`. I'll use `grepper` (or `read-file` if that's easier) to do a deeper dive into the file and trace their usage. I'll need to understand the control flow to assess the impact of these changes fully.
|
| 4/2 | 2026/11/18 16:11 | tool | grepper |
0mArgs:{
"Expression": "dma_numa_cma_reserve",
"PathPrefixes": [
"kernel/dma/",
"include/",
"mm/",
"arch/"
]
}Results: {
"Output": "kernel/dma/contiguous.c=232=static int __init early_numa_cma(char *p)\n--\nkernel/dma/contiguous.c-237-\t * Per-node CMA is configured either way. Leaving the flag clear on a\nkernel/dma/contiguous.c:238:\t * string this rejects would tell dma_numa_cma_reserve() that nobody\nkernel/dma/contiguous.c-239-\t * asked for per-node areas, and on a CMA_SIZE_PERNUMA kernel it would\n--\nkernel/dma/contiguous.c=309=static phys_addr_t __init numa_cma_pct_size(int nid, unsigned int pct,\n--\nkernel/dma/contiguous.c-319-\nkernel/dma/contiguous.c:320:static void __init dma_numa_cma_reserve(void)\nkernel/dma/contiguous.c-321-{\n--\nkernel/dma/contiguous.c-375-#else\nkernel/dma/contiguous.c:376:static inline void __init dma_numa_cma_reserve(void)\nkernel/dma/contiguous.c-377-{\n--\nkernel/dma/contiguous.c=390=void __init dma_contiguous_reserve(phys_addr_t limit)\n--\nkernel/dma/contiguous.c-452-\nkernel/dma/contiguous.c:453:\tdma_numa_cma_reserve();\nkernel/dma/contiguous.c-454-}\n"
} |
| 5/2 | 2026/11/18 16:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 7723 output: 20 thoughts: 16 Thoughts: Here's a summary of my thought process: **Investigating `dma_contiguous_reserve` Callsites** Okay, so I need to understand the usage of `dma_contiguous_reserve`. My immediate focus is to pinpoint where this function is actually being invoked within the system. I need to track down all the callsites. This is the starting point for understanding how it's being used and, ultimately, its role in the bigger picture. From there I can determine how it relates to everything else. |
| 6/2 | 2026/11/18 16:12 | tool | grepper |
0mArgs:{
"Expression": "dma_contiguous_reserve"
}Results: {
"Output": "arch/arm/mm/init.c=180=void __init arm_memblock_init(const struct machine_desc *mdesc)\n--\narch/arm/mm/init.c-195-\t/* reserve memory for DMA contiguous allocations */\narch/arm/mm/init.c:196:\tdma_contiguous_reserve(arm_dma_limit);\narch/arm/mm/init.c-197-\n--\narch/arm64/mm/init.c=304=void __init bootmem_init(void)\n--\narch/arm64/mm/init.c-323-\t */\narch/arm64/mm/init.c:324:\tdma_contiguous_reserve(arm64_dma_phys_limit);\narch/arm64/mm/init.c-325-\n--\narch/csky/kernel/setup.c=62=static void __init csky_memblock_init(void)\n--\narch/csky/kernel/setup.c-101-\narch/csky/kernel/setup.c:102:\tdma_contiguous_reserve(0);\narch/csky/kernel/setup.c-103-}\n--\narch/loongarch/kernel/setup.c=394=static void __init arch_mem_init(char **cmdline_p)\n--\narch/loongarch/kernel/setup.c-408-\narch/loongarch/kernel/setup.c:409:\tdma_contiguous_reserve(PFN_PHYS(max_low_pfn));\narch/loongarch/kernel/setup.c-410-\n--\narch/microblaze/mm/init.c=165=asmlinkage void __init mmu_init(void)\n--\narch/microblaze/mm/init.c-235-\t/* CMA initialization */\narch/microblaze/mm/init.c:236:\tdma_contiguous_reserve(memory_start + lowmem_size - 1);\narch/microblaze/mm/init.c-237-\n--\narch/mips/kernel/setup.c=557=static void __init bootcmdline_init(void)\n--\narch/mips/kernel/setup.c-622- * o pagetable_init()\narch/mips/kernel/setup.c:623: * o dma_contiguous_reserve()\narch/mips/kernel/setup.c-624- *\n--\narch/mips/kernel/setup.c=633=static void __init arch_mem_init(char **cmdline_p)\n--\narch/mips/kernel/setup.c-673-\narch/mips/kernel/setup.c:674:\tdma_contiguous_reserve(PFN_PHYS(max_low_pfn));\narch/mips/kernel/setup.c-675-\n--\narch/riscv/mm/init.c=1372=void __init misc_mem_init(void)\n--\narch/riscv/mm/init.c-1375-\tarch_numa_init();\narch/riscv/mm/init.c:1376:\tdma_contiguous_reserve(dma32_phys_limit);\narch/riscv/mm/init.c-1377-#ifdef CONFIG_SPARSEMEM_VMEMMAP\n--\narch/s390/kernel/setup.c=897=void __init setup_arch(char **cmdline_p)\n--\narch/s390/kernel/setup.c-963-\tsetup_uv();\narch/s390/kernel/setup.c:964:\tdma_contiguous_reserve(ident_map_size);\narch/s390/kernel/setup.c-965-\tvmcp_cma_reserve();\n--\narch/x86/kernel/setup.c=884=void __init setup_arch(char **cmdline_p)\n--\narch/x86/kernel/setup.c-1203-\tinitmem_init();\narch/x86/kernel/setup.c:1204:\tdma_contiguous_reserve(max_pfn_mapped \u003c\u003c PAGE_SHIFT);\narch/x86/kernel/setup.c-1205-\n--\narch/xtensa/mm/init.c=40=void __init bootmem_init(void)\n--\narch/xtensa/mm/init.c-63-\tmemblock_set_current_limit(PFN_PHYS(max_low_pfn));\narch/xtensa/mm/init.c:64:\tdma_contiguous_reserve(PFN_PHYS(max_low_pfn));\narch/xtensa/mm/init.c-65-\n--\ninclude/linux/dma-map-ops.h=95=struct cma *dma_contiguous_get_area_by_idx(unsigned int idx);\ninclude/linux/dma-map-ops.h-96-\ninclude/linux/dma-map-ops.h:97:void dma_contiguous_reserve(phys_addr_t addr_limit);\ninclude/linux/dma-map-ops.h:98:int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,\ninclude/linux/dma-map-ops.h-99-\t\tphys_addr_t limit, struct cma **res_cma, bool fixed);\n--\ninclude/linux/dma-map-ops.h=114=static inline struct cma *dma_contiguous_get_area_by_idx(unsigned int idx)\n--\ninclude/linux/dma-map-ops.h-117-}\ninclude/linux/dma-map-ops.h:118:static inline void dma_contiguous_reserve(phys_addr_t limit)\ninclude/linux/dma-map-ops.h-119-{\ninclude/linux/dma-map-ops.h-120-}\ninclude/linux/dma-map-ops.h:121:static inline int dma_contiguous_reserve_area(phys_addr_t size,\ninclude/linux/dma-map-ops.h-122-\t\tphys_addr_t base, phys_addr_t limit, struct cma **res_cma,\n--\nkernel/dma/contiguous.c=376=static inline void __init dma_numa_cma_reserve(void)\n--\nkernel/dma/contiguous.c-381-/**\nkernel/dma/contiguous.c:382: * dma_contiguous_reserve() - reserve area(s) for contiguous memory handling\nkernel/dma/contiguous.c-383- * @limit: End address of the reserved memory (optional, 0 for any).\n--\nkernel/dma/contiguous.c-389- */\nkernel/dma/contiguous.c:390:void __init dma_contiguous_reserve(phys_addr_t limit)\nkernel/dma/contiguous.c-391-{\n--\nkernel/dma/contiguous.c-425-\nkernel/dma/contiguous.c:426:\t\tret = dma_contiguous_reserve_area(selected_size, selected_base,\nkernel/dma/contiguous.c-427-\t\t\t\t\t\t selected_limit,\n--\nkernel/dma/contiguous.c=457=dma_contiguous_early_fixup(phys_addr_t base, unsigned long size)\n--\nkernel/dma/contiguous.c-461-/**\nkernel/dma/contiguous.c:462: * dma_contiguous_reserve_area() - reserve custom contiguous area\nkernel/dma/contiguous.c-463- * @size: Size of the reserved area (in bytes),\n--\nkernel/dma/contiguous.c-477- */\nkernel/dma/contiguous.c:478:int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,\nkernel/dma/contiguous.c-479-\t\t\t\t phys_addr_t limit, struct cma **res_cma,\n"
} |
| 7/2 | 2026/11/18 16:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 9899 output: 46 thoughts: 503 Thoughts: **Analyzing Syzkaller's Reachability of Early Boot CMA Allocation** Okay, so I'm looking at these CMA allocation functions, specifically the ones related to NUMA and DMA. I'm noticing that `early_param` functions like `early_numa_cma` and `early_cma_pernuma` are called during kernel boot command-line parsing, and `dma_numa_cma_reserve` is called within `setup_arch()` during early boot. I've got a list here: * `numa_cma_parse_size` (__init) * `numa_cma_parse` (__init) * `early_numa_cma` (__init) * `early_cma_pernuma` (__init) * `numa_cma_node_size` (__init) * `numa_cma_pct_size` (__init) * `dma_numa_cma_reserve` (__init) My initial concern is whether Syzkaller, given its ability to fuzz boot parameters, could potentially reach these early initialization functions. The Syzkaller guidelines emphasize reachability as the key criterion, stating that code unreachable in standard virtualized environments shouldn't be fuzzed. That triggers some thoughts: Can syzkaller reach `__init` functions or boot parameters? Right, the key here is that any function marked `__init` is in the `.init.text` section, and that memory is freed after the kernel boots via `free_initmem()`. Syzkaller executes *after* the kernel has booted. So, there is no way for Syzkaller to directly call `early_param` or `__init` functions. Those functions are long gone. However, I want to confirm that there's no way to invoke them via some runtime configuration or sysfs entries. I will check the kernel code to verify that `numa_cma` or `cma_pernuma` or anything modified is reachable at runtime. Specifically, I should check `kernel/dma/contiguous.c` to look for runtime callers. |
| 8/2 | 2026/11/18 16:13 | tool | grepper |
0mArgs:{
"Expression": "numa_cma|cma_pernuma|pernuma_",
"PathPrefixes": [
"kernel/dma/contiguous.c"
]
}Results: {
"Output": "kernel/dma/contiguous.c=137=static struct cma *dma_contiguous_numa_area[MAX_NUMNODES];\nkernel/dma/contiguous.c:138:static phys_addr_t numa_cma_size[MAX_NUMNODES] __initdata;\nkernel/dma/contiguous.c:139:static phys_addr_t pernuma_size_bytes __initdata;\nkernel/dma/contiguous.c:140:static unsigned int numa_cma_pct[MAX_NUMNODES] __initdata;\nkernel/dma/contiguous.c:141:static unsigned int pernuma_pct __initdata;\nkernel/dma/contiguous.c:142:static phys_addr_t numa_cma_sub[MAX_NUMNODES] __initdata;\nkernel/dma/contiguous.c:143:static phys_addr_t pernuma_sub __initdata;\nkernel/dma/contiguous.c:144:static bool numa_cma_configured __initdata;\nkernel/dma/contiguous.c-145-\nkernel/dma/contiguous.c-146-/*\nkernel/dma/contiguous.c:147: * What numa_cma_parse() does with a string it accepts: NUMA_CMA_CHECK leaves\nkernel/dma/contiguous.c-148- * everything outside the function as it is, so a caller can validate the\n--\nkernel/dma/contiguous.c-150- */\nkernel/dma/contiguous.c:151:enum numa_cma_action {\nkernel/dma/contiguous.c-152-\tNUMA_CMA_CHECK,\n--\nkernel/dma/contiguous.c-160- */\nkernel/dma/contiguous.c:161:static int __init numa_cma_parse_size(char **s, phys_addr_t *size,\nkernel/dma/contiguous.c-162-\t\t\t\t unsigned int *pct, phys_addr_t *sub)\n--\nkernel/dma/contiguous.c-196-/*\nkernel/dma/contiguous.c:197: * Parse one numa_cma= string: a comma separated list of \u003cnode\u003e:\u003csize\u003e, where\nkernel/dma/contiguous.c-198- * \u003csize\u003e is a size or \u003cpercent\u003e%[-\u003csize\u003e]. Anything else fails the parse.\nkernel/dma/contiguous.c-199- */\nkernel/dma/contiguous.c:200:static int __init numa_cma_parse(char *p, enum numa_cma_action action)\nkernel/dma/contiguous.c-201-{\n--\nkernel/dma/contiguous.c-215-\t\ts += count + 1;\nkernel/dma/contiguous.c:216:\t\tif (numa_cma_parse_size(\u0026s, \u0026size, \u0026pct, \u0026sub))\nkernel/dma/contiguous.c-217-\t\t\treturn -EINVAL;\nkernel/dma/contiguous.c-218-\t\tif (action == NUMA_CMA_APPLY) {\nkernel/dma/contiguous.c:219:\t\t\tnuma_cma_size[nid] = size;\nkernel/dma/contiguous.c:220:\t\t\tnuma_cma_pct[nid] = pct;\nkernel/dma/contiguous.c:221:\t\t\tnuma_cma_sub[nid] = sub;\nkernel/dma/contiguous.c-222-\t\t}\n--\nkernel/dma/contiguous.c-231-\nkernel/dma/contiguous.c:232:static int __init early_numa_cma(char *p)\nkernel/dma/contiguous.c-233-{\n--\nkernel/dma/contiguous.c-237-\t * Per-node CMA is configured either way. Leaving the flag clear on a\nkernel/dma/contiguous.c:238:\t * string this rejects would tell dma_numa_cma_reserve() that nobody\nkernel/dma/contiguous.c-239-\t * asked for per-node areas, and on a CMA_SIZE_PERNUMA kernel it would\n--\nkernel/dma/contiguous.c-241-\t */\nkernel/dma/contiguous.c:242:\tnuma_cma_configured = true;\nkernel/dma/contiguous.c-243-\n--\nkernel/dma/contiguous.c-246-\nkernel/dma/contiguous.c:247:\trc = numa_cma_parse(p, NUMA_CMA_CHECK);\nkernel/dma/contiguous.c-248-\tif (rc)\n--\nkernel/dma/contiguous.c-250-\nkernel/dma/contiguous.c:251:\treturn numa_cma_parse(p, NUMA_CMA_APPLY);\nkernel/dma/contiguous.c-252-}\nkernel/dma/contiguous.c:253:early_param(\"numa_cma\", early_numa_cma);\nkernel/dma/contiguous.c-254-\nkernel/dma/contiguous.c:255:static int __init early_cma_pernuma(char *p)\nkernel/dma/contiguous.c-256-{\n--\nkernel/dma/contiguous.c-259-\nkernel/dma/contiguous.c:260:\t/* See early_numa_cma(): a rejected string still counts as configured. */\nkernel/dma/contiguous.c:261:\tnuma_cma_configured = true;\nkernel/dma/contiguous.c-262-\nkernel/dma/contiguous.c:263:\tif (!p || numa_cma_parse_size(\u0026p, \u0026size, \u0026pct, \u0026sub) || *p)\nkernel/dma/contiguous.c-264-\t\treturn -EINVAL;\nkernel/dma/contiguous.c-265-\nkernel/dma/contiguous.c:266:\tpernuma_size_bytes = size;\nkernel/dma/contiguous.c:267:\tpernuma_pct = pct;\nkernel/dma/contiguous.c:268:\tpernuma_sub = sub;\nkernel/dma/contiguous.c-269-\treturn 0;\nkernel/dma/contiguous.c-270-}\nkernel/dma/contiguous.c:271:early_param(\"cma_pernuma\", early_cma_pernuma);\nkernel/dma/contiguous.c-272-#endif\n--\nkernel/dma/contiguous.c=285=static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)\n--\nkernel/dma/contiguous.c-292-#ifdef CONFIG_DMA_NUMA_CMA\nkernel/dma/contiguous.c:293:static phys_addr_t __init numa_cma_node_size(int nid)\nkernel/dma/contiguous.c-294-{\n--\nkernel/dma/contiguous.c-308- */\nkernel/dma/contiguous.c:309:static phys_addr_t __init numa_cma_pct_size(int nid, unsigned int pct,\nkernel/dma/contiguous.c-310-\t\t\t\t\t phys_addr_t sub)\nkernel/dma/contiguous.c-311-{\nkernel/dma/contiguous.c:312:\tphys_addr_t size = mul_u64_u32_div(numa_cma_node_size(nid), pct, 100);\nkernel/dma/contiguous.c-313-\n--\nkernel/dma/contiguous.c-319-\nkernel/dma/contiguous.c:320:static void __init dma_numa_cma_reserve(void)\nkernel/dma/contiguous.c-321-{\n--\nkernel/dma/contiguous.c-324-\tif (IS_ENABLED(CONFIG_CMA_SIZE_PERNUMA) \u0026\u0026\nkernel/dma/contiguous.c:325:\t !numa_cma_configured \u0026\u0026 dma_contiguous_default_area \u0026\u0026\nkernel/dma/contiguous.c-326-\t nr_online_nodes \u003e 1)\nkernel/dma/contiguous.c:327:\t\tpernuma_size_bytes = cma_get_size(dma_contiguous_default_area);\nkernel/dma/contiguous.c-328-\n--\nkernel/dma/contiguous.c-335-\t\tif (!node_online(nid)) {\nkernel/dma/contiguous.c:336:\t\t\tif (pernuma_size_bytes || pernuma_pct ||\nkernel/dma/contiguous.c:337:\t\t\t numa_cma_size[nid] || numa_cma_pct[nid])\nkernel/dma/contiguous.c-338-\t\t\t\tpr_warn(\"invalid node %d specified\\n\", nid);\n--\nkernel/dma/contiguous.c-342-\t\t/* per-node numa setting has the priority */\nkernel/dma/contiguous.c:343:\t\tif (numa_cma_size[nid])\nkernel/dma/contiguous.c:344:\t\t\tsize = numa_cma_size[nid];\nkernel/dma/contiguous.c:345:\t\telse if (numa_cma_pct[nid])\nkernel/dma/contiguous.c:346:\t\t\tsize = numa_cma_pct_size(nid, numa_cma_pct[nid],\nkernel/dma/contiguous.c:347:\t\t\t\t\t\t numa_cma_sub[nid]);\nkernel/dma/contiguous.c:348:\t\telse if (pernuma_size_bytes)\nkernel/dma/contiguous.c:349:\t\t\tsize = pernuma_size_bytes;\nkernel/dma/contiguous.c:350:\t\telse if (pernuma_pct)\nkernel/dma/contiguous.c:351:\t\t\tsize = numa_cma_pct_size(nid, pernuma_pct, pernuma_sub);\nkernel/dma/contiguous.c-352-\t\telse\n--\nkernel/dma/contiguous.c-360-\t\tif (!size) {\nkernel/dma/contiguous.c:361:\t\t\tif (numa_cma_pct[nid] || pernuma_pct)\nkernel/dma/contiguous.c-362-\t\t\t\tpr_warn(\"node %d percentage reserves nothing\\n\",\n--\nkernel/dma/contiguous.c-375-#else\nkernel/dma/contiguous.c:376:static inline void __init dma_numa_cma_reserve(void)\nkernel/dma/contiguous.c-377-{\n--\nkernel/dma/contiguous.c=390=void __init dma_contiguous_reserve(phys_addr_t limit)\n--\nkernel/dma/contiguous.c-452-\nkernel/dma/contiguous.c:453:\tdma_numa_cma_reserve();\nkernel/dma/contiguous.c-454-}\n"
} |
| 9/2 | 2026/11/18 16:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13693 output: 36 thoughts: 29 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Diving Back into `kernel/dma/contiguous.c`** Alright, time to revisit `kernel/dma/contiguous.c`. I need to zero in on the surrounding code around `dma_contiguous_numa_area`. My initial analysis hinted at some potential issues, but I want to get a broader understanding of how this particular function fits into the overall DMA contiguous memory allocation scheme. I need to refresh my memory on the interactions with NUMA nodes, zone management, and any possible race conditions. Let's see how they handle memory allocation and deallocation, particularly when NUMA is in the picture. I need to look closely for any subtle memory leaks, alignment problems, or potential performance bottlenecks in this specific area. |
| 10/2 | 2026/11/18 16:14 | tool | read-file |
0mArgs:{
"File": "kernel/dma/contiguous.c",
"FirstLine": 100,
"LineCount": 45
}Results: {
"Contents": " 100:\t#define size_bytes ((phys_addr_t)CMA_SIZE_MBYTES * SZ_1M)\n 101:\tstatic phys_addr_t size_cmdline __initdata = -1;\n 102:\tstatic phys_addr_t base_cmdline __initdata;\n 103:\tstatic phys_addr_t limit_cmdline __initdata;\n 104:\t\n 105:\tstatic int __init early_cma(char *p)\n 106:\t{\n 107:\t\tif (!p) {\n 108:\t\t\tpr_err(\"Config string not provided\\n\");\n 109:\t\t\treturn -EINVAL;\n 110:\t\t}\n 111:\t\n 112:\t\tsize_cmdline = memparse(p, \u0026p);\n 113:\t\tif (*p != '@')\n 114:\t\t\treturn 0;\n 115:\t\tbase_cmdline = memparse(p + 1, \u0026p);\n 116:\t\tif (*p != '-') {\n 117:\t\t\tlimit_cmdline = base_cmdline + size_cmdline;\n 118:\t\t\treturn 0;\n 119:\t\t}\n 120:\t\tlimit_cmdline = memparse(p + 1, \u0026p);\n 121:\t\n 122:\t\treturn 0;\n 123:\t}\n 124:\tearly_param(\"cma\", early_cma);\n 125:\t\n 126:\tstruct cma *dev_get_cma_area(struct device *dev)\n 127:\t{\n 128:\t\tif (dev \u0026\u0026 dev-\u003ecma_area)\n 129:\t\t\treturn dev-\u003ecma_area;\n 130:\t\n 131:\t\treturn dma_contiguous_default_area;\n 132:\t}\n 133:\tEXPORT_SYMBOL_GPL(dev_get_cma_area);\n 134:\t\n 135:\t#ifdef CONFIG_DMA_NUMA_CMA\n 136:\t\n 137:\tstatic struct cma *dma_contiguous_numa_area[MAX_NUMNODES];\n 138:\tstatic phys_addr_t numa_cma_size[MAX_NUMNODES] __initdata;\n 139:\tstatic phys_addr_t pernuma_size_bytes __initdata;\n 140:\tstatic unsigned int numa_cma_pct[MAX_NUMNODES] __initdata;\n 141:\tstatic unsigned int pernuma_pct __initdata;\n 142:\tstatic phys_addr_t numa_cma_sub[MAX_NUMNODES] __initdata;\n 143:\tstatic phys_addr_t pernuma_sub __initdata;\n 144:\tstatic bool numa_cma_configured __initdata;\n"
} |
| 11/2 | 2026/11/18 16:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14683 output: 36 thoughts: 24 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person: **Diving into Contiguous Memory Management** Alright, time to get my hands dirty. I'm going to take a closer look at how contiguous memory is managed within the kernel. Specifically, my focus is going to be on the `kernel/dma/contiguous.c` file. I'm interested in understanding the nuances of how this particular subsystem handles DMA-able memory regions. There are always tricky parts, so let's start with a focused investigation. I figure lines 360 through 390 are a good place to begin. This section likely deals with a crucial aspect of allocating, freeing, or managing these contiguous DMA buffers. I'm hoping to find either a critical data structure definition, a key function call, or perhaps some particularly clever (or potentially problematic!) logic related to how the kernel interfaces with the hardware's DMA capabilities. I'm especially keen to see how they handle fragmentation, error checking, and interactions with other memory management layers. I want to build a clear mental picture of what's going on, and from there, I can determine where I need to focus my energies for deeper analysis. |
| 12/2 | 2026/11/18 16:15 | tool | read-file |
0mArgs:{
"File": "kernel/dma/contiguous.c",
"FirstLine": 355,
"LineCount": 45
}Results: {
"Contents": " 355:\t\t\t/*\n 356:\t\t\t * A percentage of a memoryless online node, and a percentage\n 357:\t\t\t * entirely consumed by the size kept back, resolve to nothing\n 358:\t\t\t * to reserve. Say so, since the operator asked for memory.\n 359:\t\t\t */\n 360:\t\t\tif (!size) {\n 361:\t\t\t\tif (numa_cma_pct[nid] || pernuma_pct)\n 362:\t\t\t\t\tpr_warn(\"node %d percentage reserves nothing\\n\",\n 363:\t\t\t\t\t\tnid);\n 364:\t\t\t\tcontinue;\n 365:\t\t\t}\n 366:\t\n 367:\t\t\tcma = \u0026dma_contiguous_numa_area[nid];\n 368:\t\t\tsnprintf(name, sizeof(name), \"numa%d\", nid);\n 369:\t\t\tret = cma_declare_contiguous_nid(0, size, 0, 0, 0, false, name, cma, nid);\n 370:\t\t\tif (ret)\n 371:\t\t\t\tpr_warn(\"%s: reservation failed: err %d, node %d\", __func__,\n 372:\t\t\t\t\tret, nid);\n 373:\t\t}\n 374:\t}\n 375:\t#else\n 376:\tstatic inline void __init dma_numa_cma_reserve(void)\n 377:\t{\n 378:\t}\n 379:\t#endif\n 380:\t\n 381:\t/**\n 382:\t * dma_contiguous_reserve() - reserve area(s) for contiguous memory handling\n 383:\t * @limit: End address of the reserved memory (optional, 0 for any).\n 384:\t *\n 385:\t * This function reserves memory from early allocator. It should be\n 386:\t * called by arch specific code once the early allocator (memblock or bootmem)\n 387:\t * has been activated and all other subsystems have already allocated/reserved\n 388:\t * memory.\n 389:\t */\n 390:\tvoid __init dma_contiguous_reserve(phys_addr_t limit)\n 391:\t{\n 392:\t\tphys_addr_t selected_size = 0;\n 393:\t\tphys_addr_t selected_base = 0;\n 394:\t\tphys_addr_t selected_limit = limit;\n 395:\t\tbool fixed = false;\n 396:\t\n 397:\t\tpr_debug(\"%s(limit %08lx)\\n\", __func__, (unsigned long)limit);\n 398:\t\n 399:\t\tif (size_cmdline != -1) {\n"
} |
| 13/2 | 2026/11/18 16:15 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15711 output: 38 thoughts: 23 Thoughts: Okay, let's dive into this. Here's my summary, presented as my own thought process, aimed at an expert audience: **Investigating `dma_contiguous_numa_area` Usage** Alright, so I need to understand the role of `dma_contiguous_numa_area` in this context. My initial instinct is to track its usage. Where is this thing actually *being* used? What functions, modules, or subsystems are leveraging it? I'm thinking I'll need to employ my typical debugging and code-analysis skills. A quick `grep` might be a good starting point, but I'll need to be mindful of potential indirection or macro usage. I anticipate that a thorough investigation will be necessary, examining the call chains and associated data structures to understand the purpose and implications of using this area. I'll need to consider aspects like memory allocation, deallocation, synchronization, and the impact on NUMA node utilization. My immediate goal is a clear map of its implementation details. |
| 14/2 | 2026/11/18 16:16 | tool | grepper |
0mArgs:{
"Expression": "dma_contiguous_numa_area",
"PathPrefixes": [
"kernel/dma/contiguous.c"
]
}Results: {
"Output": "kernel/dma/contiguous.c=133=EXPORT_SYMBOL_GPL(dev_get_cma_area);\n--\nkernel/dma/contiguous.c-136-\nkernel/dma/contiguous.c:137:static struct cma *dma_contiguous_numa_area[MAX_NUMNODES];\nkernel/dma/contiguous.c-138-static phys_addr_t numa_cma_size[MAX_NUMNODES] __initdata;\n--\nkernel/dma/contiguous.c=320=static void __init dma_numa_cma_reserve(void)\n--\nkernel/dma/contiguous.c-366-\nkernel/dma/contiguous.c:367:\t\tcma = \u0026dma_contiguous_numa_area[nid];\nkernel/dma/contiguous.c-368-\t\tsnprintf(name, sizeof(name), \"numa%d\", nid);\n--\nkernel/dma/contiguous.c=555=struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp)\n--\nkernel/dma/contiguous.c-570-\tif (nid != NUMA_NO_NODE \u0026\u0026 !(gfp \u0026 (GFP_DMA | GFP_DMA32))) {\nkernel/dma/contiguous.c:571:\t\tstruct cma *cma = dma_contiguous_numa_area[nid];\nkernel/dma/contiguous.c-572-\t\tstruct page *page;\n--\nkernel/dma/contiguous.c=597=void dma_free_contiguous(struct device *dev, struct page *page, size_t size)\n--\nkernel/dma/contiguous.c-609-#ifdef CONFIG_DMA_NUMA_CMA\nkernel/dma/contiguous.c:610:\t\tif (cma_release(dma_contiguous_numa_area[page_to_nid(page)],\nkernel/dma/contiguous.c-611-\t\t\t\t\tpage, count))\n"
} |
| 15/2 | 2026/11/18 16:16 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16494 output: 192 thoughts: 5556 Thoughts: **Patch Analysis: WorthFuzzing = False** Okay, let's break this down. My initial assessment is that this patch is *not* worth fuzzing. I've gone through the code, and my understanding is that it's all related to early boot-time configuration of CMA (Contiguous Memory Allocator) specifically with NUMA (Non-Uniform Memory Access) nodes. My first observation, and this is critical, is that *everything* modified in `kernel/dma/contiguous.c` is marked either `__init` or `__initdata`. We're talking about functions like `numa_cma_parse_size`, `early_numa_cma`, `dma_numa_cma_reserve` - the key is, they are ALL initialization functions. They are executed *only* during kernel boot, and the data is used during the early boot process to set up DMA. Now, let's remember how syzkaller operates. Syzkaller is a *runtime* fuzzer. It works by injecting system calls from user space into a *running* kernel. It does *not* interact with the bootloader or early boot processes. It doesn't generate kernel command-line arguments. It can't inject command line arguments into `early_param` at runtime. I've checked the triage philosophy. "REACHABILITY IS THE PRIMARY GATE: Fuzzing can only discover bugs in code that can actually execute in standard virtualized environments". All this code is functionally dead after boot. After the boot process completes, the `.init.text` and `.init.data` sections that contain the `__init` code are freed from memory by `free_initmem()`. Any attempt to execute any instructions from there would trigger a kernel oops or page fault. I also thoroughly reviewed the negative criteria: "Unreachable execution paths". Are early boot and `__init` functions unreachable? The answer is YES! Syzkaller cannot reach them. I considered whether the patch could affect *runtime* DMA allocations, but the patch doesn't touch any of the runtime allocation or freeing functions like `dma_alloc_contiguous`, `dma_free_contiguous`, etc. It only touches the initialization process. I need to focus my effort on *reachable* code. Since no system call can reach this patch's changes, there's nothing to fuzz. If I tried to list any symbols from this patch, they would not be found at runtime, so I should set `FocusSymbols: []`. Therefore, I'm confident that `WorthFuzzing: false`. |
| 16/2 | 2026/11/18 16:17 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch adds percentage and subtraction support to the 'cma_pernuma' and 'numa_cma' boot command-line parameters. All modified and newly introduced functions (numa_cma_parse_size, numa_cma_parse, early_numa_cma, early_cma_pernuma, numa_cma_node_size, numa_cma_pct_size, dma_numa_cma_reserve) and variables are marked __init or __initdata. They execute strictly during early boot before userspace initialization and are discarded (via free_initmem()). Because syzkaller executes from userspace after boot and cannot fuzz early boot command-line parsing, the modified code is structurally unreachable at runtime.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch adds percentage and subtraction support to the 'cma_pernuma' and 'numa_cma' boot command-line parameters. All modified and newly introduced functions (numa_cma_parse_size, numa_cma_parse, early_numa_cma, early_cma_pernuma, numa_cma_node_size, numa_cma_pct_size, dma_numa_cma_reserve) and variables are marked __init or __initdata. They execute strictly during early boot before userspace initialization and are discarded (via free_initmem()). Because syzkaller executes from userspace after boot and cannot fuzz early boot command-line parsing, the modified code is structurally unreachable at runtime.",
"WorthFuzzing": false
} |
| 17/1 | 2026/11/18 16:17 | 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) |
|---|