| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/17 04:46 | flow | patch-triage |
0mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies only user-space utilities in tools/bpf/bpftool and a test in tools/testing/selftests/bpf. None of the changes affect the compiled kernel image (vmlinux) or kernel modules.",
"WorthFuzzing": false
} |
| 1/1 | 2026/10/17 04:46 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 3913824d3fdc4b7d83135e9f47d9a78197a6b337\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Oct 17 04:46:01 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c\nindex f9b87efa7c9a7..ca5fa2f0bf9b1 100644\n--- a/tools/bpf/bpftool/common.c\n+++ b/tools/bpf/bpftool/common.c\n@@ -72,6 +72,17 @@ void p_info(const char *fmt, ...)\n \tva_end(ap);\n }\n \n+/*\n+ * Like strerror(), but also knows ENOTSUPP (524), which the kernel returns\n+ * to user space from some BPF commands although it is not a userspace errno.\n+ */\n+const char *bpf_strerror(int err)\n+{\n+\tif (err == 524 /* ENOTSUPP */)\n+\t\treturn \"Operation not supported\";\n+\treturn strerror(err);\n+}\n+\n static bool is_bpffs(const char *path)\n {\n \tstruct statfs st_fs;\ndiff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h\nindex 6851346a60305..b1eb4b5d991b8 100644\n--- a/tools/bpf/bpftool/main.h\n+++ b/tools/bpf/bpftool/main.h\n@@ -98,6 +98,7 @@ extern const char *cert_path;\n \n void __printf(1, 2) p_err(const char *fmt, ...);\n void __printf(1, 2) p_info(const char *fmt, ...);\n+const char *bpf_strerror(int err);\n \n bool is_prefix(const char *pfx, const char *str);\n int detect_common_prefix(const char *arg, ...);\ndiff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c\nindex 20d59eab09a12..4b65edf74859b 100644\n--- a/tools/bpf/bpftool/map.c\n+++ b/tools/bpf/bpftool/map.c\n@@ -228,7 +228,7 @@ print_entry_error(struct bpf_map_info *map_info, void *key, int lookup_errno)\n \t\tprint_hex_data_json(key, map_info-\u003ekey_size);\n \t\tjsonw_name(json_wtr, \"value\");\n \t\tjsonw_start_object(json_wtr);\t/* error */\n-\t\tjsonw_string_field(json_wtr, \"error\", strerror(lookup_errno));\n+\t\tjsonw_string_field(json_wtr, \"error\", bpf_strerror(lookup_errno));\n \t\tjsonw_end_object(json_wtr);\t/* error */\n \t\tjsonw_end_object(json_wtr);\t/* entry */\n \t} else {\n@@ -241,7 +241,7 @@ print_entry_error(struct bpf_map_info *map_info, void *key, int lookup_errno)\n \t\t\tmsg = \"\u003ccannot read\u003e\";\n \n \t\tprint_entry_error_msg(map_info, key,\n-\t\t\t\t msg ? : strerror(lookup_errno));\n+\t\t\t\t msg ? : bpf_strerror(lookup_errno));\n \t}\n }\n \n@@ -856,6 +856,21 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,\n \t\t}\n \t}\n \n+\t/* Fail early to avoid an empty dump if map type cannot be iterated */\n+\tif (bpf_map_get_next_key(fd, NULL, key) \u0026\u0026 errno != ENOENT) {\n+\t\tconst char *map_type_str, *err_str;\n+\n+\t\terr_str = bpf_strerror(errno);\n+\t\tmap_type_str = libbpf_bpf_map_type_str(info-\u003etype);\n+\t\tif (map_type_str)\n+\t\t\tp_err(\"can't dump %s map: %s\", map_type_str, err_str);\n+\t\telse\n+\t\t\tp_err(\"can't dump map of type %u: %s\", info-\u003etype,\n+\t\t\t err_str);\n+\t\terr = -1;\n+\t\tgoto exit_free;\n+\t}\n+\n \tif (wtr) {\n \t\terr = get_map_kv_btf(info, \u0026btf);\n \t\tif (err) {\n@@ -883,8 +898,11 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,\n \twhile (true) {\n \t\terr = bpf_map_get_next_key(fd, prev_key, key);\n \t\tif (err) {\n-\t\t\tif (errno == ENOENT)\n+\t\t\tif (errno == ENOENT) {\n \t\t\t\terr = 0;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tp_err(\"can't get next key: %s\", bpf_strerror(errno));\n \t\t\tbreak;\n \t\t}\n \t\tif (!dump_map_elem(fd, key, value, info, btf, wtr,\n@@ -897,7 +915,7 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,\n \t\tjsonw_end_array(wtr);\t/* elements */\n \t\tif (show_header)\n \t\t\tjsonw_end_object(wtr);\t/* map object */\n-\t} else {\n+\t} else if (!err) {\n \t\tprintf(\"Found %u element%s\\n\", num_elems,\n \t\t num_elems != 1 ? \"s\" : \"\");\n \t}\n@@ -1032,7 +1050,7 @@ static int do_update(int argc, char **argv)\n \n \terr = bpf_map_update_elem(fd, key, value, flags);\n \tif (err) {\n-\t\tp_err(\"update failed: %s\", strerror(errno));\n+\t\tp_err(\"update failed: %s\", bpf_strerror(errno));\n \t\tgoto exit_free;\n \t}\n \n@@ -1136,7 +1154,7 @@ static int do_lookup(int argc, char **argv)\n \t\t\t\tprintf(\"\\n\\nNot found\\n\");\n \t\t\t}\n \t\t} else {\n-\t\t\tp_err(\"lookup failed: %s\", strerror(errno));\n+\t\t\tp_err(\"lookup failed: %s\", bpf_strerror(errno));\n \t\t}\n \n \t\tgoto exit_free;\n@@ -1188,7 +1206,7 @@ static int do_getnext(int argc, char **argv)\n \n \terr = bpf_map_get_next_key(fd, key, nextkey);\n \tif (err) {\n-\t\tp_err(\"can't get next key: %s\", strerror(errno));\n+\t\tp_err(\"can't get next key: %s\", bpf_strerror(errno));\n \t\tgoto exit_free;\n \t}\n \n@@ -1253,7 +1271,7 @@ static int do_delete(int argc, char **argv)\n \n \terr = bpf_map_delete_elem(fd, key);\n \tif (err)\n-\t\tp_err(\"delete failed: %s\", strerror(errno));\n+\t\tp_err(\"delete failed: %s\", bpf_strerror(errno));\n \n exit_free:\n \tfree(key);\n@@ -1381,7 +1399,7 @@ static int do_create(int argc, char **argv)\n \n \tfd = bpf_map_create(map_type, map_name, key_size, value_size, max_entries, \u0026attr);\n \tif (fd \u003c 0) {\n-\t\tp_err(\"map create failed: %s\", strerror(errno));\n+\t\tp_err(\"map create failed: %s\", bpf_strerror(errno));\n \t\tgoto exit;\n \t}\n \n@@ -1427,7 +1445,7 @@ static int do_pop_dequeue(int argc, char **argv)\n \t\t\telse\n \t\t\t\tprintf(\"Error: empty map\\n\");\n \t\t} else {\n-\t\t\tp_err(\"pop failed: %s\", strerror(errno));\n+\t\t\tp_err(\"pop failed: %s\", bpf_strerror(errno));\n \t\t}\n \n \t\tgoto exit_free;\n@@ -1462,7 +1480,7 @@ static int do_freeze(int argc, char **argv)\n \terr = bpf_map_freeze(fd);\n \tclose(fd);\n \tif (err) {\n-\t\tp_err(\"failed to freeze map: %s\", strerror(errno));\n+\t\tp_err(\"failed to freeze map: %s\", bpf_strerror(errno));\n \t\treturn err;\n \t}\n \ndiff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c\nindex eb077236d2eaa..43599c79c93ac 100644\n--- a/tools/bpf/bpftool/prog.c\n+++ b/tools/bpf/bpftool/prog.c\n@@ -1499,7 +1499,7 @@ static int do_run(int argc, char **argv)\n \n \terr = bpf_prog_test_run_opts(fd, \u0026test_attr);\n \tif (err) {\n-\t\tp_err(\"failed to run program: %s\", strerror(errno));\n+\t\tp_err(\"failed to run program: %s\", bpf_strerror(errno));\n \t\tgoto free_ctx_out;\n \t}\n \ndiff --git a/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c b/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c\nnew file mode 100644\nindex 0000000000000..187b3f7843079\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c\n@@ -0,0 +1,133 @@\n+// SPDX-License-Identifier: GPL-2.0-only\n+#include \u003csys/socket.h\u003e\n+#include \u003cunistd.h\u003e\n+#include \u003cbpf/btf.h\u003e\n+#include \u003ctest_progs.h\u003e\n+#include \"bpftool_helpers.h\"\n+\n+#define PIN_PATH\t\"/sys/fs/bpf/test_bpftool_map_dump_sk_storage\"\n+#define QUEUE_PIN_PATH\t\"/sys/fs/bpf/test_bpftool_map_dump_queue\"\n+#define JSON_ERROR\t\"{\\\"error\\\":\\\"can't dump sk_storage map\"\n+\n+/* An empty socket storage map with an int value. */\n+static int create_sk_storage_map(void)\n+{\n+\tLIBBPF_OPTS(bpf_map_create_opts, opts,\n+\t\t .map_flags = BPF_F_NO_PREALLOC);\n+\tstruct btf *btf;\n+\tint int_id, fd = -1;\n+\n+\tbtf = btf__new_empty();\n+\tif (!ASSERT_OK_PTR(btf, \"btf__new_empty\"))\n+\t\treturn -1;\n+\n+\tint_id = btf__add_int(btf, \"int\", 4, BTF_INT_SIGNED);\n+\tif (!ASSERT_GT(int_id, 0, \"btf__add_int\"))\n+\t\tgoto out;\n+\tif (!ASSERT_OK(btf__load_into_kernel(btf), \"btf__load_into_kernel\"))\n+\t\tgoto out;\n+\n+\topts.btf_fd = btf__fd(btf);\n+\topts.btf_key_type_id = int_id;\n+\topts.btf_value_type_id = int_id;\n+\tfd = bpf_map_create(BPF_MAP_TYPE_SK_STORAGE, \"sk_storage\", sizeof(int),\n+\t\t\t sizeof(int), 0, \u0026opts);\n+\tASSERT_OK_FD(fd, \"bpf_map_create\");\n+out:\n+\tbtf__free(btf);\n+\treturn fd;\n+}\n+\n+static void test_sk_storage(void)\n+{\n+\tint map_fd, sk_fd = -1, value = 42, ret;\n+\tchar output[1024] = {};\n+\n+\tmap_fd = create_sk_storage_map();\n+\tif (map_fd \u003c 0)\n+\t\treturn;\n+\n+\tsk_fd = socket(AF_INET, SOCK_STREAM, 0);\n+\tif (!ASSERT_OK_FD(sk_fd, \"socket\"))\n+\t\tgoto out;\n+\tif (!ASSERT_OK(bpf_map_update_elem(map_fd, \u0026sk_fd, \u0026value, BPF_NOEXIST),\n+\t\t \"add socket storage\"))\n+\t\tgoto out;\n+\tif (!ASSERT_OK(bpf_obj_pin(map_fd, PIN_PATH), \"pin map\"))\n+\t\tgoto out;\n+\n+\t/*\n+\t * Socket storage can't be iterated, so the dump must fail with an\n+\t * error and nothing else, rather than print an empty map that holds\n+\t * an element. The buffer is cleared before each run so that a run\n+\t * that fails to start can't match stale or uninitialised output.\n+\t */\n+\tret = get_bpftool_command_output(\"-j map dump pinned \" PIN_PATH,\n+\t\t\t\t\t output, sizeof(output));\n+\tASSERT_NEQ(ret, 0, \"json dump fails\");\n+\tASSERT_STRNEQ(output, JSON_ERROR, strlen(JSON_ERROR),\n+\t\t \"json dump is only the error\");\n+\n+\tmemset(output, 0, sizeof(output));\n+\tret = get_bpftool_command_output(\"map dump pinned \" PIN_PATH,\n+\t\t\t\t\t output, sizeof(output));\n+\tASSERT_NEQ(ret, 0, \"plain dump fails\");\n+\tASSERT_NULL(strchr(output, '['), \"plain dump prints no elements\");\n+\n+\tmemset(output, 0, sizeof(output));\n+\tget_bpftool_command_output(\"map dump pinned \" PIN_PATH \" 2\u003e\u00261 \u003e/dev/null\",\n+\t\t\t\t output, sizeof(output));\n+\tASSERT_HAS_SUBSTR(output,\n+\t\t\t \"can't dump sk_storage map: Operation not supported\",\n+\t\t\t \"plain dump explains why on stderr\");\n+\n+out:\n+\tunlink(PIN_PATH);\n+\tif (sk_fd \u003e= 0)\n+\t\tclose(sk_fd);\n+\tclose(map_fd);\n+}\n+\n+/*\n+ * A queue map has no BTF, so its plain dump prints an element count\n+ * rather than JSON. A dump that ignored the error would print \"Found 0\n+ * elements\" for a queue that holds one.\n+ */\n+static void test_queue(void)\n+{\n+\tchar output[1024] = {};\n+\tint map_fd, value = 42, ret;\n+\n+\tmap_fd = bpf_map_create(BPF_MAP_TYPE_QUEUE, \"queue\", 0, sizeof(int), 1,\n+\t\t\t\tNULL);\n+\tif (!ASSERT_OK_FD(map_fd, \"bpf_map_create\"))\n+\t\treturn;\n+\tif (!ASSERT_OK(bpf_map_update_elem(map_fd, NULL, \u0026value, BPF_ANY),\n+\t\t \"push to queue\"))\n+\t\tgoto out;\n+\tif (!ASSERT_OK(bpf_obj_pin(map_fd, QUEUE_PIN_PATH), \"pin map\"))\n+\t\tgoto out;\n+\n+\tret = get_bpftool_command_output(\"map dump pinned \" QUEUE_PIN_PATH,\n+\t\t\t\t\t output, sizeof(output));\n+\tASSERT_NEQ(ret, 0, \"plain dump fails\");\n+\tASSERT_NULL(strstr(output, \"Found\"), \"plain dump prints no count\");\n+\n+\tmemset(output, 0, sizeof(output));\n+\tget_bpftool_command_output(\"map dump pinned \" QUEUE_PIN_PATH \" 2\u003e\u00261 \u003e/dev/null\",\n+\t\t\t\t output, sizeof(output));\n+\tASSERT_HAS_SUBSTR(output, \"can't dump queue map\",\n+\t\t\t \"plain dump explains why on stderr\");\n+\n+out:\n+\tunlink(QUEUE_PIN_PATH);\n+\tclose(map_fd);\n+}\n+\n+void test_bpftool_map_dump(void)\n+{\n+\tif (test__start_subtest(\"sk_storage\"))\n+\t\ttest_sk_storage();\n+\tif (test__start_subtest(\"queue\"))\n+\t\ttest_queue();\n+}\n"
} |
| 2/1 | 2026/10/17 04:46 | agent | patch-evaluator |
0mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch modifies only user-space utilities in tools/bpf/bpftool and a test in tools/testing/selftests/bpf. None of the changes affect the compiled kernel image (vmlinux) or kernel 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 3913824d3fdc4b7d83135e9f47d9a78197a6b337
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Oct 17 04:46:01 2026 +0000
syz-cluster: applied patch under review
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index f9b87efa7c9a7..ca5fa2f0bf9b1 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -72,6 +72,17 @@ void p_info(const char *fmt, ...)
va_end(ap);
}
+/*
+ * Like strerror(), but also knows ENOTSUPP (524), which the kernel returns
+ * to user space from some BPF commands although it is not a userspace errno.
+ */
+const char *bpf_strerror(int err)
+{
+ if (err == 524 /* ENOTSUPP */)
+ return "Operation not supported";
+ return strerror(err);
+}
+
static bool is_bpffs(const char *path)
{
struct statfs st_fs;
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index 6851346a60305..b1eb4b5d991b8 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -98,6 +98,7 @@ extern const char *cert_path;
void __printf(1, 2) p_err(const char *fmt, ...);
void __printf(1, 2) p_info(const char *fmt, ...);
+const char *bpf_strerror(int err);
bool is_prefix(const char *pfx, const char *str);
int detect_common_prefix(const char *arg, ...);
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 20d59eab09a12..4b65edf74859b 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -228,7 +228,7 @@ print_entry_error(struct bpf_map_info *map_info, void *key, int lookup_errno)
print_hex_data_json(key, map_info->key_size);
jsonw_name(json_wtr, "value");
jsonw_start_object(json_wtr); /* error */
- jsonw_string_field(json_wtr, "error", strerror(lookup_errno));
+ jsonw_string_field(json_wtr, "error", bpf_strerror(lookup_errno));
jsonw_end_object(json_wtr); /* error */
jsonw_end_object(json_wtr); /* entry */
} else {
@@ -241,7 +241,7 @@ print_entry_error(struct bpf_map_info *map_info, void *key, int lookup_errno)
msg = "<cannot read>";
print_entry_error_msg(map_info, key,
- msg ? : strerror(lookup_errno));
+ msg ? : bpf_strerror(lookup_errno));
}
}
@@ -856,6 +856,21 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,
}
}
+ /* Fail early to avoid an empty dump if map type cannot be iterated */
+ if (bpf_map_get_next_key(fd, NULL, key) && errno != ENOENT) {
+ const char *map_type_str, *err_str;
+
+ err_str = bpf_strerror(errno);
+ map_type_str = libbpf_bpf_map_type_str(info->type);
+ if (map_type_str)
+ p_err("can't dump %s map: %s", map_type_str, err_str);
+ else
+ p_err("can't dump map of type %u: %s", info->type,
+ err_str);
+ err = -1;
+ goto exit_free;
+ }
+
if (wtr) {
err = get_map_kv_btf(info, &btf);
if (err) {
@@ -883,8 +898,11 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,
while (true) {
err = bpf_map_get_next_key(fd, prev_key, key);
if (err) {
- if (errno == ENOENT)
+ if (errno == ENOENT) {
err = 0;
+ break;
+ }
+ p_err("can't get next key: %s", bpf_strerror(errno));
break;
}
if (!dump_map_elem(fd, key, value, info, btf, wtr,
@@ -897,7 +915,7 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,
jsonw_end_array(wtr); /* elements */
if (show_header)
jsonw_end_object(wtr); /* map object */
- } else {
+ } else if (!err) {
printf("Found %u element%s\n", num_elems,
num_elems != 1 ? "s" : "");
}
@@ -1032,7 +1050,7 @@ static int do_update(int argc, char **argv)
err = bpf_map_update_elem(fd, key, value, flags);
if (err) {
- p_err("update failed: %s", strerror(errno));
+ p_err("update failed: %s", bpf_strerror(errno));
goto exit_free;
}
@@ -1136,7 +1154,7 @@ static int do_lookup(int argc, char **argv)
printf("\n\nNot found\n");
}
} else {
- p_err("lookup failed: %s", strerror(errno));
+ p_err("lookup failed: %s", bpf_strerror(errno));
}
goto exit_free;
@@ -1188,7 +1206,7 @@ static int do_getnext(int argc, char **argv)
err = bpf_map_get_next_key(fd, key, nextkey);
if (err) {
- p_err("can't get next key: %s", strerror(errno));
+ p_err("can't get next key: %s", bpf_strerror(errno));
goto exit_free;
}
@@ -1253,7 +1271,7 @@ static int do_delete(int argc, char **argv)
err = bpf_map_delete_elem(fd, key);
if (err)
- p_err("delete failed: %s", strerror(errno));
+ p_err("delete failed: %s", bpf_strerror(errno));
exit_free:
free(key);
@@ -1381,7 +1399,7 @@ static int do_create(int argc, char **argv)
fd = bpf_map_create(map_type, map_name, key_size, value_size, max_entries, &attr);
if (fd < 0) {
- p_err("map create failed: %s", strerror(errno));
+ p_err("map create failed: %s", bpf_strerror(errno));
goto exit;
}
@@ -1427,7 +1445,7 @@ static int do_pop_dequeue(int argc, char **argv)
else
printf("Error: empty map\n");
} else {
- p_err("pop failed: %s", strerror(errno));
+ p_err("pop failed: %s", bpf_strerror(errno));
}
goto exit_free;
@@ -1462,7 +1480,7 @@ static int do_freeze(int argc, char **argv)
err = bpf_map_freeze(fd);
close(fd);
if (err) {
- p_err("failed to freeze map: %s", strerror(errno));
+ p_err("failed to freeze map: %s", bpf_strerror(errno));
return err;
}
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index eb077236d2eaa..43599c79c93ac 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1499,7 +1499,7 @@ static int do_run(int argc, char **argv)
err = bpf_prog_test_run_opts(fd, &test_attr);
if (err) {
- p_err("failed to run program: %s", strerror(errno));
+ p_err("failed to run program: %s", bpf_strerror(errno));
goto free_ctx_out;
}
diff --git a/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c b/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c
new file mode 100644
index 0000000000000..187b3f7843079
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <sys/socket.h>
+#include <unistd.h>
+#include <bpf/btf.h>
+#include <test_progs.h>
+#include "bpftool_helpers.h"
+
+#define PIN_PATH "/sys/fs/bpf/test_bpftool_map_dump_sk_storage"
+#define QUEUE_PIN_PATH "/sys/fs/bpf/test_bpftool_map_dump_queue"
+#define JSON_ERROR "{\"error\":\"can't dump sk_storage map"
+
+/* An empty socket storage map with an int value. */
+static int create_sk_storage_map(void)
+{
+ LIBBPF_OPTS(bpf_map_create_opts, opts,
+ .map_flags = BPF_F_NO_PREALLOC);
+ struct btf *btf;
+ int int_id, fd = -1;
+
+ btf = btf__new_empty();
+ if (!ASSERT_OK_PTR(btf, "btf__new_empty"))
+ return -1;
+
+ int_id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED);
+ if (!ASSERT_GT(int_id, 0, "btf__add_int"))
+ goto out;
+ if (!ASSERT_OK(btf__load_into_kernel(btf), "btf__load_into_kernel"))
+ goto out;
+
+ opts.btf_fd = btf__fd(btf);
+ opts.btf_key_type_id = int_id;
+ opts.btf_value_type_id = int_id;
+ fd = bpf_map_create(BPF_MAP_TYPE_SK_STORAGE, "sk_storage", sizeof(int),
+ sizeof(int), 0, &opts);
+ ASSERT_OK_FD(fd, "bpf_map_create");
+out:
+ btf__free(btf);
+ return fd;
+}
+
+static void test_sk_storage(void)
+{
+ int map_fd, sk_fd = -1, value = 42, ret;
+ char output[1024] = {};
+
+ map_fd = create_sk_storage_map();
+ if (map_fd < 0)
+ return;
+
+ sk_fd = socket(AF_INET, SOCK_STREAM, 0);
+ if (!ASSERT_OK_FD(sk_fd, "socket"))
+ goto out;
+ if (!ASSERT_OK(bpf_map_update_elem(map_fd, &sk_fd, &value, BPF_NOEXIST),
+ "add socket storage"))
+ goto out;
+ if (!ASSERT_OK(bpf_obj_pin(map_fd, PIN_PATH), "pin map"))
+ goto out;
+
+ /*
+ * Socket storage can't be iterated, so the dump must fail with an
+ * error and nothing else, rather than print an empty map that holds
+ * an element. The buffer is cleared before each run so that a run
+ * that fails to start can't match stale or uninitialised output.
+ */
+ ret = get_bpftool_command_output("-j map dump pinned " PIN_PATH,
+ output, sizeof(output));
+ ASSERT_NEQ(ret, 0, "json dump fails");
+ ASSERT_STRNEQ(output, JSON_ERROR, strlen(JSON_ERROR),
+ "json dump is only the error");
+
+ memset(output, 0, sizeof(output));
+ ret = get_bpftool_command_output("map dump pinned " PIN_PATH,
+ output, sizeof(output));
+ ASSERT_NEQ(ret, 0, "plain dump fails");
+ ASSERT_NULL(strchr(output, '['), "plain dump prints no elements");
+
+ memset(output, 0, sizeof(output));
+ get_bpftool_command_output("map dump pinned " PIN_PATH " 2>&1 >/dev/null",
+ output, sizeof(output));
+ ASSERT_HAS_SUBSTR(output,
+ "can't dump sk_storage map: Operation not supported",
+ "plain dump explains why on stderr");
+
+out:
+ unlink(PIN_PATH);
+ if (sk_fd >= 0)
+ close(sk_fd);
+ close(map_fd);
+}
+
+/*
+ * A queue map has no BTF, so its plain dump prints an element count
+ * rather than JSON. A dump that ignored the error would print "Found 0
+ * elements" for a queue that holds one.
+ */
+static void test_queue(void)
+{
+ char output[1024] = {};
+ int map_fd, value = 42, ret;
+
+ map_fd = bpf_map_create(BPF_MAP_TYPE_QUEUE, "queue", 0, sizeof(int), 1,
+ NULL);
+ if (!ASSERT_OK_FD(map_fd, "bpf_map_create"))
+ return;
+ if (!ASSERT_OK(bpf_map_update_elem(map_fd, NULL, &value, BPF_ANY),
+ "push to queue"))
+ goto out;
+ if (!ASSERT_OK(bpf_obj_pin(map_fd, QUEUE_PIN_PATH), "pin map"))
+ goto out;
+
+ ret = get_bpftool_command_output("map dump pinned " QUEUE_PIN_PATH,
+ output, sizeof(output));
+ ASSERT_NEQ(ret, 0, "plain dump fails");
+ ASSERT_NULL(strstr(output, "Found"), "plain dump prints no count");
+
+ memset(output, 0, sizeof(output));
+ get_bpftool_command_output("map dump pinned " QUEUE_PIN_PATH " 2>&1 >/dev/null",
+ output, sizeof(output));
+ ASSERT_HAS_SUBSTR(output, "can't dump queue map",
+ "plain dump explains why on stderr");
+
+out:
+ unlink(QUEUE_PIN_PATH);
+ close(map_fd);
+}
+
+void test_bpftool_map_dump(void)
+{
+ if (test__start_subtest("sk_storage"))
+ test_sk_storage();
+ if (test__start_subtest("queue"))
+ test_queue();
+}
|
| 3/2 | 2026/10/17 04:46 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 7117 output: 31 thoughts: 420 Thoughts: **Fuzzing Evaluation: Worth the Effort?** Okay, let's assess this patch series. My initial thought is whether it justifies the effort of fuzzing with syzkaller. The first step is to see exactly what code has been touched by the changes. A quick `git diff` reveals modifications in several files: `tools/bpf/bpftool/common.c`, `tools/bpf/bpftool/main.h`, `tools/bpf/bpftool/map.c`, `tools/bpf/bpftool/prog.c`, and `tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c`. Now, let's apply the filtering rules. We need to determine if these changes fall into the "WorthFuzzing=false" criteria. Specifically, are the modifications strictly non-kernel and non-executable? Let's see... all the files are under `tools/bpf/bpftool/` and `tools/testing/selftests/bpf/`. This means they are in user-space directories, and involve the `bpftool` utility and selftests, essentially. Critically, these changes do *not* impact the compiled kernel image (`vmlinux`) or kernel modules. I'm leaning towards "WorthFuzzing=false" based on this quick assessment. However, I want to be absolutely thorough. Before I definitively rule it out, I'm going to double-check the commit history. It's good practice to ensure there weren't any incidental changes, say, related to a build process or unrelated files that might have been part of the same commit. I'll use `git log` or `git diff HEAD~1` to see if there is any other code to check. If everything checks out, this series doesn't seem like a good candidate for syzkaller, which is designed for kernel-level bugs. |
| 4/2 | 2026/10/17 04:46 | tool | grepper |
0mArgs:{
"Expression": "bpf_strerror",
"PathPrefixes": [
"tools/bpf/"
]
}Results: {
"Output": "tools/bpf/bpftool/common.c=62=void p_info(const char *fmt, ...)\n--\ntools/bpf/bpftool/common.c-78- */\ntools/bpf/bpftool/common.c:79:const char *bpf_strerror(int err)\ntools/bpf/bpftool/common.c-80-{\n--\ntools/bpf/bpftool/gen.c=1238=static int do_skeleton(int argc, char **argv)\n--\ntools/bpf/bpftool/gen.c-1313-\t\terr = -errno;\ntools/bpf/bpftool/gen.c:1314:\t\tlibbpf_strerror(err, err_buf, sizeof(err_buf));\ntools/bpf/bpftool/gen.c-1315-\t\tp_err(\"failed to open BPF object file: %s\", err_buf);\n--\ntools/bpf/bpftool/gen.c=1651=static int do_subskeleton(int argc, char **argv)\n--\ntools/bpf/bpftool/gen.c-1733-\ntools/bpf/bpftool/gen.c:1734:\t\tlibbpf_strerror(errno, err_buf, sizeof(err_buf));\ntools/bpf/bpftool/gen.c-1735-\t\tp_err(\"failed to open BPF object file: %s\", err_buf);\n--\ntools/bpf/bpftool/main.h=100=void __printf(1, 2) p_info(const char *fmt, ...);\ntools/bpf/bpftool/main.h:101:const char *bpf_strerror(int err);\ntools/bpf/bpftool/main.h-102-\n--\ntools/bpf/bpftool/map.c=215=print_entry_error(struct bpf_map_info *map_info, void *key, int lookup_errno)\n--\ntools/bpf/bpftool/map.c-230-\t\tjsonw_start_object(json_wtr);\t/* error */\ntools/bpf/bpftool/map.c:231:\t\tjsonw_string_field(json_wtr, \"error\", bpf_strerror(lookup_errno));\ntools/bpf/bpftool/map.c-232-\t\tjsonw_end_object(json_wtr);\t/* error */\n--\ntools/bpf/bpftool/map.c-243-\t\tprint_entry_error_msg(map_info, key,\ntools/bpf/bpftool/map.c:244:\t\t\t\t msg ? : bpf_strerror(lookup_errno));\ntools/bpf/bpftool/map.c-245-\t}\n--\ntools/bpf/bpftool/map.c=831=map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,\n--\ntools/bpf/bpftool/map.c-862-\ntools/bpf/bpftool/map.c:863:\t\terr_str = bpf_strerror(errno);\ntools/bpf/bpftool/map.c-864-\t\tmap_type_str = libbpf_bpf_map_type_str(info-\u003etype);\n--\ntools/bpf/bpftool/map.c-904-\t\t\t}\ntools/bpf/bpftool/map.c:905:\t\t\tp_err(\"can't get next key: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-906-\t\t\tbreak;\n--\ntools/bpf/bpftool/map.c=1026=static int do_update(int argc, char **argv)\n--\ntools/bpf/bpftool/map.c-1052-\tif (err) {\ntools/bpf/bpftool/map.c:1053:\t\tp_err(\"update failed: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-1054-\t\tgoto exit_free;\n--\ntools/bpf/bpftool/map.c=1122=static int do_lookup(int argc, char **argv)\n--\ntools/bpf/bpftool/map.c-1156-\t\t} else {\ntools/bpf/bpftool/map.c:1157:\t\t\tp_err(\"lookup failed: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-1158-\t\t}\n--\ntools/bpf/bpftool/map.c=1174=static int do_getnext(int argc, char **argv)\n--\ntools/bpf/bpftool/map.c-1208-\tif (err) {\ntools/bpf/bpftool/map.c:1209:\t\tp_err(\"can't get next key: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-1210-\t\tgoto exit_free;\n--\ntools/bpf/bpftool/map.c=1245=static int do_delete(int argc, char **argv)\n--\ntools/bpf/bpftool/map.c-1273-\tif (err)\ntools/bpf/bpftool/map.c:1274:\t\tp_err(\"delete failed: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-1275-\n--\ntools/bpf/bpftool/map.c=1300=static int do_create(int argc, char **argv)\n--\ntools/bpf/bpftool/map.c-1401-\tif (fd \u003c 0) {\ntools/bpf/bpftool/map.c:1402:\t\tp_err(\"map create failed: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-1403-\t\tgoto exit;\n--\ntools/bpf/bpftool/map.c=1421=static int do_pop_dequeue(int argc, char **argv)\n--\ntools/bpf/bpftool/map.c-1447-\t\t} else {\ntools/bpf/bpftool/map.c:1448:\t\t\tp_err(\"pop failed: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-1449-\t\t}\n--\ntools/bpf/bpftool/map.c=1464=static int do_freeze(int argc, char **argv)\n--\ntools/bpf/bpftool/map.c-1482-\tif (err) {\ntools/bpf/bpftool/map.c:1483:\t\tp_err(\"failed to freeze map: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/map.c-1484-\t\treturn err;\n--\ntools/bpf/bpftool/net.c=931=static int do_show(int argc, char **argv)\n--\ntools/bpf/bpftool/net.c-996-\t\t\tjsonw_null(json_wtr);\ntools/bpf/bpftool/net.c:997:\t\tlibbpf_strerror(ret, err_buf, sizeof(err_buf));\ntools/bpf/bpftool/net.c-998-\t\tfprintf(stderr, \"Error: %s\\n\", err_buf);\n--\ntools/bpf/bpftool/prog.c=1367=static int do_run(int argc, char **argv)\n--\ntools/bpf/bpftool/prog.c-1501-\tif (err) {\ntools/bpf/bpftool/prog.c:1502:\t\tp_err(\"failed to run program: %s\", bpf_strerror(errno));\ntools/bpf/bpftool/prog.c-1503-\t\tgoto free_ctx_out;\n"
} |
| 5/2 | 2026/10/17 04:46 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 10051 output: 81 thoughts: 223 Thoughts: Here's my assessment of this patch: **Patch Analysis for Fuzzing Eligibility** Okay, so I've looked at the diff and it's pretty clear where the changes lie. The patch is solely touching the `tools/bpf/bpftool/` directory and the `tools/testing/selftests/bpf/` directory. Based on Section 2's guidelines, specifically the quoted criteria, I'm confident that this doesn't warrant fuzzing. The rule is very specific: we only skip fuzzing if all modifications are non-kernel, non-executable changes within user-space directories, like tools, self-tests, samples, or scripts, that *don't* impact the kernel image (`vmlinux`) or kernel modules. These changes are exactly that. No kernel code, no modules, purely user space tooling and tests. Therefore: * `WorthFuzzing` should be `false`. * There's no need to enable any specific configurations, so `EnableConfigs` remains an empty list: `[]`. * There are no focus symbols that need highlighting. So, the `FocusSymbols` is an empty list: `[]`. Okay, I'll go ahead and `set-results` based on this analysis. |
| 6/2 | 2026/10/17 04:46 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch modifies only user-space utilities in tools/bpf/bpftool and a test in tools/testing/selftests/bpf. None of the changes affect the compiled kernel image (vmlinux) or kernel modules.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch modifies only user-space utilities in tools/bpf/bpftool and a test in tools/testing/selftests/bpf. None of the changes affect the compiled kernel image (vmlinux) or kernel modules.",
"WorthFuzzing": false
} |
| 7/1 | 2026/10/17 04:46 | 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) |
|---|