AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/09/07 05:45 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch only modifies user-space tools (bpftool documentation, bash-completion, and command parsing) and a BPF selftest under tools/. It does not touch any kernel code or affect the compiled kernel image (vmlinux/modules).",
  "WorthFuzzing": false
}

1/1 2026/09/07 05:45 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 081cdca058cdd95b43c097304bd1bf0b7b5715a8\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Mon Sep 7 05:45:50 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/tools/bpf/bpftool/Documentation/bpftool-map.rst b/tools/bpf/bpftool/Documentation/bpftool-map.rst\nindex 5daf3de5c7446..375321d55823c 100644\n--- a/tools/bpf/bpftool/Documentation/bpftool-map.rst\n+++ b/tools/bpf/bpftool/Documentation/bpftool-map.rst\n@@ -76,9 +76,16 @@ bpftool map { show | list }   [*MAP*]\n bpftool map create *FILE* type *TYPE* key *KEY_SIZE* value *VALUE_SIZE*  entries *MAX_ENTRIES* name *NAME* [flags *FLAGS*] [inner_map *MAP*] [offload_dev *NAME*]\n     Create a new map with given parameters and pin it to *bpffs* as *FILE*.\n \n-    *FLAGS* should be an integer which is the combination of desired flags,\n-    e.g. 1024 for **BPF_F_MMAPABLE** (see bpf.h UAPI header for existing\n-    flags).\n+    *FLAGS* accepts an unsigned 32-bit integer combining the desired flags\n+    (decimal, hexadecimal with a **0x** prefix, or octal with a **0** prefix),\n+    or a comma-separated list of full, case-sensitive map creation flag names\n+    from the bpf.h UAPI header. For example, **1024**, **0x400**, and\n+    **BPF_F_MMAPABLE** are equivalent. Multiple names are combined with\n+    bitwise OR, for example **BPF_F_NO_PREALLOC,BPF_F_RDONLY_PROG**.\n+    Repeated names are allowed. Empty list elements, abbreviated names, and\n+    lists mixing numbers with names are not accepted. Use **0** for no flags.\n+    Numeric values can include bits unknown to bpftool. The kernel checks\n+    whether the flags are valid for the requested map type.\n \n     To create maps of type array-of-maps or hash-of-maps, the **inner_map**\n     keyword must be used to pass an inner map. The kernel needs it to collect\ndiff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool\nindex 75cbcb512ebae..73f6a81182675 100644\n--- a/tools/bpf/bpftool/bash-completion/bpftool\n+++ b/tools/bpf/bpftool/bash-completion/bpftool\n@@ -718,6 +718,10 @@ _bpftool()\n                     esac\n                     ;;\n                 create)\n+                    # Keep a flags list together if readline splits at commas.\n+                    if [[ $COMP_WORDBREAKS == *,* \u0026\u0026 ( $cur == , || $prev == , ) ]]; then\n+                        _get_comp_words_by_ref -n , cur prev\n+                    fi\n                     case $prev in\n                         $command)\n                             _filedir\n@@ -729,7 +733,27 @@ _bpftool()\n                             COMPREPLY=( $( compgen -W \"$BPFTOOL_MAP_CREATE_TYPES\" -- \"$cur\" ) )\n                             return 0\n                             ;;\n-                        key|value|flags|entries)\n+                        flags)\n+                            compopt -o nospace\n+                            local flags='BPF_F_NO_PREALLOC BPF_F_NO_COMMON_LRU\n+                                BPF_F_NUMA_NODE BPF_F_RDONLY BPF_F_WRONLY\n+                                BPF_F_STACK_BUILD_ID BPF_F_ZERO_SEED\n+                                BPF_F_RDONLY_PROG BPF_F_WRONLY_PROG BPF_F_CLONE\n+                                BPF_F_MMAPABLE BPF_F_PRESERVE_ELEMS BPF_F_INNER_MAP\n+                                BPF_F_LINK BPF_F_VTYPE_BTF_OBJ_FD BPF_F_TOKEN_FD\n+                                BPF_F_SEGV_ON_FAULT BPF_F_NO_USER_CONV\n+                                BPF_F_RB_OVERWRITE'\n+                            local prefix= flag\n+                            # Readline replaces only the suffix after a word break.\n+                            if [[ $cur == *,* \u0026\u0026 $COMP_WORDBREAKS != *,* ]]; then\n+                                prefix=\"${cur%,*},\"\n+                            fi\n+                            for flag in $(compgen -W \"$flags\" -- \"${cur##*,}\"); do\n+                                COMPREPLY+=( \"${prefix}${flag}\" )\n+                            done\n+                            return 0\n+                            ;;\n+                        key|value|entries)\n                             return 0\n                             ;;\n                         inner_map)\ndiff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c\nindex 684a8fb724146..d703af60d0bee 100644\n--- a/tools/bpf/bpftool/map.c\n+++ b/tools/bpf/bpftool/map.c\n@@ -1250,6 +1250,73 @@ static int do_pin(int argc, char **argv)\n \treturn err;\n }\n \n+static const struct {\n+\tconst char *name;\n+\t__u32 value;\n+} map_create_flags[] = {\n+#define MAP_CREATE_FLAG(flag) { #flag, flag }\n+\tMAP_CREATE_FLAG(BPF_F_NO_PREALLOC),\n+\tMAP_CREATE_FLAG(BPF_F_NO_COMMON_LRU),\n+\tMAP_CREATE_FLAG(BPF_F_NUMA_NODE),\n+\tMAP_CREATE_FLAG(BPF_F_RDONLY),\n+\tMAP_CREATE_FLAG(BPF_F_WRONLY),\n+\tMAP_CREATE_FLAG(BPF_F_STACK_BUILD_ID),\n+\tMAP_CREATE_FLAG(BPF_F_ZERO_SEED),\n+\tMAP_CREATE_FLAG(BPF_F_RDONLY_PROG),\n+\tMAP_CREATE_FLAG(BPF_F_WRONLY_PROG),\n+\tMAP_CREATE_FLAG(BPF_F_CLONE),\n+\tMAP_CREATE_FLAG(BPF_F_MMAPABLE),\n+\tMAP_CREATE_FLAG(BPF_F_PRESERVE_ELEMS),\n+\tMAP_CREATE_FLAG(BPF_F_INNER_MAP),\n+\tMAP_CREATE_FLAG(BPF_F_LINK),\n+\tMAP_CREATE_FLAG(BPF_F_VTYPE_BTF_OBJ_FD),\n+\tMAP_CREATE_FLAG(BPF_F_TOKEN_FD),\n+\tMAP_CREATE_FLAG(BPF_F_SEGV_ON_FAULT),\n+\tMAP_CREATE_FLAG(BPF_F_NO_USER_CONV),\n+\tMAP_CREATE_FLAG(BPF_F_RB_OVERWRITE),\n+#undef MAP_CREATE_FLAG\n+};\n+\n+static int parse_map_create_flags(const char *arg, __u32 *flags)\n+{\n+\tconst char *name = arg, *comma;\n+\tlong long value;\n+\t__u32 parsed = 0;\n+\tsize_t len, i;\n+\tchar *end;\n+\n+\t/* Keep base-0 numeric input, including bits unknown to this bpftool. */\n+\tif (strncmp(arg, \"BPF_F_\", 6)) {\n+\t\terrno = 0;\n+\t\tvalue = strtoll(arg, \u0026end, 0);\n+\t\tif (errno || end == arg || *end || value \u003c 0 || value \u003e UINT32_MAX)\n+\t\t\tgoto invalid;\n+\t\t*flags = value;\n+\t\treturn 0;\n+\t}\n+\n+\tdo {\n+\t\tcomma = strchr(name, ',');\n+\t\tlen = comma ? (size_t)(comma - name) : strlen(name);\n+\t\tfor (i = 0; i \u003c ARRAY_SIZE(map_create_flags); i++) {\n+\t\t\tif (strlen(map_create_flags[i].name) == len \u0026\u0026\n+\t\t\t    !strncmp(name, map_create_flags[i].name, len))\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (i == ARRAY_SIZE(map_create_flags))\n+\t\t\tgoto invalid;\n+\t\tparsed |= map_create_flags[i].value;\n+\t\tif (comma)\n+\t\t\tname = comma + 1;\n+\t} while (comma);\n+\n+\t*flags = parsed;\n+\treturn 0;\n+invalid:\n+\tp_err(\"can't parse %s as map creation flags\", arg);\n+\treturn -1;\n+}\n+\n static int do_create(int argc, char **argv)\n {\n \tLIBBPF_OPTS(bpf_map_create_opts, attr);\n@@ -1301,9 +1368,14 @@ static int do_create(int argc, char **argv)\n \t\t\t\t\t  \"max entries\"))\n \t\t\t\tgoto exit;\n \t\t} else if (is_prefix(*argv, \"flags\")) {\n-\t\t\tif (parse_u32_arg(\u0026argc, \u0026argv, \u0026attr.map_flags,\n-\t\t\t\t\t  \"flags\"))\n+\t\t\tNEXT_ARG();\n+\t\t\tif (attr.map_flags) {\n+\t\t\t\tp_err(\"flags already specified\");\n+\t\t\t\tgoto exit;\n+\t\t\t}\n+\t\t\tif (parse_map_create_flags(*argv, \u0026attr.map_flags))\n \t\t\t\tgoto exit;\n+\t\t\tNEXT_ARG();\n \t\t} else if (is_prefix(*argv, \"dev\")) {\n \t\t\tp_info(\"Warning: 'bpftool map create [...] dev \u003cifname\u003e' syntax is deprecated.\\n\"\n \t\t\t       \"Going further, please use 'offload_dev \u003cifname\u003e' to request hardware offload for the map.\");\n@@ -1474,6 +1546,7 @@ static int do_help(int argc, char **argv)\n \t\t\"       DATA := { [hex] BYTES }\\n\"\n \t\t\"       \" HELP_SPEC_PROGRAM \"\\n\"\n \t\t\"       VALUE := { DATA | MAP | PROG }\\n\"\n+\t\t\"       FLAGS := { integer | BPF_F_NAME[,BPF_F_NAME...] }\\n\"\n \t\t\"       UPDATE_FLAGS := { any | exist | noexist }\\n\"\n \t\t\"       TYPE := { hash | array | prog_array | perf_event_array | percpu_hash |\\n\"\n \t\t\"                 percpu_array | stack_trace | cgroup_array | lru_hash |\\n\"\ndiff --git a/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c b/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c\nnew file mode 100644\nindex 0000000000000..140401dd2548f\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c\n@@ -0,0 +1,99 @@\n+// SPDX-License-Identifier: GPL-2.0-only\n+\n+#include \u003cerrno.h\u003e\n+#include \u003cunistd.h\u003e\n+#include \u003cbpf/bpf.h\u003e\n+#include \u003cbpftool_helpers.h\u003e\n+#include \u003ctest_progs.h\u003e\n+\n+static const struct map_flags_test {\n+\tconst char *name;\n+\tconst char *flags;\n+\t__u32 expected_flags;\n+\tconst char *error;\n+} tests[] = {\n+\t{ \"zero\", \"0\", 0 },\n+\t{ \"decimal\", \"129\", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },\n+\t{ \"hexadecimal\", \"0x81\", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },\n+\t{ \"octal\", \"0201\", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },\n+\t{ \"positive_sign\", \"+1\", BPF_F_NO_PREALLOC },\n+\t{ \"single_name\", \"BPF_F_NO_PREALLOC\", BPF_F_NO_PREALLOC },\n+\t{ \"combined_names\", \"BPF_F_NO_PREALLOC,BPF_F_RDONLY_PROG\",\n+\t  BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },\n+\t{ \"repeated_name\", \"BPF_F_NO_PREALLOC,BPF_F_NO_PREALLOC\", BPF_F_NO_PREALLOC },\n+\t{ \"unknown_name\", \"BPF_F_NOT_A_MAP_FLAG\", 0, \"can't parse\" },\n+\t{ \"other_command_flag\", \"BPF_F_PATH_FD\", 0, \"can't parse\" },\n+\t{ \"update_flag\", \"BPF_F_LOCK\", 0, \"can't parse\" },\n+\t{ \"abbreviated_name\", \"BPF_F_NO_PRE\", 0, \"can't parse\" },\n+\t{ \"lowercase_name\", \"bpf_f_no_prealloc\", 0, \"can't parse\" },\n+\t{ \"empty\", \"\", 0, \"can't parse\" },\n+\t{ \"whitespace\", \" \", 0, \"can't parse\" },\n+\t{ \"empty_list\", \",\", 0, \"can't parse\" },\n+\t{ \"leading_comma\", \",BPF_F_NO_PREALLOC\", 0, \"can't parse\" },\n+\t{ \"trailing_comma\", \"BPF_F_NO_PREALLOC,\", 0, \"can't parse\" },\n+\t{ \"empty_element\", \"BPF_F_NO_PREALLOC,,BPF_F_RDONLY_PROG\", 0, \"can't parse\" },\n+\t{ \"number_then_name\", \"1,BPF_F_RDONLY_PROG\", 0, \"can't parse\" },\n+\t{ \"name_then_number\", \"BPF_F_NO_PREALLOC,128\", 0, \"can't parse\" },\n+\t{ \"numeric_list\", \"1,128\", 0, \"can't parse\" },\n+\t{ \"whitespace_in_list\", \"BPF_F_NO_PREALLOC, BPF_F_RDONLY_PROG\", 0, \"can't parse\" },\n+\t{ \"overflow_u32\", \"4294967296\", 0, \"can't parse\" },\n+\t{ \"overflow_hex\", \"0x100000000\", 0, \"can't parse\" },\n+\t{ \"overflow_u64\", \"18446744073709551616\", 0, \"can't parse\" },\n+\t{ \"negative\", \"-1\", 0, \"can't parse\" },\n+\t/* Numeric bits unknown to bpftool must still reach the kernel. */\n+\t{ \"all_bits\", \"0xffffffff\", 0, \"map create failed\" },\n+\t{ \"invalid_combination\", \"BPF_F_RDONLY,BPF_F_WRONLY\", 0, \"map create failed\" },\n+};\n+\n+static void test_map_flags(const struct map_flags_test *test, const char *path)\n+{\n+\tchar cmd[MAX_BPFTOOL_CMD_LEN], output[1024] = {};\n+\tstruct bpf_map_info info = {};\n+\t__u32 info_len = sizeof(info);\n+\tint fd, err;\n+\n+\t/* Let the flags parser handle negative numbers instead of getopt(). */\n+\terr = snprintf(cmd, sizeof(cmd),\n+\t\t       \"-- map create %s type hash key 4 value 4 entries 1 name flags_test flags '%s' 2\u003e\u00261\",\n+\t\t       path, test-\u003eflags);\n+\tif (!ASSERT_GT(err, 0, \"format_command\") ||\n+\t    !ASSERT_LT(err, sizeof(cmd), \"command_length\"))\n+\t\treturn;\n+\n+\terr = get_bpftool_command_output(cmd, output, sizeof(output));\n+\tif (test-\u003eerror) {\n+\t\tASSERT_NEQ(err, 0, \"reject_flags\");\n+\t\tASSERT_HAS_SUBSTR(output, test-\u003eerror, \"error_message\");\n+\t\terr = access(path, F_OK);\n+\t\tASSERT_EQ(err, -1, \"no_pin\");\n+\t\tASSERT_EQ(errno, ENOENT, \"pin_absent\");\n+\t\tgoto cleanup;\n+\t}\n+\tif (!ASSERT_OK(err, \"create_map\"))\n+\t\tgoto cleanup;\n+\n+\tfd = bpf_obj_get(path);\n+\tif (!ASSERT_OK_FD(fd, \"open_map\"))\n+\t\tgoto cleanup;\n+\tif (ASSERT_OK(bpf_map_get_info_by_fd(fd, \u0026info, \u0026info_len), \"map_info\"))\n+\t\tASSERT_EQ(info.map_flags, test-\u003eexpected_flags, \"map_flags\");\n+\tclose(fd);\n+cleanup:\n+\tunlink(path);\n+}\n+\n+void test_bpftool_map_flags(void)\n+{\n+\tchar dir[] = \"/sys/fs/bpf/bpftool_flags_XXXXXX\";\n+\tchar path[sizeof(dir) + sizeof(\"/map\")];\n+\tint i;\n+\n+\tif (!ASSERT_OK_PTR(mkdtemp(dir), \"create_pin_dir\"))\n+\t\treturn;\n+\tsnprintf(path, sizeof(path), \"%s/map\", dir);\n+\tfor (i = 0; i \u003c ARRAY_SIZE(tests); i++) {\n+\t\tif (test__start_subtest(tests[i].name))\n+\t\t\ttest_map_flags(\u0026tests[i], path);\n+\t}\n+\tASSERT_OK(rmdir(dir), \"remove_pin_dir\");\n+}\n"
}

2/1 2026/09/07 05:45 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies user-space tools (bpftool documentation, bash-completion, and command parsing) and a BPF selftest under tools/. It does not touch any kernel code or affect the compiled kernel image (vmlinux/modules).",
  "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 081cdca058cdd95b43c097304bd1bf0b7b5715a8
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Sep 7 05:45:50 2026 +0000

    syz-cluster: applied patch under review

diff --git a/tools/bpf/bpftool/Documentation/bpftool-map.rst b/tools/bpf/bpftool/Documentation/bpftool-map.rst
index 5daf3de5c7446..375321d55823c 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-map.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-map.rst
@@ -76,9 +76,16 @@ bpftool map { show | list }   [*MAP*]
 bpftool map create *FILE* type *TYPE* key *KEY_SIZE* value *VALUE_SIZE*  entries *MAX_ENTRIES* name *NAME* [flags *FLAGS*] [inner_map *MAP*] [offload_dev *NAME*]
     Create a new map with given parameters and pin it to *bpffs* as *FILE*.
 
-    *FLAGS* should be an integer which is the combination of desired flags,
-    e.g. 1024 for **BPF_F_MMAPABLE** (see bpf.h UAPI header for existing
-    flags).
+    *FLAGS* accepts an unsigned 32-bit integer combining the desired flags
+    (decimal, hexadecimal with a **0x** prefix, or octal with a **0** prefix),
+    or a comma-separated list of full, case-sensitive map creation flag names
+    from the bpf.h UAPI header. For example, **1024**, **0x400**, and
+    **BPF_F_MMAPABLE** are equivalent. Multiple names are combined with
+    bitwise OR, for example **BPF_F_NO_PREALLOC,BPF_F_RDONLY_PROG**.
+    Repeated names are allowed. Empty list elements, abbreviated names, and
+    lists mixing numbers with names are not accepted. Use **0** for no flags.
+    Numeric values can include bits unknown to bpftool. The kernel checks
+    whether the flags are valid for the requested map type.
 
     To create maps of type array-of-maps or hash-of-maps, the **inner_map**
     keyword must be used to pass an inner map. The kernel needs it to collect
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 75cbcb512ebae..73f6a81182675 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -718,6 +718,10 @@ _bpftool()
                     esac
                     ;;
                 create)
+                    # Keep a flags list together if readline splits at commas.
+                    if [[ $COMP_WORDBREAKS == *,* && ( $cur == , || $prev == , ) ]]; then
+                        _get_comp_words_by_ref -n , cur prev
+                    fi
                     case $prev in
                         $command)
                             _filedir
@@ -729,7 +733,27 @@ _bpftool()
                             COMPREPLY=( $( compgen -W "$BPFTOOL_MAP_CREATE_TYPES" -- "$cur" ) )
                             return 0
                             ;;
-                        key|value|flags|entries)
+                        flags)
+                            compopt -o nospace
+                            local flags='BPF_F_NO_PREALLOC BPF_F_NO_COMMON_LRU
+                                BPF_F_NUMA_NODE BPF_F_RDONLY BPF_F_WRONLY
+                                BPF_F_STACK_BUILD_ID BPF_F_ZERO_SEED
+                                BPF_F_RDONLY_PROG BPF_F_WRONLY_PROG BPF_F_CLONE
+                                BPF_F_MMAPABLE BPF_F_PRESERVE_ELEMS BPF_F_INNER_MAP
+                                BPF_F_LINK BPF_F_VTYPE_BTF_OBJ_FD BPF_F_TOKEN_FD
+                                BPF_F_SEGV_ON_FAULT BPF_F_NO_USER_CONV
+                                BPF_F_RB_OVERWRITE'
+                            local prefix= flag
+                            # Readline replaces only the suffix after a word break.
+                            if [[ $cur == *,* && $COMP_WORDBREAKS != *,* ]]; then
+                                prefix="${cur%,*},"
+                            fi
+                            for flag in $(compgen -W "$flags" -- "${cur##*,}"); do
+                                COMPREPLY+=( "${prefix}${flag}" )
+                            done
+                            return 0
+                            ;;
+                        key|value|entries)
                             return 0
                             ;;
                         inner_map)
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 684a8fb724146..d703af60d0bee 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -1250,6 +1250,73 @@ static int do_pin(int argc, char **argv)
 	return err;
 }
 
+static const struct {
+	const char *name;
+	__u32 value;
+} map_create_flags[] = {
+#define MAP_CREATE_FLAG(flag) { #flag, flag }
+	MAP_CREATE_FLAG(BPF_F_NO_PREALLOC),
+	MAP_CREATE_FLAG(BPF_F_NO_COMMON_LRU),
+	MAP_CREATE_FLAG(BPF_F_NUMA_NODE),
+	MAP_CREATE_FLAG(BPF_F_RDONLY),
+	MAP_CREATE_FLAG(BPF_F_WRONLY),
+	MAP_CREATE_FLAG(BPF_F_STACK_BUILD_ID),
+	MAP_CREATE_FLAG(BPF_F_ZERO_SEED),
+	MAP_CREATE_FLAG(BPF_F_RDONLY_PROG),
+	MAP_CREATE_FLAG(BPF_F_WRONLY_PROG),
+	MAP_CREATE_FLAG(BPF_F_CLONE),
+	MAP_CREATE_FLAG(BPF_F_MMAPABLE),
+	MAP_CREATE_FLAG(BPF_F_PRESERVE_ELEMS),
+	MAP_CREATE_FLAG(BPF_F_INNER_MAP),
+	MAP_CREATE_FLAG(BPF_F_LINK),
+	MAP_CREATE_FLAG(BPF_F_VTYPE_BTF_OBJ_FD),
+	MAP_CREATE_FLAG(BPF_F_TOKEN_FD),
+	MAP_CREATE_FLAG(BPF_F_SEGV_ON_FAULT),
+	MAP_CREATE_FLAG(BPF_F_NO_USER_CONV),
+	MAP_CREATE_FLAG(BPF_F_RB_OVERWRITE),
+#undef MAP_CREATE_FLAG
+};
+
+static int parse_map_create_flags(const char *arg, __u32 *flags)
+{
+	const char *name = arg, *comma;
+	long long value;
+	__u32 parsed = 0;
+	size_t len, i;
+	char *end;
+
+	/* Keep base-0 numeric input, including bits unknown to this bpftool. */
+	if (strncmp(arg, "BPF_F_", 6)) {
+		errno = 0;
+		value = strtoll(arg, &end, 0);
+		if (errno || end == arg || *end || value < 0 || value > UINT32_MAX)
+			goto invalid;
+		*flags = value;
+		return 0;
+	}
+
+	do {
+		comma = strchr(name, ',');
+		len = comma ? (size_t)(comma - name) : strlen(name);
+		for (i = 0; i < ARRAY_SIZE(map_create_flags); i++) {
+			if (strlen(map_create_flags[i].name) == len &&
+			    !strncmp(name, map_create_flags[i].name, len))
+				break;
+		}
+		if (i == ARRAY_SIZE(map_create_flags))
+			goto invalid;
+		parsed |= map_create_flags[i].value;
+		if (comma)
+			name = comma + 1;
+	} while (comma);
+
+	*flags = parsed;
+	return 0;
+invalid:
+	p_err("can't parse %s as map creation flags", arg);
+	return -1;
+}
+
 static int do_create(int argc, char **argv)
 {
 	LIBBPF_OPTS(bpf_map_create_opts, attr);
@@ -1301,9 +1368,14 @@ static int do_create(int argc, char **argv)
 					  "max entries"))
 				goto exit;
 		} else if (is_prefix(*argv, "flags")) {
-			if (parse_u32_arg(&argc, &argv, &attr.map_flags,
-					  "flags"))
+			NEXT_ARG();
+			if (attr.map_flags) {
+				p_err("flags already specified");
+				goto exit;
+			}
+			if (parse_map_create_flags(*argv, &attr.map_flags))
 				goto exit;
+			NEXT_ARG();
 		} else if (is_prefix(*argv, "dev")) {
 			p_info("Warning: 'bpftool map create [...] dev <ifname>' syntax is deprecated.\n"
 			       "Going further, please use 'offload_dev <ifname>' to request hardware offload for the map.");
@@ -1474,6 +1546,7 @@ static int do_help(int argc, char **argv)
 		"       DATA := { [hex] BYTES }\n"
 		"       " HELP_SPEC_PROGRAM "\n"
 		"       VALUE := { DATA | MAP | PROG }\n"
+		"       FLAGS := { integer | BPF_F_NAME[,BPF_F_NAME...] }\n"
 		"       UPDATE_FLAGS := { any | exist | noexist }\n"
 		"       TYPE := { hash | array | prog_array | perf_event_array | percpu_hash |\n"
 		"                 percpu_array | stack_trace | cgroup_array | lru_hash |\n"
diff --git a/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c b/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c
new file mode 100644
index 0000000000000..140401dd2548f
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <errno.h>
+#include <unistd.h>
+#include <bpf/bpf.h>
+#include <bpftool_helpers.h>
+#include <test_progs.h>
+
+static const struct map_flags_test {
+	const char *name;
+	const char *flags;
+	__u32 expected_flags;
+	const char *error;
+} tests[] = {
+	{ "zero", "0", 0 },
+	{ "decimal", "129", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
+	{ "hexadecimal", "0x81", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
+	{ "octal", "0201", BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
+	{ "positive_sign", "+1", BPF_F_NO_PREALLOC },
+	{ "single_name", "BPF_F_NO_PREALLOC", BPF_F_NO_PREALLOC },
+	{ "combined_names", "BPF_F_NO_PREALLOC,BPF_F_RDONLY_PROG",
+	  BPF_F_NO_PREALLOC | BPF_F_RDONLY_PROG },
+	{ "repeated_name", "BPF_F_NO_PREALLOC,BPF_F_NO_PREALLOC", BPF_F_NO_PREALLOC },
+	{ "unknown_name", "BPF_F_NOT_A_MAP_FLAG", 0, "can't parse" },
+	{ "other_command_flag", "BPF_F_PATH_FD", 0, "can't parse" },
+	{ "update_flag", "BPF_F_LOCK", 0, "can't parse" },
+	{ "abbreviated_name", "BPF_F_NO_PRE", 0, "can't parse" },
+	{ "lowercase_name", "bpf_f_no_prealloc", 0, "can't parse" },
+	{ "empty", "", 0, "can't parse" },
+	{ "whitespace", " ", 0, "can't parse" },
+	{ "empty_list", ",", 0, "can't parse" },
+	{ "leading_comma", ",BPF_F_NO_PREALLOC", 0, "can't parse" },
+	{ "trailing_comma", "BPF_F_NO_PREALLOC,", 0, "can't parse" },
+	{ "empty_element", "BPF_F_NO_PREALLOC,,BPF_F_RDONLY_PROG", 0, "can't parse" },
+	{ "number_then_name", "1,BPF_F_RDONLY_PROG", 0, "can't parse" },
+	{ "name_then_number", "BPF_F_NO_PREALLOC,128", 0, "can't parse" },
+	{ "numeric_list", "1,128", 0, "can't parse" },
+	{ "whitespace_in_list", "BPF_F_NO_PREALLOC, BPF_F_RDONLY_PROG", 0, "can't parse" },
+	{ "overflow_u32", "4294967296", 0, "can't parse" },
+	{ "overflow_hex", "0x100000000", 0, "can't parse" },
+	{ "overflow_u64", "18446744073709551616", 0, "can't parse" },
+	{ "negative", "-1", 0, "can't parse" },
+	/* Numeric bits unknown to bpftool must still reach the kernel. */
+	{ "all_bits", "0xffffffff", 0, "map create failed" },
+	{ "invalid_combination", "BPF_F_RDONLY,BPF_F_WRONLY", 0, "map create failed" },
+};
+
+static void test_map_flags(const struct map_flags_test *test, const char *path)
+{
+	char cmd[MAX_BPFTOOL_CMD_LEN], output[1024] = {};
+	struct bpf_map_info info = {};
+	__u32 info_len = sizeof(info);
+	int fd, err;
+
+	/* Let the flags parser handle negative numbers instead of getopt(). */
+	err = snprintf(cmd, sizeof(cmd),
+		       "-- map create %s type hash key 4 value 4 entries 1 name flags_test flags '%s' 2>&1",
+		       path, test->flags);
+	if (!ASSERT_GT(err, 0, "format_command") ||
+	    !ASSERT_LT(err, sizeof(cmd), "command_length"))
+		return;
+
+	err = get_bpftool_command_output(cmd, output, sizeof(output));
+	if (test->error) {
+		ASSERT_NEQ(err, 0, "reject_flags");
+		ASSERT_HAS_SUBSTR(output, test->error, "error_message");
+		err = access(path, F_OK);
+		ASSERT_EQ(err, -1, "no_pin");
+		ASSERT_EQ(errno, ENOENT, "pin_absent");
+		goto cleanup;
+	}
+	if (!ASSERT_OK(err, "create_map"))
+		goto cleanup;
+
+	fd = bpf_obj_get(path);
+	if (!ASSERT_OK_FD(fd, "open_map"))
+		goto cleanup;
+	if (ASSERT_OK(bpf_map_get_info_by_fd(fd, &info, &info_len), "map_info"))
+		ASSERT_EQ(info.map_flags, test->expected_flags, "map_flags");
+	close(fd);
+cleanup:
+	unlink(path);
+}
+
+void test_bpftool_map_flags(void)
+{
+	char dir[] = "/sys/fs/bpf/bpftool_flags_XXXXXX";
+	char path[sizeof(dir) + sizeof("/map")];
+	int i;
+
+	if (!ASSERT_OK_PTR(mkdtemp(dir), "create_pin_dir"))
+		return;
+	snprintf(path, sizeof(path), "%s/map", dir);
+	for (i = 0; i < ARRAY_SIZE(tests); i++) {
+		if (test__start_subtest(tests[i].name))
+			test_map_flags(&tests[i], path);
+	}
+	ASSERT_OK(rmdir(dir), "remove_pin_dir");
+}

3/2 2026/09/07 05:45 llm patch-evaluator
0m Model:
gemini-3.7-flash

Args:
null

Results:
null

Tokens:
							input: 7158
							output: 82
							thoughts: 439
						

Thoughts:
**Patch Analysis: WorthFuzzing = False**

Okay, let's break this patch down and figure out if fuzzing is necessary. First, I need to see what's actually been modified. The diff lists four files: `tools/bpf/bpftool/Documentation/bpftool-map.rst`, `tools/bpf/bpftool/bash-completion/bpftool`, `tools/bpf/bpftool/map.c`, and `tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c`.

Right away, I see they are all under `tools/`, specifically within the `bpf/bpftool` directory for the user-space `bpftool` utility and the `testing/selftests/bpf` directory for selftests. Now, I need to check it against those negative criteria to determine if it should be fuzzed.

The prompt specifies when *not* to fuzz. It says to return `WorthFuzzing=false` if the changes are strictly one or more of the following: documentation, comments, spelling fixes, or changes in user-space directories like `tools/`, `samples/`, `scripts/`, or `usr/`, as long as they don't affect the compiled kernel image or modules.

Looking at these files, it's clear that all changes fall squarely into the negative criteria category. These modifications are confined to user-space utilities and selftests; they have no impact on the kernel itself, the compiled image (vmlinux), or any kernel modules. Therefore, this patch is a definite `WorthFuzzing: false`.

Let's do a quick sanity check to be sure. I'll make sure there aren't any hidden changes or other files that might be problematic but the diff only shows these four files.

Finally, I need to be sure the `set-results` call is in the right format. It looks like it should be: `EnableConfigs: []`, `FocusSymbols: []`, `Reasoning: Concise explanation`, and `WorthFuzzing: false`. With this in mind, I'm ready to prepare the call.



4/2 2026/09/07 05:45 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies user-space tools (bpftool documentation, bash-completion, and command parsing) and a BPF selftest under tools/. It does not touch any kernel code or affect the compiled kernel image (vmlinux/modules).",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies user-space tools (bpftool documentation, bash-completion, and command parsing) and a BPF selftest under tools/. It does not touch any kernel code or affect the compiled kernel image (vmlinux/modules).",
  "WorthFuzzing": false
}

5/1 2026/09/07 05:45 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)