AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/15 04:47 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch modifies the RISC-V 64-bit BPF JIT compiler (arch/riscv/net/) to support BPF private stacks, and updates BPF selftests in tools/testing/selftests/bpf/. Because the target architecture is amd64, the arch/riscv code paths are not compiled or executable, and the selftest files do not affect the compiled kernel image. Consequently, all modified code is unreachable on amd64.",
  "WorthFuzzing": false
}

1/1 2026/10/15 04:47 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 6fa536b1b9818c64a098002e6b45029d475f85b1\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Thu Oct 15 04:47:31 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/arch/riscv/net/bpf_jit.h b/arch/riscv/net/bpf_jit.h\nindex 5c4f53060c918..6d42083829f78 100644\n--- a/arch/riscv/net/bpf_jit.h\n+++ b/arch/riscv/net/bpf_jit.h\n@@ -14,6 +14,7 @@\n \n #define RV_MAX_REG_ARGS\t\t8\n #define RV_EXTRA_STK_ARGS\t(RV_MAX_REG_ARGS - MAX_BPF_FUNC_REG_ARGS)\n+#define PRIV_STACK_GUARD_SZ\t16\n \n /* verify runtime detection extension status */\n #define rv_ext_enabled(ext) \\\ndiff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c\nindex 788fcc21fd5b8..9a83770f04604 100644\n--- a/arch/riscv/net/bpf_jit_comp64.c\n+++ b/arch/riscv/net/bpf_jit_comp64.c\n@@ -2122,12 +2122,34 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,\n \treturn 0;\n }\n \n+static void emit_priv_stack_frame(struct rv_jit_context *ctx)\n+{\n+\tu64 fp = (__force u64)ctx-\u003eprog-\u003eaux-\u003epriv_stack_ptr + PRIV_STACK_GUARD_SZ;\n+\n+\tfp += round_up(ctx-\u003eprog-\u003eaux-\u003estack_depth, STACK_ALIGN);\n+\temit_imm(RV_REG_S5, fp, ctx);\n+#ifdef CONFIG_SMP\n+\temit_lw(RV_REG_T1, offsetof(struct thread_info, cpu), RV_REG_TP, ctx);\n+\temit_imm(RV_REG_T2, (u64)__per_cpu_offset, ctx);\n+\temit_sh3add(RV_REG_T1, RV_REG_T1, RV_REG_T2, ctx);\n+\temit_ld(RV_REG_T1, 0, RV_REG_T1, ctx);\n+\temit_add(RV_REG_S5, RV_REG_S5, RV_REG_T1, ctx);\n+#endif\n+}\n+\n void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)\n {\n+\tbool priv_stack = ctx-\u003eprog-\u003eaux-\u003epriv_stack_ptr;\n \tint i, stack_adjust = 0, store_offset, bpf_stack_adjust = ctx-\u003estack_arg_sz;\n \n-\tbpf_stack_adjust += round_up(ctx-\u003eprog-\u003eaux-\u003estack_depth, STACK_ALIGN);\n-\tif (bpf_stack_adjust)\n+\t/*\n+\t * With a private stack only the outgoing stack argument area is left in\n+\t * this frame. It has to stay: the caller writes it relative to SP while\n+\t * the callee reads it relative to RV_REG_FP, the caller's SP set below.\n+\t */\n+\tif (!priv_stack)\n+\t\tbpf_stack_adjust += round_up(ctx-\u003eprog-\u003eaux-\u003estack_depth, STACK_ALIGN);\n+\tif (bpf_stack_adjust || priv_stack)\n \t\tmark_fp(ctx);\n \n \tif (seen_reg(RV_REG_RA, ctx))\n@@ -2205,7 +2227,16 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)\n \n \temit_addi(RV_REG_FP, RV_REG_SP, stack_adjust, ctx);\n \n-\tif (bpf_stack_adjust)\n+\t/*\n+\t * Point BPF_REG_FP at the top of this CPU's private stack. A program\n+\t * with one can still be entered as a tail call target, at\n+\t * RV_TAILCALL_OFFSET, so this has to come after that entry point; the\n+\t * offset is a constant added to the target's bpf_func, so everything in\n+\t * front of it must also be the same size in every program.\n+\t */\n+\tif (priv_stack)\n+\t\temit_priv_stack_frame(ctx);\n+\telse if (bpf_stack_adjust)\n \t\temit_addi(RV_REG_S5, RV_REG_SP, bpf_stack_adjust, ctx);\n \n \tctx-\u003estack_size = stack_adjust;\n@@ -2303,3 +2334,8 @@ bool bpf_jit_supports_callx(void)\n {\n \treturn true;\n }\n+\n+bool bpf_jit_supports_private_stack(void)\n+{\n+\treturn true;\n+}\ndiff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c\nindex 5265dd5bd39e1..06f74d6943a98 100644\n--- a/arch/riscv/net/bpf_jit_core.c\n+++ b/arch/riscv/net/bpf_jit_core.c\n@@ -9,6 +9,7 @@\n #include \u003clinux/bpf.h\u003e\n #include \u003clinux/filter.h\u003e\n #include \u003clinux/memory.h\u003e\n+#include \u003clinux/percpu.h\u003e\n #include \u003casm/text-patching.h\u003e\n #include \u003casm/cfi.h\u003e\n #include \"bpf_jit.h\"\n@@ -44,6 +45,62 @@ bool bpf_jit_needs_zext(void)\n \treturn true;\n }\n \n+#define PRIV_STACK_GUARD_VAL\t0xEB9F12345678eb9fULL\n+\n+static u32 priv_stack_size(struct bpf_prog *prog)\n+{\n+\treturn round_up(prog-\u003eaux-\u003estack_depth, STACK_ALIGN) +\n+\t       2 * PRIV_STACK_GUARD_SZ;\n+}\n+\n+static int alloc_priv_stack(struct bpf_prog *prog)\n+{\n+\tu32 size = priv_stack_size(prog);\n+\tu32 end = (size - PRIV_STACK_GUARD_SZ) / sizeof(u64);\n+\tvoid __percpu *ptr;\n+\tint cpu, i;\n+\n+\tptr = __alloc_percpu_gfp(size, STACK_ALIGN, GFP_KERNEL);\n+\tif (!ptr)\n+\t\treturn -ENOMEM;\n+\n+\tfor_each_possible_cpu(cpu) {\n+\t\tu64 *stack = per_cpu_ptr(ptr, cpu);\n+\n+\t\tfor (i = 0; i \u003c PRIV_STACK_GUARD_SZ / sizeof(u64); i++) {\n+\t\t\tstack[i] = PRIV_STACK_GUARD_VAL;\n+\t\t\tstack[end + i] = PRIV_STACK_GUARD_VAL;\n+\t\t}\n+\t}\n+\tprog-\u003eaux-\u003epriv_stack_ptr = ptr;\n+\treturn 0;\n+}\n+\n+static void priv_stack_check_guard(struct bpf_prog *prog)\n+{\n+\tu32 end = (priv_stack_size(prog) - PRIV_STACK_GUARD_SZ) / sizeof(u64);\n+\tint cpu;\n+\n+\tfor_each_possible_cpu(cpu) {\n+\t\tu64 *stack = per_cpu_ptr(prog-\u003eaux-\u003epriv_stack_ptr, cpu);\n+\n+\t\tif (stack[0] != PRIV_STACK_GUARD_VAL ||\n+\t\t    stack[1] != PRIV_STACK_GUARD_VAL ||\n+\t\t    stack[end] != PRIV_STACK_GUARD_VAL ||\n+\t\t    stack[end + 1] != PRIV_STACK_GUARD_VAL) {\n+\t\t\tpr_err(\"bpf-jit: private stack overflow/underflow guard of prog %s corrupted on CPU %d\\n\",\n+\t\t\t       bpf_jit_get_prog_name(prog), cpu);\n+\t\t\treturn;\n+\t\t}\n+\t}\n+}\n+\n+static void free_priv_stack(struct bpf_prog *prog)\n+{\n+\tfree_percpu(prog-\u003eaux-\u003epriv_stack_ptr);\n+\tprog-\u003eaux-\u003epriv_stack_ptr = NULL;\n+}\n+\n struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prog *prog)\n {\n \tunsigned int prog_size = 0, extable_size = 0;\n@@ -82,12 +139,15 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr\n \t\t\t    round_up((stack_arg_cnt - RV_EXTRA_STK_ARGS) * 8, STACK_ALIGN) : 0;\n \n \tctx-\u003eprog = prog;\n+\tif (prog-\u003eaux-\u003ejits_use_priv_stack \u0026\u0026 alloc_priv_stack(prog))\n+\t\tgoto out_free_hdr;\n+\n \tctx-\u003eoffset = kvzalloc_objs(int, prog-\u003elen);\n \tif (!ctx-\u003eoffset)\n-\t\tgoto out_offset;\n+\t\tgoto out_free_hdr;\n \n \tif (build_body(ctx, extra_pass, NULL))\n-\t\tgoto out_offset;\n+\t\tgoto out_free_hdr;\n \n \tfor (i = 0; i \u003c prog-\u003elen; i++) {\n \t\tprev_ninsns += 32;\n@@ -102,7 +162,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr\n \t\tctx-\u003eprologue_len = ctx-\u003eninsns;\n \n \t\tif (build_body(ctx, extra_pass, ctx-\u003eoffset))\n-\t\t\tgoto out_offset;\n+\t\t\tgoto out_free_hdr;\n \n \t\tctx-\u003eepilogue_offset = ctx-\u003eninsns;\n \t\tbpf_jit_build_epilogue(ctx);\n@@ -122,7 +182,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr\n \t\t\t\t\t\t\t  bpf_fill_ill_insns,\n \t\t\t\t\t\t\t  bpf_prog_was_classic(prog));\n \t\t\tif (!jit_data-\u003ero_header)\n-\t\t\t\tgoto out_offset;\n+\t\t\t\tgoto out_free_hdr;\n \n \t\t\t/*\n \t\t\t * Use the image(RW) for writing the JITed instructions. But also save\n@@ -188,10 +248,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr\n \t\t\tctx-\u003eoffset[i] = ctx-\u003eoffset[i - 1];\n \t\tctx-\u003eoffset[0] = ninsns_rvoff(ctx-\u003eprologue_len);\n \t\tbpf_prog_update_insn_ptrs(prog, ctx-\u003eoffset, jit_data-\u003ero_image);\n-out_offset:\n-\t\tkvfree(ctx-\u003eoffset);\n-\t\tkfree(jit_data);\n-\t\tprog-\u003eaux-\u003ejit_data = NULL;\n+\t\tgoto out_free_ctx;\n \t}\n \n \treturn prog;\n@@ -207,7 +264,12 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr\n \t\t\t\t   sizeof(jit_data-\u003eheader-\u003esize));\n \t\tbpf_jit_binary_pack_free(jit_data-\u003ero_header, jit_data-\u003eheader);\n \t}\n-\tgoto out_offset;\n+\tfree_priv_stack(prog);\n+out_free_ctx:\n+\tkvfree(ctx-\u003eoffset);\n+\tkfree(jit_data);\n+\tprog-\u003eaux-\u003ejit_data = NULL;\n+\treturn prog;\n }\n \n u64 bpf_jit_alloc_exec_limit(void)\n@@ -259,6 +321,10 @@ void bpf_jit_free(struct bpf_prog *prog)\n \t\tprog-\u003ebpf_func = (void *)prog-\u003ebpf_func - cfi_get_offset();\n \t\thdr = bpf_jit_binary_pack_hdr(prog);\n \t\tbpf_jit_binary_pack_free(hdr, NULL);\n+\t\tif (prog-\u003eaux-\u003epriv_stack_ptr) {\n+\t\t\tpriv_stack_check_guard(prog);\n+\t\t\tfree_priv_stack(prog);\n+\t\t}\n \t\tWARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(prog));\n \t}\n \ndiff --git a/tools/testing/selftests/bpf/private_stack_runtime.h b/tools/testing/selftests/bpf/private_stack_runtime.h\nnew file mode 100644\nindex 0000000000000..8ed49ff66a6e4\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/private_stack_runtime.h\n@@ -0,0 +1,12 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+#ifndef __PRIVATE_STACK_RUNTIME_H\n+#define __PRIVATE_STACK_RUNTIME_H\n+\n+struct private_stack_result {\n+\tlong value;\n+\tlong first;\n+\tlong last;\n+\t__u32 cpu;\n+};\n+\n+#endif\ndiff --git a/tools/testing/selftests/bpf/prog_tests/private_stack_runtime.c b/tools/testing/selftests/bpf/prog_tests/private_stack_runtime.c\nnew file mode 100644\nindex 0000000000000..3af24ca8009f4\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/prog_tests/private_stack_runtime.c\n@@ -0,0 +1,83 @@\n+// SPDX-License-Identifier: GPL-2.0\n+#include \u003ctest_progs.h\u003e\n+#include \u003cnetwork_helpers.h\u003e\n+#include \"private_stack_runtime.h\"\n+#include \"private_stack_runtime.skel.h\"\n+\n+void test_private_stack_runtime(void)\n+{\n+#if defined(__riscv) \u0026\u0026 __riscv_xlen == 64\n+\tLIBBPF_OPTS(bpf_test_run_opts, opts,\n+\t\t    .data_in = \u0026pkt_v4,\n+\t\t    .data_size_in = sizeof(pkt_v4),\n+\t);\n+\tstruct private_stack_runtime *skel;\n+\tstruct bpf_link *trace = NULL, *ops = NULL;\n+\tcpu_set_t saved, single;\n+\tint cpu, err, tested = 0;\n+\n+\t/*\n+\t * Two independent halves. RUN_TESTS() validates the __jited patterns\n+\t * through the test loader, which builds its own object from the ELF\n+\t * bytes. The half below loads a separate skeleton to check the runtime\n+\t * values and the CPU the program reported, which disassembly patterns\n+\t * cannot express.\n+\t */\n+\tRUN_TESTS(private_stack_runtime);\n+\n+\tif (!ASSERT_OK(sched_getaffinity(0, sizeof(saved), \u0026saved), \"getaffinity\"))\n+\t\treturn;\n+\n+\tskel = private_stack_runtime__open();\n+\tif (!ASSERT_OK_PTR(skel, \"open\"))\n+\t\treturn;\n+\tif (!skel-\u003erodata-\u003ehas_stack_args) {\n+\t\ttest__skip();\n+\t\tgoto out;\n+\t}\n+\tskel-\u003erodata-\u003etarget_tgid = getpid();\n+\tif (!ASSERT_OK(private_stack_runtime__load(skel), \"load\"))\n+\t\tgoto out;\n+\n+\ttrace = bpf_program__attach_raw_tracepoint(skel-\u003eprogs.private_args, \"sys_enter\");\n+\tif (!ASSERT_OK_PTR(trace, \"attach_tracepoint\"))\n+\t\tgoto out;\n+\n+\tfor (cpu = 0; cpu \u003c CPU_SETSIZE; cpu++) {\n+\t\tif (!CPU_ISSET(cpu, \u0026saved))\n+\t\t\tcontinue;\n+\t\tCPU_ZERO(\u0026single);\n+\t\tCPU_SET(cpu, \u0026single);\n+\t\tif (!ASSERT_OK(sched_setaffinity(0, sizeof(single), \u0026single), \"setaffinity\"))\n+\t\t\tbreak;\n+\n+\t\terr = bpf_prog_test_run_opts(bpf_program__fd(skel-\u003eprogs.kernel_args), \u0026opts);\n+\t\tif (!ASSERT_OK(err, \"kernel_args\") || !ASSERT_EQ(opts.retval, 0, \"retval\"))\n+\t\t\tbreak;\n+\t\tsyscall(__NR_getpgid, 0);\n+\t\tASSERT_EQ(skel-\u003ebss-\u003eprivate_result.value, 324 + getpid(), \"private_value\");\n+\t\tASSERT_EQ(skel-\u003ebss-\u003eprivate_result.first, 29, \"private_first\");\n+\t\tASSERT_EQ(skel-\u003ebss-\u003eprivate_result.last, 324, \"private_last\");\n+\t\tASSERT_EQ(skel-\u003ebss-\u003eprivate_result.cpu, cpu, \"private_cpu\");\n+\t\tASSERT_EQ(skel-\u003ebss-\u003ekernel_result.value, 324 + getpid(), \"kernel_value\");\n+\t\tASSERT_EQ(skel-\u003ebss-\u003ekernel_result.first, 29, \"kernel_first\");\n+\t\tASSERT_EQ(skel-\u003ebss-\u003ekernel_result.last, 324, \"kernel_last\");\n+\t\tASSERT_EQ(skel-\u003ebss-\u003ekernel_result.cpu, cpu, \"kernel_cpu\");\n+\t\ttested++;\n+\t}\n+\tASSERT_GT(tested, 0, \"tested_cpus\");\n+\n+\tops = bpf_map__attach_struct_ops(skel-\u003emaps.zero_stack_ops);\n+\tif (!ASSERT_OK_PTR(ops, \"attach_zero_stack\"))\n+\t\tgoto out;\n+\tASSERT_OK(trigger_module_test_read(256), \"trigger_zero_stack\");\n+\tASSERT_EQ(skel-\u003ebss-\u003ezero_calls, 1, \"zero_stack_calls\");\n+out:\n+\tbpf_link__destroy(ops);\n+\tbpf_link__destroy(trace);\n+\tprivate_stack_runtime__destroy(skel);\n+\tASSERT_OK(sched_setaffinity(0, sizeof(saved), \u0026saved), \"restore_affinity\");\n+#else\n+\ttest__skip();\n+#endif\n+}\ndiff --git a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c\nindex 2b3ec2b790918..103179ff8733b 100644\n--- a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c\n+++ b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c\n@@ -6,7 +6,8 @@\n #include \"struct_ops_private_stack_recur.skel.h\"\n #include \"struct_ops_private_stack_large.skel.h\"\n \n-#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)\n+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \\\n+\t(defined(__riscv) \u0026\u0026 __riscv_xlen == 64)\n static void test_private_stack(void)\n {\n \tstruct struct_ops_private_stack *skel;\ndiff --git a/tools/testing/selftests/bpf/progs/private_stack_runtime.c b/tools/testing/selftests/bpf/progs/private_stack_runtime.c\nnew file mode 100644\nindex 0000000000000..61c144fd5cbec\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/progs/private_stack_runtime.c\n@@ -0,0 +1,140 @@\n+// SPDX-License-Identifier: GPL-2.0\n+#include \u003cvmlinux.h\u003e\n+#include \u003cbpf/bpf_helpers.h\u003e\n+#include \u003cbpf/bpf_tracing.h\u003e\n+#include \"../test_kmods/bpf_testmod.h\"\n+#include \"../private_stack_runtime.h\"\n+#include \"bpf_misc.h\"\n+\n+char _license[] SEC(\"license\") = \"GPL\";\n+\n+const volatile __u32 target_tgid;\n+const volatile long seed = 1;\n+\n+struct private_stack_result private_result, kernel_result;\n+int zero_calls;\n+\n+#ifdef __BPF_FEATURE_STACK_ARGUMENT\n+const volatile bool has_stack_args = true;\n+\n+struct frame {\n+\tlong slots[16];\n+};\n+\n+static __noinline long check_args(long a, long b, long c, long d, long e,\n+\t\t\t\t  long f, long g, long h, long i,\n+\t\t\t\t  struct frame *caller)\n+{\n+\tvolatile long local[16] = {};\n+\tlong sum;\n+\n+\tlocal[0] = a;\n+\tlocal[15] = i;\n+\tsum = a + 2 * b + 3 * c + 4 * d + 5 * e + 6 * f + 7 * g + 8 * h + 9 * i;\n+\tcaller-\u003eslots[15] = caller-\u003eslots[0] + sum + local[0] + local[15];\n+\treturn caller-\u003eslots[15] + (bpf_get_current_pid_tgid() \u003e\u003e 32);\n+}\n+\n+static __always_inline void run_args(struct private_stack_result *result)\n+{\n+\tstruct frame caller = {};\n+\tlong n = seed;\n+\n+\tcaller.slots[0] = 29;\n+\tresult-\u003evalue = check_args(n, n + 1, n + 2, n + 3, n + 4,\n+\t\t\t\t   n + 5, n + 6, n + 7, n + 8, \u0026caller);\n+\tresult-\u003efirst = caller.slots[0];\n+\tresult-\u003elast = caller.slots[15];\n+\tresult-\u003ecpu = bpf_get_smp_processor_id();\n+}\n+#else\n+const volatile bool has_stack_args = false;\n+\n+static __always_inline void run_args(struct private_stack_result *result)\n+{\n+}\n+#endif\n+\n+SEC(\"raw_tp/sys_enter\")\n+#ifdef __BPF_FEATURE_STACK_ARGUMENT\n+__arch_riscv64\n+/*\n+ * func #0, the caller. With a private stack the kernel frame holds only the\n+ * saved registers and the outgoing stack argument area, so it is 48 bytes =\n+ * 32 (ra, fp, s5, tcc) + 16 (two 8 byte outgoing slots). The 128 byte BPF\n+ * stack is not in this frame; it lives on the per-CPU private stack reached\n+ * through s5. The caller writes the two outgoing arguments relative to sp.\n+ */\n+__jited(\"\taddi\tsp, sp, -0x30\")\n+__jited(\"...\")\n+__jited(\"\tsd\t{{.*}}, 0x0(sp)\")\n+__jited(\"...\")\n+__jited(\"\tsd\t{{.*}}, 0x8(sp)\")\n+__jited(\"...\")\n+/*\n+ * func #1, the ten argument callee, gets a private stack of its own, so its\n+ * kernel frame is the 64 bytes of saved registers and nothing else. It reads\n+ * the two incoming stack arguments relative to fp (s0), which its prologue\n+ * set to the caller's sp, i.e. exactly the area the caller wrote above.\n+ */\n+__jited(\"func #1\")\n+__jited(\"...\")\n+__jited(\"\taddi\tsp, sp, -0x40\")\n+__jited(\"...\")\n+__jited(\"\tld\t{{.*}}, 0x0(s0)\")\n+__jited(\"...\")\n+__jited(\"\tld\t{{.*}}, 0x8(s0)\")\n+#endif\n+\n+int private_args(void *ctx)\n+{\n+\tif ((bpf_get_current_pid_tgid() \u003e\u003e 32) == target_tgid)\n+\t\trun_args(\u0026private_result);\n+\treturn 0;\n+}\n+\n+SEC(\"tc\")\n+#ifdef __BPF_FEATURE_STACK_ARGUMENT\n+__arch_riscv64\n+/*\n+ * func #0, the caller, control group. BPF_PROG_TYPE_SCHED_CLS is\n+ * NO_PRIV_STACK, so the 128 byte BPF stack stays in the kernel frame and s5\n+ * is sp relative: 176 bytes = 32 saved + 128 BPF stack + 16 outgoing, i.e.\n+ * 128 bytes larger than the private stack caller above. The outgoing stack\n+ * argument area is written relative to sp in both cases.\n+ */\n+__jited(\"\taddi\tsp, sp, -0xb0\")\n+__jited(\"...\")\n+__jited(\"\taddi\ts5, sp, 0x90\")\n+__jited(\"...\")\n+__jited(\"\tsd\t{{.*}}, 0x0(sp)\")\n+__jited(\"...\")\n+__jited(\"\tsd\t{{.*}}, 0x8(sp)\")\n+__jited(\"...\")\n+/* func #1, the callee: 208 bytes = 64 saved + 144 BPF stack. */\n+__jited(\"func #1\")\n+__jited(\"...\")\n+__jited(\"\taddi\tsp, sp, -0xd0\")\n+__jited(\"...\")\n+__jited(\"\tld\t{{.*}}, 0x0(s0)\")\n+__jited(\"...\")\n+__jited(\"\tld\t{{.*}}, 0x8(s0)\")\n+#endif\n+\n+int kernel_args(struct __sk_buff *skb)\n+{\n+\trun_args(\u0026kernel_result);\n+\treturn 0;\n+}\n+\n+SEC(\"struct_ops\")\n+int BPF_PROG(zero_stack)\n+{\n+\tzero_calls++;\n+\treturn 0;\n+}\n+\n+SEC(\".struct_ops\")\n+struct bpf_testmod_ops3 zero_stack_ops = {\n+\t.test_1 = (void *)zero_stack,\n+};\ndiff --git a/tools/testing/selftests/bpf/progs/verifier_private_stack.c b/tools/testing/selftests/bpf/progs/verifier_private_stack.c\nindex 3d9994a52464e..d9cebbc7355d1 100644\n--- a/tools/testing/selftests/bpf/progs/verifier_private_stack.c\n+++ b/tools/testing/selftests/bpf/progs/verifier_private_stack.c\n@@ -8,7 +8,8 @@\n /* From include/linux/filter.h */\n #define MAX_BPF_STACK    512\n \n-#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)\n+#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \\\n+\t(defined(__TARGET_ARCH_riscv) \u0026\u0026 __riscv_xlen == 64)\n \n struct elem {\n \tstruct bpf_timer t;\n@@ -42,6 +43,14 @@ __jited(\"\tmov\tx0, #0x2a\")\n __jited(\"\tstr\tx0, [x27]\")\n __jited(\"...\")\n __jited(\"\tldp\tx25, x27, [sp], {{.*}}\")\n+__arch_riscv64\n+__jited(\"\taddi\tsp, sp, -0x20\")\n+__jited(\"...\")\n+__jited(\"\tsd\ts5, 0x10(sp)\")\n+__jited(\"...\")\n+__jited(\"\tsd\ta0, -0x100(s5)\")\n+__jited(\"...\")\n+__jited(\"\tld\ts5, 0x10(sp)\")\n __naked void private_stack_single_prog(void)\n {\n \tasm volatile (\"\t\t\t\\\n@@ -60,6 +69,10 @@ __jited(\"\tsubq\t$0x8, %rsp\")\n __arch_arm64\n __jited(\"\tmov\tx25, sp\")\n __jited(\"\tsub\tsp, sp, #0x10\")\n+__arch_riscv64\n+__jited(\"\taddi\tsp, sp, -0x30\")\n+__jited(\"...\")\n+__jited(\"\taddi\ts5, sp, 0x10\")\n __naked void no_private_stack_nested(void)\n {\n \tasm volatile (\"\t\t\t\\\n@@ -113,6 +126,14 @@ __jited(\"\tstr\tx0, [x27]\")\n __jited(\"\tbl\t{{.*}}\")\n __jited(\"...\")\n __jited(\"\tldp\tx25, x27, [sp], {{.*}}\")\n+__arch_riscv64\n+__jited(\"\taddi\tsp, sp, -0x20\")\n+__jited(\"...\")\n+__jited(\"\tsd\ts5, 0x8(sp)\")\n+__jited(\"...\")\n+__jited(\"\tsd\ta0, -0x200(s5)\")\n+__jited(\"...\")\n+__jited(\"\tld\ts5, 0x8(sp)\")\n __naked void private_stack_nested_1(void)\n {\n \tasm volatile (\"\t\t\t\t\\\n@@ -183,6 +204,16 @@ __jited(\"\tbl\t0x{{.*}}\")\n __jited(\"\tmov\tx8, x0\")\n __jited(\"\tmov\tx8, #0x0\")\n __jited(\"\tldp\tx25, x27, [sp], {{.*}}\")\n+__arch_riscv64\n+__jited(\"func #1\")\n+__jited(\"...\")\n+__jited(\"\taddi\tsp, sp, -0x20\")\n+__jited(\"...\")\n+__jited(\"\tsd\ts5, 0x8(sp)\")\n+__jited(\"...\")\n+__jited(\"\tsd\ta0, -0x200(s5)\")\n+__jited(\"...\")\n+__jited(\"\tld\ts5, 0x8(sp)\")\n __naked void private_stack_callback(void)\n {\n \tasm volatile (\"\t\t\t\\\n@@ -313,6 +344,10 @@ __arch_arm64\n __jited(\"\tmrs\tx10, TPIDR_EL{{[0-1]}}\")\n __jited(\"\tadd\tx27, x27, x10\")\n __jited(\"\tadd\tx25, x27, {{.*}}\")\n+__arch_riscv64\n+__jited(\"\taddi\tsp, sp, -0x20\")\n+__jited(\"...\")\n+__jited(\"\tsd\ts5, 0x8(sp)\")\n int private_stack_async_callback_1(void)\n {\n \tstruct bpf_timer *arr_timer;\n@@ -342,6 +377,10 @@ __arch_x86_64\n __jited(\"\tsubq\t$0x100, %rsp\")\n __arch_arm64\n __jited(\"\tsub\tsp, sp, #0x100\")\n+__arch_riscv64\n+__jited(\"\taddi\tsp, sp, -0x120\")\n+__jited(\"...\")\n+__jited(\"\taddi\ts5, sp, 0x100\")\n int private_stack_async_callback_2(void)\n {\n \tstruct bpf_timer *arr_timer;\n"
}

2/1 2026/10/15 04:47 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the RISC-V 64-bit BPF JIT compiler (arch/riscv/net/) to support BPF private stacks, and updates BPF selftests in tools/testing/selftests/bpf/. Because the target architecture is amd64, the arch/riscv code paths are not compiled or executable, and the selftest files do not affect the compiled kernel image. Consequently, all modified code is unreachable on amd64.",
  "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 6fa536b1b9818c64a098002e6b45029d475f85b1
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Oct 15 04:47:31 2026 +0000

    syz-cluster: applied patch under review

diff --git a/arch/riscv/net/bpf_jit.h b/arch/riscv/net/bpf_jit.h
index 5c4f53060c918..6d42083829f78 100644
--- a/arch/riscv/net/bpf_jit.h
+++ b/arch/riscv/net/bpf_jit.h
@@ -14,6 +14,7 @@
 
 #define RV_MAX_REG_ARGS		8
 #define RV_EXTRA_STK_ARGS	(RV_MAX_REG_ARGS - MAX_BPF_FUNC_REG_ARGS)
+#define PRIV_STACK_GUARD_SZ	16
 
 /* verify runtime detection extension status */
 #define rv_ext_enabled(ext) \
diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index 788fcc21fd5b8..9a83770f04604 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -2122,12 +2122,34 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
 	return 0;
 }
 
+static void emit_priv_stack_frame(struct rv_jit_context *ctx)
+{
+	u64 fp = (__force u64)ctx->prog->aux->priv_stack_ptr + PRIV_STACK_GUARD_SZ;
+
+	fp += round_up(ctx->prog->aux->stack_depth, STACK_ALIGN);
+	emit_imm(RV_REG_S5, fp, ctx);
+#ifdef CONFIG_SMP
+	emit_lw(RV_REG_T1, offsetof(struct thread_info, cpu), RV_REG_TP, ctx);
+	emit_imm(RV_REG_T2, (u64)__per_cpu_offset, ctx);
+	emit_sh3add(RV_REG_T1, RV_REG_T1, RV_REG_T2, ctx);
+	emit_ld(RV_REG_T1, 0, RV_REG_T1, ctx);
+	emit_add(RV_REG_S5, RV_REG_S5, RV_REG_T1, ctx);
+#endif
+}
+
 void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)
 {
+	bool priv_stack = ctx->prog->aux->priv_stack_ptr;
 	int i, stack_adjust = 0, store_offset, bpf_stack_adjust = ctx->stack_arg_sz;
 
-	bpf_stack_adjust += round_up(ctx->prog->aux->stack_depth, STACK_ALIGN);
-	if (bpf_stack_adjust)
+	/*
+	 * With a private stack only the outgoing stack argument area is left in
+	 * this frame. It has to stay: the caller writes it relative to SP while
+	 * the callee reads it relative to RV_REG_FP, the caller's SP set below.
+	 */
+	if (!priv_stack)
+		bpf_stack_adjust += round_up(ctx->prog->aux->stack_depth, STACK_ALIGN);
+	if (bpf_stack_adjust || priv_stack)
 		mark_fp(ctx);
 
 	if (seen_reg(RV_REG_RA, ctx))
@@ -2205,7 +2227,16 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)
 
 	emit_addi(RV_REG_FP, RV_REG_SP, stack_adjust, ctx);
 
-	if (bpf_stack_adjust)
+	/*
+	 * Point BPF_REG_FP at the top of this CPU's private stack. A program
+	 * with one can still be entered as a tail call target, at
+	 * RV_TAILCALL_OFFSET, so this has to come after that entry point; the
+	 * offset is a constant added to the target's bpf_func, so everything in
+	 * front of it must also be the same size in every program.
+	 */
+	if (priv_stack)
+		emit_priv_stack_frame(ctx);
+	else if (bpf_stack_adjust)
 		emit_addi(RV_REG_S5, RV_REG_SP, bpf_stack_adjust, ctx);
 
 	ctx->stack_size = stack_adjust;
@@ -2303,3 +2334,8 @@ bool bpf_jit_supports_callx(void)
 {
 	return true;
 }
+
+bool bpf_jit_supports_private_stack(void)
+{
+	return true;
+}
diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c
index 5265dd5bd39e1..06f74d6943a98 100644
--- a/arch/riscv/net/bpf_jit_core.c
+++ b/arch/riscv/net/bpf_jit_core.c
@@ -9,6 +9,7 @@
 #include <linux/bpf.h>
 #include <linux/filter.h>
 #include <linux/memory.h>
+#include <linux/percpu.h>
 #include <asm/text-patching.h>
 #include <asm/cfi.h>
 #include "bpf_jit.h"
@@ -44,6 +45,62 @@ bool bpf_jit_needs_zext(void)
 	return true;
 }
 
+#define PRIV_STACK_GUARD_VAL	0xEB9F12345678eb9fULL
+
+static u32 priv_stack_size(struct bpf_prog *prog)
+{
+	return round_up(prog->aux->stack_depth, STACK_ALIGN) +
+	       2 * PRIV_STACK_GUARD_SZ;
+}
+
+static int alloc_priv_stack(struct bpf_prog *prog)
+{
+	u32 size = priv_stack_size(prog);
+	u32 end = (size - PRIV_STACK_GUARD_SZ) / sizeof(u64);
+	void __percpu *ptr;
+	int cpu, i;
+
+	ptr = __alloc_percpu_gfp(size, STACK_ALIGN, GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	for_each_possible_cpu(cpu) {
+		u64 *stack = per_cpu_ptr(ptr, cpu);
+
+		for (i = 0; i < PRIV_STACK_GUARD_SZ / sizeof(u64); i++) {
+			stack[i] = PRIV_STACK_GUARD_VAL;
+			stack[end + i] = PRIV_STACK_GUARD_VAL;
+		}
+	}
+	prog->aux->priv_stack_ptr = ptr;
+	return 0;
+}
+
+static void priv_stack_check_guard(struct bpf_prog *prog)
+{
+	u32 end = (priv_stack_size(prog) - PRIV_STACK_GUARD_SZ) / sizeof(u64);
+	int cpu;
+
+	for_each_possible_cpu(cpu) {
+		u64 *stack = per_cpu_ptr(prog->aux->priv_stack_ptr, cpu);
+
+		if (stack[0] != PRIV_STACK_GUARD_VAL ||
+		    stack[1] != PRIV_STACK_GUARD_VAL ||
+		    stack[end] != PRIV_STACK_GUARD_VAL ||
+		    stack[end + 1] != PRIV_STACK_GUARD_VAL) {
+			pr_err("bpf-jit: private stack overflow/underflow guard of prog %s corrupted on CPU %d\n",
+			       bpf_jit_get_prog_name(prog), cpu);
+			return;
+		}
+	}
+}
+
+static void free_priv_stack(struct bpf_prog *prog)
+{
+	free_percpu(prog->aux->priv_stack_ptr);
+	prog->aux->priv_stack_ptr = NULL;
+}
+
 struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prog *prog)
 {
 	unsigned int prog_size = 0, extable_size = 0;
@@ -82,12 +139,15 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
 			    round_up((stack_arg_cnt - RV_EXTRA_STK_ARGS) * 8, STACK_ALIGN) : 0;
 
 	ctx->prog = prog;
+	if (prog->aux->jits_use_priv_stack && alloc_priv_stack(prog))
+		goto out_free_hdr;
+
 	ctx->offset = kvzalloc_objs(int, prog->len);
 	if (!ctx->offset)
-		goto out_offset;
+		goto out_free_hdr;
 
 	if (build_body(ctx, extra_pass, NULL))
-		goto out_offset;
+		goto out_free_hdr;
 
 	for (i = 0; i < prog->len; i++) {
 		prev_ninsns += 32;
@@ -102,7 +162,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
 		ctx->prologue_len = ctx->ninsns;
 
 		if (build_body(ctx, extra_pass, ctx->offset))
-			goto out_offset;
+			goto out_free_hdr;
 
 		ctx->epilogue_offset = ctx->ninsns;
 		bpf_jit_build_epilogue(ctx);
@@ -122,7 +182,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
 							  bpf_fill_ill_insns,
 							  bpf_prog_was_classic(prog));
 			if (!jit_data->ro_header)
-				goto out_offset;
+				goto out_free_hdr;
 
 			/*
 			 * Use the image(RW) for writing the JITed instructions. But also save
@@ -188,10 +248,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
 			ctx->offset[i] = ctx->offset[i - 1];
 		ctx->offset[0] = ninsns_rvoff(ctx->prologue_len);
 		bpf_prog_update_insn_ptrs(prog, ctx->offset, jit_data->ro_image);
-out_offset:
-		kvfree(ctx->offset);
-		kfree(jit_data);
-		prog->aux->jit_data = NULL;
+		goto out_free_ctx;
 	}
 
 	return prog;
@@ -207,7 +264,12 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_pr
 				   sizeof(jit_data->header->size));
 		bpf_jit_binary_pack_free(jit_data->ro_header, jit_data->header);
 	}
-	goto out_offset;
+	free_priv_stack(prog);
+out_free_ctx:
+	kvfree(ctx->offset);
+	kfree(jit_data);
+	prog->aux->jit_data = NULL;
+	return prog;
 }
 
 u64 bpf_jit_alloc_exec_limit(void)
@@ -259,6 +321,10 @@ void bpf_jit_free(struct bpf_prog *prog)
 		prog->bpf_func = (void *)prog->bpf_func - cfi_get_offset();
 		hdr = bpf_jit_binary_pack_hdr(prog);
 		bpf_jit_binary_pack_free(hdr, NULL);
+		if (prog->aux->priv_stack_ptr) {
+			priv_stack_check_guard(prog);
+			free_priv_stack(prog);
+		}
 		WARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(prog));
 	}
 
diff --git a/tools/testing/selftests/bpf/private_stack_runtime.h b/tools/testing/selftests/bpf/private_stack_runtime.h
new file mode 100644
index 0000000000000..8ed49ff66a6e4
--- /dev/null
+++ b/tools/testing/selftests/bpf/private_stack_runtime.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PRIVATE_STACK_RUNTIME_H
+#define __PRIVATE_STACK_RUNTIME_H
+
+struct private_stack_result {
+	long value;
+	long first;
+	long last;
+	__u32 cpu;
+};
+
+#endif
diff --git a/tools/testing/selftests/bpf/prog_tests/private_stack_runtime.c b/tools/testing/selftests/bpf/prog_tests/private_stack_runtime.c
new file mode 100644
index 0000000000000..3af24ca8009f4
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/private_stack_runtime.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <test_progs.h>
+#include <network_helpers.h>
+#include "private_stack_runtime.h"
+#include "private_stack_runtime.skel.h"
+
+void test_private_stack_runtime(void)
+{
+#if defined(__riscv) && __riscv_xlen == 64
+	LIBBPF_OPTS(bpf_test_run_opts, opts,
+		    .data_in = &pkt_v4,
+		    .data_size_in = sizeof(pkt_v4),
+	);
+	struct private_stack_runtime *skel;
+	struct bpf_link *trace = NULL, *ops = NULL;
+	cpu_set_t saved, single;
+	int cpu, err, tested = 0;
+
+	/*
+	 * Two independent halves. RUN_TESTS() validates the __jited patterns
+	 * through the test loader, which builds its own object from the ELF
+	 * bytes. The half below loads a separate skeleton to check the runtime
+	 * values and the CPU the program reported, which disassembly patterns
+	 * cannot express.
+	 */
+	RUN_TESTS(private_stack_runtime);
+
+	if (!ASSERT_OK(sched_getaffinity(0, sizeof(saved), &saved), "getaffinity"))
+		return;
+
+	skel = private_stack_runtime__open();
+	if (!ASSERT_OK_PTR(skel, "open"))
+		return;
+	if (!skel->rodata->has_stack_args) {
+		test__skip();
+		goto out;
+	}
+	skel->rodata->target_tgid = getpid();
+	if (!ASSERT_OK(private_stack_runtime__load(skel), "load"))
+		goto out;
+
+	trace = bpf_program__attach_raw_tracepoint(skel->progs.private_args, "sys_enter");
+	if (!ASSERT_OK_PTR(trace, "attach_tracepoint"))
+		goto out;
+
+	for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
+		if (!CPU_ISSET(cpu, &saved))
+			continue;
+		CPU_ZERO(&single);
+		CPU_SET(cpu, &single);
+		if (!ASSERT_OK(sched_setaffinity(0, sizeof(single), &single), "setaffinity"))
+			break;
+
+		err = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.kernel_args), &opts);
+		if (!ASSERT_OK(err, "kernel_args") || !ASSERT_EQ(opts.retval, 0, "retval"))
+			break;
+		syscall(__NR_getpgid, 0);
+		ASSERT_EQ(skel->bss->private_result.value, 324 + getpid(), "private_value");
+		ASSERT_EQ(skel->bss->private_result.first, 29, "private_first");
+		ASSERT_EQ(skel->bss->private_result.last, 324, "private_last");
+		ASSERT_EQ(skel->bss->private_result.cpu, cpu, "private_cpu");
+		ASSERT_EQ(skel->bss->kernel_result.value, 324 + getpid(), "kernel_value");
+		ASSERT_EQ(skel->bss->kernel_result.first, 29, "kernel_first");
+		ASSERT_EQ(skel->bss->kernel_result.last, 324, "kernel_last");
+		ASSERT_EQ(skel->bss->kernel_result.cpu, cpu, "kernel_cpu");
+		tested++;
+	}
+	ASSERT_GT(tested, 0, "tested_cpus");
+
+	ops = bpf_map__attach_struct_ops(skel->maps.zero_stack_ops);
+	if (!ASSERT_OK_PTR(ops, "attach_zero_stack"))
+		goto out;
+	ASSERT_OK(trigger_module_test_read(256), "trigger_zero_stack");
+	ASSERT_EQ(skel->bss->zero_calls, 1, "zero_stack_calls");
+out:
+	bpf_link__destroy(ops);
+	bpf_link__destroy(trace);
+	private_stack_runtime__destroy(skel);
+	ASSERT_OK(sched_setaffinity(0, sizeof(saved), &saved), "restore_affinity");
+#else
+	test__skip();
+#endif
+}
diff --git a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
index 2b3ec2b790918..103179ff8733b 100644
--- a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
+++ b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
@@ -6,7 +6,8 @@
 #include "struct_ops_private_stack_recur.skel.h"
 #include "struct_ops_private_stack_large.skel.h"
 
-#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
+	(defined(__riscv) && __riscv_xlen == 64)
 static void test_private_stack(void)
 {
 	struct struct_ops_private_stack *skel;
diff --git a/tools/testing/selftests/bpf/progs/private_stack_runtime.c b/tools/testing/selftests/bpf/progs/private_stack_runtime.c
new file mode 100644
index 0000000000000..61c144fd5cbec
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/private_stack_runtime.c
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <vmlinux.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+#include "../test_kmods/bpf_testmod.h"
+#include "../private_stack_runtime.h"
+#include "bpf_misc.h"
+
+char _license[] SEC("license") = "GPL";
+
+const volatile __u32 target_tgid;
+const volatile long seed = 1;
+
+struct private_stack_result private_result, kernel_result;
+int zero_calls;
+
+#ifdef __BPF_FEATURE_STACK_ARGUMENT
+const volatile bool has_stack_args = true;
+
+struct frame {
+	long slots[16];
+};
+
+static __noinline long check_args(long a, long b, long c, long d, long e,
+				  long f, long g, long h, long i,
+				  struct frame *caller)
+{
+	volatile long local[16] = {};
+	long sum;
+
+	local[0] = a;
+	local[15] = i;
+	sum = a + 2 * b + 3 * c + 4 * d + 5 * e + 6 * f + 7 * g + 8 * h + 9 * i;
+	caller->slots[15] = caller->slots[0] + sum + local[0] + local[15];
+	return caller->slots[15] + (bpf_get_current_pid_tgid() >> 32);
+}
+
+static __always_inline void run_args(struct private_stack_result *result)
+{
+	struct frame caller = {};
+	long n = seed;
+
+	caller.slots[0] = 29;
+	result->value = check_args(n, n + 1, n + 2, n + 3, n + 4,
+				   n + 5, n + 6, n + 7, n + 8, &caller);
+	result->first = caller.slots[0];
+	result->last = caller.slots[15];
+	result->cpu = bpf_get_smp_processor_id();
+}
+#else
+const volatile bool has_stack_args = false;
+
+static __always_inline void run_args(struct private_stack_result *result)
+{
+}
+#endif
+
+SEC("raw_tp/sys_enter")
+#ifdef __BPF_FEATURE_STACK_ARGUMENT
+__arch_riscv64
+/*
+ * func #0, the caller. With a private stack the kernel frame holds only the
+ * saved registers and the outgoing stack argument area, so it is 48 bytes =
+ * 32 (ra, fp, s5, tcc) + 16 (two 8 byte outgoing slots). The 128 byte BPF
+ * stack is not in this frame; it lives on the per-CPU private stack reached
+ * through s5. The caller writes the two outgoing arguments relative to sp.
+ */
+__jited("	addi	sp, sp, -0x30")
+__jited("...")
+__jited("	sd	{{.*}}, 0x0(sp)")
+__jited("...")
+__jited("	sd	{{.*}}, 0x8(sp)")
+__jited("...")
+/*
+ * func #1, the ten argument callee, gets a private stack of its own, so its
+ * kernel frame is the 64 bytes of saved registers and nothing else. It reads
+ * the two incoming stack arguments relative to fp (s0), which its prologue
+ * set to the caller's sp, i.e. exactly the area the caller wrote above.
+ */
+__jited("func #1")
+__jited("...")
+__jited("	addi	sp, sp, -0x40")
+__jited("...")
+__jited("	ld	{{.*}}, 0x0(s0)")
+__jited("...")
+__jited("	ld	{{.*}}, 0x8(s0)")
+#endif
+
+int private_args(void *ctx)
+{
+	if ((bpf_get_current_pid_tgid() >> 32) == target_tgid)
+		run_args(&private_result);
+	return 0;
+}
+
+SEC("tc")
+#ifdef __BPF_FEATURE_STACK_ARGUMENT
+__arch_riscv64
+/*
+ * func #0, the caller, control group. BPF_PROG_TYPE_SCHED_CLS is
+ * NO_PRIV_STACK, so the 128 byte BPF stack stays in the kernel frame and s5
+ * is sp relative: 176 bytes = 32 saved + 128 BPF stack + 16 outgoing, i.e.
+ * 128 bytes larger than the private stack caller above. The outgoing stack
+ * argument area is written relative to sp in both cases.
+ */
+__jited("	addi	sp, sp, -0xb0")
+__jited("...")
+__jited("	addi	s5, sp, 0x90")
+__jited("...")
+__jited("	sd	{{.*}}, 0x0(sp)")
+__jited("...")
+__jited("	sd	{{.*}}, 0x8(sp)")
+__jited("...")
+/* func #1, the callee: 208 bytes = 64 saved + 144 BPF stack. */
+__jited("func #1")
+__jited("...")
+__jited("	addi	sp, sp, -0xd0")
+__jited("...")
+__jited("	ld	{{.*}}, 0x0(s0)")
+__jited("...")
+__jited("	ld	{{.*}}, 0x8(s0)")
+#endif
+
+int kernel_args(struct __sk_buff *skb)
+{
+	run_args(&kernel_result);
+	return 0;
+}
+
+SEC("struct_ops")
+int BPF_PROG(zero_stack)
+{
+	zero_calls++;
+	return 0;
+}
+
+SEC(".struct_ops")
+struct bpf_testmod_ops3 zero_stack_ops = {
+	.test_1 = (void *)zero_stack,
+};
diff --git a/tools/testing/selftests/bpf/progs/verifier_private_stack.c b/tools/testing/selftests/bpf/progs/verifier_private_stack.c
index 3d9994a52464e..d9cebbc7355d1 100644
--- a/tools/testing/selftests/bpf/progs/verifier_private_stack.c
+++ b/tools/testing/selftests/bpf/progs/verifier_private_stack.c
@@ -8,7 +8,8 @@
 /* From include/linux/filter.h */
 #define MAX_BPF_STACK    512
 
-#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64)
+#if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \
+	(defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64)
 
 struct elem {
 	struct bpf_timer t;
@@ -42,6 +43,14 @@ __jited("	mov	x0, #0x2a")
 __jited("	str	x0, [x27]")
 __jited("...")
 __jited("	ldp	x25, x27, [sp], {{.*}}")
+__arch_riscv64
+__jited("	addi	sp, sp, -0x20")
+__jited("...")
+__jited("	sd	s5, 0x10(sp)")
+__jited("...")
+__jited("	sd	a0, -0x100(s5)")
+__jited("...")
+__jited("	ld	s5, 0x10(sp)")
 __naked void private_stack_single_prog(void)
 {
 	asm volatile ("			\
@@ -60,6 +69,10 @@ __jited("	subq	$0x8, %rsp")
 __arch_arm64
 __jited("	mov	x25, sp")
 __jited("	sub	sp, sp, #0x10")
+__arch_riscv64
+__jited("	addi	sp, sp, -0x30")
+__jited("...")
+__jited("	addi	s5, sp, 0x10")
 __naked void no_private_stack_nested(void)
 {
 	asm volatile ("			\
@@ -113,6 +126,14 @@ __jited("	str	x0, [x27]")
 __jited("	bl	{{.*}}")
 __jited("...")
 __jited("	ldp	x25, x27, [sp], {{.*}}")
+__arch_riscv64
+__jited("	addi	sp, sp, -0x20")
+__jited("...")
+__jited("	sd	s5, 0x8(sp)")
+__jited("...")
+__jited("	sd	a0, -0x200(s5)")
+__jited("...")
+__jited("	ld	s5, 0x8(sp)")
 __naked void private_stack_nested_1(void)
 {
 	asm volatile ("				\
@@ -183,6 +204,16 @@ __jited("	bl	0x{{.*}}")
 __jited("	mov	x8, x0")
 __jited("	mov	x8, #0x0")
 __jited("	ldp	x25, x27, [sp], {{.*}}")
+__arch_riscv64
+__jited("func #1")
+__jited("...")
+__jited("	addi	sp, sp, -0x20")
+__jited("...")
+__jited("	sd	s5, 0x8(sp)")
+__jited("...")
+__jited("	sd	a0, -0x200(s5)")
+__jited("...")
+__jited("	ld	s5, 0x8(sp)")
 __naked void private_stack_callback(void)
 {
 	asm volatile ("			\
@@ -313,6 +344,10 @@ __arch_arm64
 __jited("	mrs	x10, TPIDR_EL{{[0-1]}}")
 __jited("	add	x27, x27, x10")
 __jited("	add	x25, x27, {{.*}}")
+__arch_riscv64
+__jited("	addi	sp, sp, -0x20")
+__jited("...")
+__jited("	sd	s5, 0x8(sp)")
 int private_stack_async_callback_1(void)
 {
 	struct bpf_timer *arr_timer;
@@ -342,6 +377,10 @@ __arch_x86_64
 __jited("	subq	$0x100, %rsp")
 __arch_arm64
 __jited("	sub	sp, sp, #0x100")
+__arch_riscv64
+__jited("	addi	sp, sp, -0x120")
+__jited("...")
+__jited("	addi	s5, sp, 0x100")
 int private_stack_async_callback_2(void)
 {
 	struct bpf_timer *arr_timer;

3/2 2026/10/15 04:47 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 10976
							output: 46
							thoughts: 1285
						

Thoughts:
**WorthFuzzing Evaluation: A Negative Outcome**

Okay, let's see if this patch series warrants syzkaller fuzzing. The target architecture is amd64, which is important. Let's look at the files modified: we have RISC-V BPF JIT compiler files (`arch/riscv/...`) and user-space selftests (`tools/testing/selftests/...`). No other files were in this commit, based on the prompt.

Now, let's apply the negative criteria from the instructions. The first is "Non-kernel and non-executable changes, which includes User-space directories, selftests, samples, or scripts that do not affect the compiled kernel image (vmlinux) or kernel modules." The second relevant one is, "Code paths exclusive to architectures other than the target architecture."

Now, let's go file by file. `arch/riscv/*` files are RISC-V specific; therefore, these are exclusive to that architecture and are not relevant to amd64. The files under `tools/testing/selftests/*` are selftests, so those do not impact the kernel image. Therefore, this patch is *not* worth fuzzing with syzkaller. No other files are touched in the commit or are linked based on the prompt, and no files in other architectures are shared. This looks like a definite "WorthFuzzing=false".



4/2 2026/10/15 04:47 tool grepper
0m Args:
{
  "Expression": "bpf_jit_supports_private_stack",
  "PathPrefixes": [
    "arch/",
    "include/",
    "kernel/bpf/"
  ]
}

Results:
{
  "Output": "arch/arm64/net/bpf_jit_comp.c=2227=struct bpf_prog *bpf_int_jit_compile(struct bpf_verifier_env *env, struct bpf_prog *prog)\n--\narch/arm64/net/bpf_jit_comp.c-2451-\narch/arm64/net/bpf_jit_comp.c:2452:bool bpf_jit_supports_private_stack(void)\narch/arm64/net/bpf_jit_comp.c-2453-{\n--\narch/powerpc/net/bpf_jit_comp.c=525=bool bpf_jit_supports_kfunc_call(void)\n--\narch/powerpc/net/bpf_jit_comp.c-529-\narch/powerpc/net/bpf_jit_comp.c:530:bool bpf_jit_supports_private_stack(void)\narch/powerpc/net/bpf_jit_comp.c-531-{\n--\narch/riscv/net/bpf_jit_comp64.c=2333=bool bpf_jit_supports_callx(void)\n--\narch/riscv/net/bpf_jit_comp64.c-2337-\narch/riscv/net/bpf_jit_comp64.c:2338:bool bpf_jit_supports_private_stack(void)\narch/riscv/net/bpf_jit_comp64.c-2339-{\n--\narch/x86/net/bpf_jit_comp.c=4594=bool bpf_jit_supports_exceptions(void)\n--\narch/x86/net/bpf_jit_comp.c-4602-\narch/x86/net/bpf_jit_comp.c:4603:bool bpf_jit_supports_private_stack(void)\narch/x86/net/bpf_jit_comp.c-4604-{\n--\ninclude/linux/filter.h=1254=bool bpf_jit_supports_insn(struct bpf_insn *insn, bool in_arena);\ninclude/linux/filter.h:1255:bool bpf_jit_supports_private_stack(void);\ninclude/linux/filter.h-1256-bool bpf_jit_supports_large_stack(void);\n--\nkernel/bpf/core.c=3504=bool __weak bpf_jit_supports_exceptions(void)\n--\nkernel/bpf/core.c-3508-\nkernel/bpf/core.c:3509:bool __weak bpf_jit_supports_private_stack(void)\nkernel/bpf/core.c-3510-{\n--\nkernel/bpf/verifier.c=5635=static enum priv_stack_mode bpf_enable_priv_stack(struct bpf_prog *prog)\nkernel/bpf/verifier.c-5636-{\nkernel/bpf/verifier.c:5637:\tif (!bpf_jit_supports_private_stack())\nkernel/bpf/verifier.c-5638-\t\treturn NO_PRIV_STACK;\n--\nkernel/bpf/verifier.c=21677=static int check_struct_ops_btf_id(struct bpf_verifier_env *env)\n--\nkernel/bpf/verifier.c-21754-\nkernel/bpf/verifier.c:21755:\tif (prog-\u003eaux-\u003epriv_stack_requested \u0026\u0026 !bpf_jit_supports_private_stack()) {\nkernel/bpf/verifier.c-21756-\t\tverbose(env, \"Private stack not supported by jit\\n\");\n"
}

5/2 2026/10/15 04:47 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 13559
							output: 130
							thoughts: 776
						

Thoughts:
**Analysis of RISC-V BPF JIT Patch Series for Fuzzing Eligibility**

Okay, let's break this down. My initial assessment based on the patch series is:

*   The changes are specifically targeted at RISC-V 64-bit BPF JIT compilation, residing in `arch/riscv/net/`, namely `bpf_jit.h`, `bpf_jit_comp64.c`, and `bpf_jit_core.c`. There are also modifications in `tools/testing/selftests/bpf/*`.
*   Crucially, these changes are *entirely* contained within the RISC-V architecture-specific directory, and user space self tests. This is a key observation.

Given that the target architecture for evaluation is amd64, I need to check whether this meets the criteria for `WorthFuzzing = false`, as defined in Section 2. The critical question here is whether the modified code falls into one or more categories that are *not* subject to fuzzing.

My analysis confirms that all changes are strictly within the following categories:

1.  `arch/riscv/`: This is architecture-specific code (RISC-V) that is *not* compiled or executed on amd64. It is structurally unreachable on the target architecture.
2.  `tools/testing/selftests/`: These are user-space tests. They are not compiled into the kernel image (`vmlinux`) or kernel modules, and hence do not affect the execution of the kernel on the target architecture.

Therefore, this patch series *does* fall under the `WorthFuzzing = false` criteria because the modified code is structurally unreachable on amd64. The reasoning is solid: RISC-V code is architecture-specific, and the self-tests do not impact the kernel image.

This means that `EnableConfigs` and `FocusSymbols` are both empty, which is as expected.

I am confident in these findings. I will now prepare the tool call based on this assessment, using the correct tool call format for `set-results`.



6/2 2026/10/15 04:47 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the RISC-V 64-bit BPF JIT compiler (arch/riscv/net/) to support BPF private stacks, and updates BPF selftests in tools/testing/selftests/bpf/. Because the target architecture is amd64, the arch/riscv code paths are not compiled or executable, and the selftest files do not affect the compiled kernel image. Consequently, all modified code is unreachable on amd64.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch modifies the RISC-V 64-bit BPF JIT compiler (arch/riscv/net/) to support BPF private stacks, and updates BPF selftests in tools/testing/selftests/bpf/. Because the target architecture is amd64, the arch/riscv code paths are not compiled or executable, and the selftest files do not affect the compiled kernel image. Consequently, all modified code is unreachable on amd64.",
  "WorthFuzzing": false
}

7/1 2026/10/15 04:47 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)