AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/09/27 03:18 flow patch-triage
1m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series adds support for dynamic ftrace with call ops when Clang kCFI is enabled on ARM64. All functional kernel changes are either in ARM64-specific files (arch/arm64/), guarded by ARM64-only macros (CC_USING_PATCHABLE_FUNCTION_PREFIX in compiler_types.h), or in build system scripts (scripts/, rust/). The only generic C change in kernel/trace/ftrace.c handles cases where ftrace_call_adjust() returns 0 to reject patch sites; on amd64, ftrace_call_adjust(addr) unconditionally returns addr (which is already checked non-NULL immediately prior), making the new branch unreachable on the target architecture. Therefore, no reachable executable code is modified for amd64.",
  "WorthFuzzing": false
}

1/1 2026/09/27 03:18 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 95c59580f2cc1e9df786293b63cfe3bc5b94ad84\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sun Sep 27 03:18:31 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig\nindex b5a51b0ef9440..cad2bdf3456ff 100644\n--- a/arch/arm64/Kconfig\n+++ b/arch/arm64/Kconfig\n@@ -190,7 +190,8 @@ config ARM64\n \tselect HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS \\\n \t\tif DYNAMIC_FTRACE_WITH_ARGS\n \tselect HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS \\\n-\t\tif (DYNAMIC_FTRACE_WITH_ARGS \u0026\u0026 !CFI \u0026\u0026 \\\n+\t\tif (DYNAMIC_FTRACE_WITH_ARGS \u0026\u0026 \\\n+\t\t    (!CFI || ARM64_CFI_PERMITS_CALL_OPS) \u0026\u0026 \\\n \t\t    (CC_IS_CLANG || !CC_OPTIMIZE_FOR_SIZE))\n \tselect FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY \\\n \t\tif DYNAMIC_FTRACE_WITH_ARGS\n@@ -276,6 +277,30 @@ config GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS\n \tdef_bool CC_IS_GCC\n \tdepends on $(cc-option,-fpatchable-function-entry=2)\n \n+config CC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION\n+\t# The section argument needs clang 21 or later:\n+\t# https://github.com/llvm/llvm-project/pull/131230\n+\tdef_bool $(cc-option,-fpatchable-function-entry=1$(comma)1$(comma).discard.patchable_function_entries)\n+\n+config RUSTC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION\n+\t# The section argument needs Rust 1.98.0 or later:\n+\t# https://github.com/rust-lang/rust/pull/157445\n+\tdef_bool $(rustc-option,-Zpatchable-function-entry=1$(comma)1$(comma).discard.patchable_function_entries)\n+\n+config ARM64_CFI_PERMITS_CALL_OPS\n+\tdef_bool y\n+\tdepends on CFI\n+\tdepends on CC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION\n+\tdepends on !RUST || RUSTC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION\n+\n+config ARM64_FUNCTION_PREFIX_NOPS\n+\tint\n+\tdefault 5 if DYNAMIC_FTRACE_WITH_CALL_OPS \u0026\u0026 CFI \u0026\u0026 \\\n+\t\t     (LTO_CLANG_THIN || LTO_CLANG_THIN_DIST) \u0026\u0026 ARM64_BTI_KERNEL\n+\tdefault 3 if DYNAMIC_FTRACE_WITH_CALL_OPS \u0026\u0026 CFI\n+\tdefault 2 if DYNAMIC_FTRACE_WITH_CALL_OPS\n+\tdefault 0\n+\n config 64BIT\n \tdef_bool y\n \ndiff --git a/arch/arm64/Makefile b/arch/arm64/Makefile\nindex 6b005c8fef706..b23430e2b8567 100644\n--- a/arch/arm64/Makefile\n+++ b/arch/arm64/Makefile\n@@ -142,7 +142,20 @@ CHECKFLAGS\t+= -D__aarch64__\n \n ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS),y)\n   KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY\n-  CC_FLAGS_FTRACE := -fpatchable-function-entry=4,2\n+  prefix_nops := $(CONFIG_ARM64_FUNCTION_PREFIX_NOPS)\n+  CC_FLAGS_FTRACE := -fpatchable-function-entry=$(shell expr $(prefix_nops) + 2),$(prefix_nops)\n+  ifeq ($(CONFIG_CFI),y)\n+    # Every object gets the prefix NOPs and no ftrace entry by default.\n+    # CC_FLAGS_FTRACE comes later for traced objects and overrides the\n+    # -fpatchable-function-entry.\n+    CFI_PREFIX_CFLAGS := -fpatchable-function-entry=$(prefix_nops),$(prefix_nops),.discard.patchable_function_entries \\\n+\t\t\t -DCC_USING_PATCHABLE_FUNCTION_PREFIX=$(prefix_nops)\n+    KBUILD_CFLAGS += $(CFI_PREFIX_CFLAGS)\n+    export CFI_PREFIX_CFLAGS\n+    # Rust functions are not patched by ftrace, but they are called indirectly\n+    # from C and make indirect calls themselves, so they need the same prefix.\n+    KBUILD_RUSTFLAGS += -Zpatchable-function-entry=$(prefix_nops),$(prefix_nops),.discard.patchable_function_entries\n+  endif\n else ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_ARGS),y)\n   KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY\n   CC_FLAGS_FTRACE := -fpatchable-function-entry=2\ndiff --git a/arch/arm64/include/asm/cfi.h b/arch/arm64/include/asm/cfi.h\nindex ab90f0351b7ae..03f02d4614c23 100644\n--- a/arch/arm64/include/asm/cfi.h\n+++ b/arch/arm64/include/asm/cfi.h\n@@ -4,4 +4,12 @@\n \n #define __bpfcall\n \n+#ifdef CONFIG_CFI\n+static inline int cfi_get_offset(void)\n+{\n+\treturn 4 + 4 * CONFIG_ARM64_FUNCTION_PREFIX_NOPS;\n+}\n+#define cfi_get_offset cfi_get_offset\n+#endif /* CONFIG_CFI */\n+\n #endif /* _ASM_ARM64_CFI_H */\ndiff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h\nindex 1621c84f44b32..5a7a515bf7cdc 100644\n--- a/arch/arm64/include/asm/ftrace.h\n+++ b/arch/arm64/include/asm/ftrace.h\n@@ -24,6 +24,22 @@\n #define FTRACE_PLT_IDX\t\t0\n #define NR_FTRACE_PLTS\t\t1\n \n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS\n+/*\n+ * ftrace_caller reads the callsite's ftrace_ops literal at\n+ * ALIGN_DOWN(LR, 8) - FTRACE_CALL_OPS_BIAS. See ftrace_call_ops_adjust()\n+ * for the layouts this serves.\n+ */\n+#define FTRACE_PREFIX_NOPS\tCONFIG_ARM64_FUNCTION_PREFIX_NOPS\n+#if FTRACE_PREFIX_NOPS == 2 || FTRACE_PREFIX_NOPS == 3\n+#define FTRACE_CALL_OPS_BIAS\t16\n+#elif FTRACE_PREFIX_NOPS == 5\n+#define FTRACE_CALL_OPS_BIAS\t24\n+#else\n+#error \"Unsupported number of function prefix NOPs\"\n+#endif\n+#endif /* CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS */\n+\n /*\n  * Currently, gcc tends to save the link register after the local variables\n  * on the stack. This causes the max stack tracer to report the function\ndiff --git a/arch/arm64/include/asm/linkage.h b/arch/arm64/include/asm/linkage.h\nindex d1f7a16729d25..14bc3c67c38b3 100644\n--- a/arch/arm64/include/asm/linkage.h\n+++ b/arch/arm64/include/asm/linkage.h\n@@ -39,6 +39,17 @@\n \tSYM_START(name, SYM_L_WEAK, SYM_A_NONE)\t\t\\\n \tbti c ;\n \n+/*\n+ * The compiler emits CONFIG_ARM64_FUNCTION_PREFIX_NOPS NOPs between a C\n+ * function's kCFI type hash and its entry point. Callers check the hash\n+ * at that offset.\n+ */\n+#define __CFI_TYPE(name)\t\t\t\t\\\n+\t.4byte __kcfi_typeid_##name ASM_NL\t\t\\\n+\t.rept CONFIG_ARM64_FUNCTION_PREFIX_NOPS ASM_NL\t\\\n+\tnop ASM_NL\t\t\t\t\t\\\n+\t.endr\n+\n #define SYM_TYPED_FUNC_START(name)\t\t\t\t\\\n \tSYM_TYPED_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)\t\\\n \tbti c ;\ndiff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S\nindex 025140caafe74..95727fee3cc55 100644\n--- a/arch/arm64/kernel/entry-ftrace.S\n+++ b/arch/arm64/kernel/entry-ftrace.S\n@@ -39,17 +39,17 @@ SYM_CODE_START(ftrace_caller)\n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS\n \t/*\n \t * The literal pointer to the ops is at an 8-byte aligned boundary\n-\t * which is either 12 or 16 bytes before the BL instruction in the call\n-\t * site. See ftrace_call_adjust() for details.\n+\t * before the BL instruction in the call site. See ftrace_call_adjust()\n+\t * and \u003casm/ftrace.h\u003e for details.\n \t *\n-\t * Therefore here the LR points at `literal + 16` or `literal + 20`,\n-\t * and we can find the address of the literal in either case by\n-\t * aligning to an 8-byte boundary and subtracting 16. We do the\n-\t * alignment first as this allows us to fold the subtraction into the\n-\t * LDR.\n+\t * Therefore here the LR points at `literal + FTRACE_CALL_OPS_BIAS` or\n+\t * `literal + FTRACE_CALL_OPS_BIAS + 4`, and we can find the address of\n+\t * the literal in either case by aligning to an 8-byte boundary and\n+\t * subtracting FTRACE_CALL_OPS_BIAS. We do the alignment first as this\n+\t * allows us to fold the subtraction into the LDR.\n \t */\n \tbic\tx11, x30, 0x7\n-\tldr\tx11, [x11, #-(4 * AARCH64_INSN_SIZE)]\t\t// op\n+\tldr\tx11, [x11, #-FTRACE_CALL_OPS_BIAS]\t\t// op\n \n #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS\n \t/*\ndiff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c\nindex e1a3c0b3a0514..0d922fa63f71b 100644\n--- a/arch/arm64/kernel/ftrace.c\n+++ b/arch/arm64/kernel/ftrace.c\n@@ -60,6 +60,73 @@ int ftrace_regs_query_register_offset(const char *name)\n }\n #endif\n \n+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS\n+/*\n+ * The address of the ops literal for a callsite whose `BL \u003ccaller\u003e` is at\n+ * @pc, exactly as ftrace_caller derives it from the return address.\n+ */\n+static unsigned long ftrace_call_ops_literal(unsigned long pc)\n+{\n+\treturn ALIGN_DOWN(pc + AARCH64_INSN_SIZE, 8) - FTRACE_CALL_OPS_BIAS;\n+}\n+\n+/*\n+ * addr is the first of the FTRACE_PREFIX_NOPS NOPs before a function:\n+ *\n+ * addr-04:\t\t.word\t\t// kCFI type hash, address-taken and non-local only\n+ * addr+00:\t\tNOP\t\t// FTRACE_PREFIX_NOPS of these, two hold the literal\n+ * func+00:\tfunc:\tBTI\tC\t// only if BTI and the function may be called indirectly\n+ * func+04:\t\tNOP\t\t// patched to MOV X9, LR\n+ * func+08:\t\tNOP\t\t// patched to BL \u003ccaller\u003e\n+ *\n+ * The compiler aligns whatever comes first to 8 bytes. ftrace_caller reads\n+ * the literal at ALIGN_DOWN(LR, 8) - FTRACE_CALL_OPS_BIAS, with LR at\n+ * func+8, or func+12 after a BTI:\n+ *\n+ *\tNOPs\tBIAS\tliteral at\n+ *\t2\t16\tfunc - 8\n+ *\t3\t16\tfunc - 8, or func - 12 if func % 8 == 4 (no hash, no BTI)\n+ *\t5\t24\tfunc - 16, or func - 12 / func - 20 if func % 8 == 4\n+ *\n+ * Return the address of the NOP to be patched to BL, or 0 when the two\n+ * NOPs are not there or the literal would fall outside the prefix.\n+ */\n+static unsigned long ftrace_call_ops_adjust(unsigned long addr)\n+{\n+\tunsigned long func = addr + FTRACE_PREFIX_NOPS * AARCH64_INSN_SIZE;\n+\tunsigned long pc = func + AARCH64_INSN_SIZE;\n+\tunsigned long literal;\n+\tu32 nop = aarch64_insn_gen_nop();\n+\n+\tif (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL) \u0026\u0026\n+\t    aarch64_insn_is_bti(le32_to_cpu(*(__le32 *)func)))\n+\t\tpc += AARCH64_INSN_SIZE;\n+\n+\t/* Objects built with only the prefix NOPs have nothing to patch. */\n+\tif (le32_to_cpu(*(__le32 *)(pc - AARCH64_INSN_SIZE)) != nop ||\n+\t    le32_to_cpu(*(__le32 *)pc) != nop) {\n+\t\tpr_warn_ratelimited(\"ftrace: no patchable entry at %ps\\n\",\n+\t\t\t\t    (void *)func);\n+\t\treturn 0;\n+\t}\n+\n+\t/* The literal would overlap the type hash or the entry point. */\n+\tliteral = ftrace_call_ops_literal(pc);\n+\tif (literal \u003c addr || literal + sizeof(u64) \u003e func) {\n+\t\tpr_warn_ratelimited(\"ftrace: cannot trace %ps: no room for the ops literal\\n\",\n+\t\t\t\t    (void *)func);\n+\t\treturn 0;\n+\t}\n+\n+\treturn pc;\n+}\n+#else\n+static unsigned long ftrace_call_ops_adjust(unsigned long addr)\n+{\n+\treturn 0;\n+}\n+#endif /* CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS */\n+\n unsigned long ftrace_call_adjust(unsigned long addr)\n {\n \t/*\n@@ -91,56 +158,7 @@ unsigned long ftrace_call_adjust(unsigned long addr)\n \tif (!IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))\n \t\treturn addr + AARCH64_INSN_SIZE;\n \n-\t/*\n-\t * When using patchable-function-entry with pre-function NOPs, addr is\n-\t * the address of the first pre-function NOP.\n-\t *\n-\t * Starting from an 8-byte aligned base, the compiler has either\n-\t * generated:\n-\t *\n-\t * addr+00:\t\tNOP\t\t// Literal (first 32 bits)\n-\t * addr+04:\t\tNOP\t\t// Literal (last 32 bits)\n-\t * addr+08:\tfunc:\tNOP\t\t// To be patched to MOV X9, LR\n-\t * addr+12:\t\tNOP\t\t// To be patched to BL \u003ccaller\u003e\n-\t *\n-\t * Or:\n-\t *\n-\t * addr+00:\t\tNOP\t\t// Literal (first 32 bits)\n-\t * addr+04:\t\tNOP\t\t// Literal (last 32 bits)\n-\t * addr+08:\tfunc:\tBTI\tC\n-\t * addr+12:\t\tNOP\t\t// To be patched to MOV X9, LR\n-\t * addr+16:\t\tNOP\t\t// To be patched to BL \u003ccaller\u003e\n-\t *\n-\t * We must adjust addr to the address of the NOP which will be patched\n-\t * to `BL \u003ccaller\u003e`, which is at either addr+12 or addr+16 depending on\n-\t * whether there is a BTI.\n-\t */\n-\n-\tif (!IS_ALIGNED(addr, sizeof(unsigned long))) {\n-\t\tWARN_RATELIMIT(1, \"Misaligned patch-site %pS\\n\",\n-\t\t\t       (void *)(addr + 8));\n-\t\treturn 0;\n-\t}\n-\n-\t/* Skip the NOPs placed before the function entry point */\n-\taddr += 2 * AARCH64_INSN_SIZE;\n-\n-\t/* Skip any BTI */\n-\tif (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)) {\n-\t\tu32 insn = le32_to_cpu(*(__le32 *)addr);\n-\n-\t\tif (aarch64_insn_is_bti(insn)) {\n-\t\t\taddr += AARCH64_INSN_SIZE;\n-\t\t} else if (insn != aarch64_insn_gen_nop()) {\n-\t\t\tWARN_RATELIMIT(1, \"unexpected insn in patch-site %pS: 0x%08x\\n\",\n-\t\t\t\t       (void *)addr, insn);\n-\t\t}\n-\t}\n-\n-\t/* Skip the first NOP after function entry */\n-\taddr += AARCH64_INSN_SIZE;\n-\n-\treturn addr;\n+\treturn ftrace_call_ops_adjust(addr);\n }\n \n /* Convert fentry_ip to the symbol address without kallsyms */\n@@ -368,7 +386,7 @@ static const struct ftrace_ops *arm64_rec_get_ops(struct dyn_ftrace *rec)\n static int ftrace_rec_set_ops(const struct dyn_ftrace *rec,\n \t\t\t      const struct ftrace_ops *ops)\n {\n-\tunsigned long literal = ALIGN_DOWN(rec-\u003eip - 12, 8);\n+\tunsigned long literal = ftrace_call_ops_literal(rec-\u003eip);\n \treturn aarch64_insn_write_literal_u64((void *)literal,\n \t\t\t\t\t      (unsigned long)ops);\n }\ndiff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile\nindex be92d73c25b21..df9f78dd9daec 100644\n--- a/arch/arm64/kernel/pi/Makefile\n+++ b/arch/arm64/kernel/pi/Makefile\n@@ -18,6 +18,8 @@ CFLAGS_map_range.o += -mstrict-align\n KBUILD_CFLAGS\t:= $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))\n # disable LTO\n KBUILD_CFLAGS\t:= $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))\n+# the discard section holds absolute relocations, which relacheck rejects\n+KBUILD_CFLAGS\t:= $(filter-out $(CFI_PREFIX_CFLAGS), $(KBUILD_CFLAGS))\n \n hostprogs\t:= relacheck\n \ndiff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile\nindex 7dec05dd33b70..44f4a6622ccd2 100644\n--- a/arch/arm64/kernel/vdso/Makefile\n+++ b/arch/arm64/kernel/vdso/Makefile\n@@ -38,7 +38,7 @@ ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO\n CC_FLAGS_REMOVE_VDSO := $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \\\n \t\t\t$(RANDSTRUCT_CFLAGS) $(KSTACK_ERASE_CFLAGS) \\\n \t\t\t$(GCC_PLUGINS_CFLAGS) \\\n-\t\t\t$(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \\\n+\t\t\t$(CC_FLAGS_LTO) $(CC_FLAGS_CFI) $(CFI_PREFIX_CFLAGS) \\\n \t\t\t-Wmissing-prototypes -Wmissing-declarations\n \n CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables\ndiff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c\nindex c18e005a41dbe..7ad14d9847138 100644\n--- a/arch/arm64/net/bpf_jit_comp.c\n+++ b/arch/arm64/net/bpf_jit_comp.c\n@@ -185,8 +185,12 @@ static inline void emit_bti(u32 insn, struct jit_ctx *ctx)\n \n static inline void emit_kcfi(u32 hash, struct jit_ctx *ctx)\n {\n-\tif (IS_ENABLED(CONFIG_CFI))\n-\t\temit_u32_data(hash, ctx);\n+\tif (!IS_ENABLED(CONFIG_CFI))\n+\t\treturn;\n+\n+\temit_u32_data(hash, ctx);\n+\tfor (int i = 0; i \u003c CONFIG_ARM64_FUNCTION_PREFIX_NOPS; i++)\n+\t\temit(A64_NOP, ctx);\n }\n \n /*\ndiff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile\nindex 77a2b2d74f3f6..9fb4e23da4535 100644\n--- a/drivers/firmware/efi/libstub/Makefile\n+++ b/drivers/firmware/efi/libstub/Makefile\n@@ -53,7 +53,7 @@ KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS))\n # remove SCS flags from all objects in this directory\n KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))\n # disable CFI\n-KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_CFI), $(KBUILD_CFLAGS))\n+KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_CFI) $(CFI_PREFIX_CFLAGS), $(KBUILD_CFLAGS))\n # disable LTO\n KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))\n \ndiff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h\nindex c5921f1390079..43dafaa061942 100644\n--- a/include/linux/compiler_types.h\n+++ b/include/linux/compiler_types.h\n@@ -211,6 +211,15 @@ struct ftrace_likely_data {\n \n #if defined(CC_USING_HOTPATCH)\n #define notrace\t\t\t__attribute__((hotpatch(0, 0)))\n+#elif defined(CC_USING_PATCHABLE_FUNCTION_PREFIX) \u0026\u0026 !defined(__BINDGEN__)\n+/*\n+ * Not for bindgen: its libclang may not support the section argument\n+ * (Clang \u003e= 21), and leaving the attribute out does not change the ABI.\n+ */\n+#define notrace\t\t\t\t\t\t\t\t\\\n+\t__attribute__((patchable_function_entry(CC_USING_PATCHABLE_FUNCTION_PREFIX, \\\n+\t\t\t\t\t\t CC_USING_PATCHABLE_FUNCTION_PREFIX, \\\n+\t\t\t\t\t\t \".discard.patchable_function_entries\")))\n #elif defined(CC_USING_PATCHABLE_FUNCTION_ENTRY)\n #define notrace\t\t\t__attribute__((patchable_function_entry(0, 0)))\n #else\ndiff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c\nindex f9d80c7bd9f16..fa541d3e8784a 100644\n--- a/kernel/trace/ftrace.c\n+++ b/kernel/trace/ftrace.c\n@@ -7676,6 +7676,11 @@ static int ftrace_process_locs(struct module *mod,\n \t\t}\n \n \t\taddr = ftrace_call_adjust(addr);\n+\t\t/* The architecture may return 0 to reject a patch site */\n+\t\tif (!addr) {\n+\t\t\tskipped++;\n+\t\t\tcontinue;\n+\t\t}\n \n \t\tend_offset = (pg-\u003eindex+1) * sizeof(pg-\u003erecords[0]);\n \t\tif (end_offset \u003e PAGE_SIZE \u003c\u003c pg-\u003eorder) {\n@@ -7689,6 +7694,20 @@ static int ftrace_process_locs(struct module *mod,\n \t\trec-\u003eip = addr;\n \t}\n \n+\t/*\n+\t * ftrace_release_mod() finds a module's page groups by their first\n+\t * record. If every entry was skipped there is none, so unlink the\n+\t * new page groups and free them now.\n+\t */\n+\tif (mod \u0026\u0026 !start_pg-\u003eindex) {\n+\t\tftrace_pages-\u003enext = NULL;\n+\t\tmutex_unlock(\u0026ftrace_lock);\n+\t\t/* Need to synchronize with ftrace_location_range() */\n+\t\tsynchronize_rcu();\n+\t\tftrace_free_pages(start_pg);\n+\t\treturn 0;\n+\t}\n+\n \tif (pg-\u003enext) {\n \t\tpg_unuse = pg-\u003enext;\n \t\tpg-\u003enext = NULL;\ndiff --git a/rust/Makefile b/rust/Makefile\nindex da1a7409d9845..b402ab768f729 100644\n--- a/rust/Makefile\n+++ b/rust/Makefile\n@@ -511,7 +511,12 @@ endif\n # prototypes for functions like `memcpy` -- if this flag is not passed,\n # `bindgen`-generated prototypes use `c_ulong` or `c_uint` depending on\n # architecture instead of generating `usize`.\n-bindgen_c_flags_final = $(bindgen_c_flags_lto) -fno-builtin -D__BINDGEN__\n+#\n+# Do not pass -fpatchable-function-entry to bindgen: its libclang may not\n+# support the section argument (Clang \u003e= 21), and removing the flag does not\n+# change the ABI.\n+bindgen_c_flags_final = $(filter-out -fpatchable-function-entry=%, \\\n+\t$(bindgen_c_flags_lto)) -fno-builtin -D__BINDGEN__\n \n # `--rust-target` points to our minimum supported Rust version.\n quiet_cmd_bindgen = BINDGEN $@\ndiff --git a/scripts/Makefile b/scripts/Makefile\nindex 3434a82a119f0..daad9b9540b8d 100644\n--- a/scripts/Makefile\n+++ b/scripts/Makefile\n@@ -51,6 +51,10 @@ endif\n \n ifdef CONFIG_BUILDTIME_MCOUNT_SORT\n HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED\n+# 0 or unset (no prefix NOPs) leaves sorttable's built-in default in place.\n+ifneq ($(filter-out 0,$(CONFIG_ARM64_FUNCTION_PREFIX_NOPS)),)\n+HOSTCFLAGS_sorttable.o += -DFUNCTION_PREFIX_BYTES=$(shell expr 4 \\* $(CONFIG_ARM64_FUNCTION_PREFIX_NOPS))\n+endif\n endif\n \n # The following programs are only built on demand\ndiff --git a/scripts/sorttable.c b/scripts/sorttable.c\nindex d8dc2a1b7c312..925382bb23dcc 100644\n--- a/scripts/sorttable.c\n+++ b/scripts/sorttable.c\n@@ -281,6 +281,11 @@ static int add_field(uint64_t addr, uint64_t size)\n /* Used for when mcount/fentry is before the function entry */\n static int before_func;\n \n+/* How far before the function entry a patchable entry may be recorded */\n+#ifndef FUNCTION_PREFIX_BYTES\n+#define FUNCTION_PREFIX_BYTES\t8\n+#endif\n+\n /* Only return match if the address lies inside the function size */\n static int cmp_func_addr(const void *K, const void *A)\n {\n@@ -899,7 +904,7 @@ static int do_file(char const *const fname, void *addr)\n \t\t/* fallthrough */\n \tcase EM_RISCV:\n \t\t/* arm64 and RISC-V place patchable entries before the function. */\n-\t\tbefore_func = 8;\n+\t\tbefore_func = FUNCTION_PREFIX_BYTES;\n #else\n \tcase EM_AARCH64:\n \tcase EM_RISCV:\n"
}

2/1 2026/09/27 03:18 agent patch-evaluator
1m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series adds support for dynamic ftrace with call ops when Clang kCFI is enabled on ARM64. All functional kernel changes are either in ARM64-specific files (arch/arm64/), guarded by ARM64-only macros (CC_USING_PATCHABLE_FUNCTION_PREFIX in compiler_types.h), or in build system scripts (scripts/, rust/). The only generic C change in kernel/trace/ftrace.c handles cases where ftrace_call_adjust() returns 0 to reject patch sites; on amd64, ftrace_call_adjust(addr) unconditionally returns addr (which is already checked non-NULL immediately prior), making the new branch unreachable on the target architecture. Therefore, no reachable executable code is modified for 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 95c59580f2cc1e9df786293b63cfe3bc5b94ad84
Author: syz-cluster <triage@syzkaller.com>
Date:   Sun Sep 27 03:18:31 2026 +0000

    syz-cluster: applied patch under review

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b5a51b0ef9440..cad2bdf3456ff 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -190,7 +190,8 @@ config ARM64
 	select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS \
 		if DYNAMIC_FTRACE_WITH_ARGS
 	select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS \
-		if (DYNAMIC_FTRACE_WITH_ARGS && !CFI && \
+		if (DYNAMIC_FTRACE_WITH_ARGS && \
+		    (!CFI || ARM64_CFI_PERMITS_CALL_OPS) && \
 		    (CC_IS_CLANG || !CC_OPTIMIZE_FOR_SIZE))
 	select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY \
 		if DYNAMIC_FTRACE_WITH_ARGS
@@ -276,6 +277,30 @@ config GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS
 	def_bool CC_IS_GCC
 	depends on $(cc-option,-fpatchable-function-entry=2)
 
+config CC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION
+	# The section argument needs clang 21 or later:
+	# https://github.com/llvm/llvm-project/pull/131230
+	def_bool $(cc-option,-fpatchable-function-entry=1$(comma)1$(comma).discard.patchable_function_entries)
+
+config RUSTC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION
+	# The section argument needs Rust 1.98.0 or later:
+	# https://github.com/rust-lang/rust/pull/157445
+	def_bool $(rustc-option,-Zpatchable-function-entry=1$(comma)1$(comma).discard.patchable_function_entries)
+
+config ARM64_CFI_PERMITS_CALL_OPS
+	def_bool y
+	depends on CFI
+	depends on CC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION
+	depends on !RUST || RUSTC_HAS_PATCHABLE_FUNCTION_ENTRY_SECTION
+
+config ARM64_FUNCTION_PREFIX_NOPS
+	int
+	default 5 if DYNAMIC_FTRACE_WITH_CALL_OPS && CFI && \
+		     (LTO_CLANG_THIN || LTO_CLANG_THIN_DIST) && ARM64_BTI_KERNEL
+	default 3 if DYNAMIC_FTRACE_WITH_CALL_OPS && CFI
+	default 2 if DYNAMIC_FTRACE_WITH_CALL_OPS
+	default 0
+
 config 64BIT
 	def_bool y
 
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 6b005c8fef706..b23430e2b8567 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -142,7 +142,20 @@ CHECKFLAGS	+= -D__aarch64__
 
 ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS),y)
   KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
-  CC_FLAGS_FTRACE := -fpatchable-function-entry=4,2
+  prefix_nops := $(CONFIG_ARM64_FUNCTION_PREFIX_NOPS)
+  CC_FLAGS_FTRACE := -fpatchable-function-entry=$(shell expr $(prefix_nops) + 2),$(prefix_nops)
+  ifeq ($(CONFIG_CFI),y)
+    # Every object gets the prefix NOPs and no ftrace entry by default.
+    # CC_FLAGS_FTRACE comes later for traced objects and overrides the
+    # -fpatchable-function-entry.
+    CFI_PREFIX_CFLAGS := -fpatchable-function-entry=$(prefix_nops),$(prefix_nops),.discard.patchable_function_entries \
+			 -DCC_USING_PATCHABLE_FUNCTION_PREFIX=$(prefix_nops)
+    KBUILD_CFLAGS += $(CFI_PREFIX_CFLAGS)
+    export CFI_PREFIX_CFLAGS
+    # Rust functions are not patched by ftrace, but they are called indirectly
+    # from C and make indirect calls themselves, so they need the same prefix.
+    KBUILD_RUSTFLAGS += -Zpatchable-function-entry=$(prefix_nops),$(prefix_nops),.discard.patchable_function_entries
+  endif
 else ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_ARGS),y)
   KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
   CC_FLAGS_FTRACE := -fpatchable-function-entry=2
diff --git a/arch/arm64/include/asm/cfi.h b/arch/arm64/include/asm/cfi.h
index ab90f0351b7ae..03f02d4614c23 100644
--- a/arch/arm64/include/asm/cfi.h
+++ b/arch/arm64/include/asm/cfi.h
@@ -4,4 +4,12 @@
 
 #define __bpfcall
 
+#ifdef CONFIG_CFI
+static inline int cfi_get_offset(void)
+{
+	return 4 + 4 * CONFIG_ARM64_FUNCTION_PREFIX_NOPS;
+}
+#define cfi_get_offset cfi_get_offset
+#endif /* CONFIG_CFI */
+
 #endif /* _ASM_ARM64_CFI_H */
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index 1621c84f44b32..5a7a515bf7cdc 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -24,6 +24,22 @@
 #define FTRACE_PLT_IDX		0
 #define NR_FTRACE_PLTS		1
 
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS
+/*
+ * ftrace_caller reads the callsite's ftrace_ops literal at
+ * ALIGN_DOWN(LR, 8) - FTRACE_CALL_OPS_BIAS. See ftrace_call_ops_adjust()
+ * for the layouts this serves.
+ */
+#define FTRACE_PREFIX_NOPS	CONFIG_ARM64_FUNCTION_PREFIX_NOPS
+#if FTRACE_PREFIX_NOPS == 2 || FTRACE_PREFIX_NOPS == 3
+#define FTRACE_CALL_OPS_BIAS	16
+#elif FTRACE_PREFIX_NOPS == 5
+#define FTRACE_CALL_OPS_BIAS	24
+#else
+#error "Unsupported number of function prefix NOPs"
+#endif
+#endif /* CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS */
+
 /*
  * Currently, gcc tends to save the link register after the local variables
  * on the stack. This causes the max stack tracer to report the function
diff --git a/arch/arm64/include/asm/linkage.h b/arch/arm64/include/asm/linkage.h
index d1f7a16729d25..14bc3c67c38b3 100644
--- a/arch/arm64/include/asm/linkage.h
+++ b/arch/arm64/include/asm/linkage.h
@@ -39,6 +39,17 @@
 	SYM_START(name, SYM_L_WEAK, SYM_A_NONE)		\
 	bti c ;
 
+/*
+ * The compiler emits CONFIG_ARM64_FUNCTION_PREFIX_NOPS NOPs between a C
+ * function's kCFI type hash and its entry point. Callers check the hash
+ * at that offset.
+ */
+#define __CFI_TYPE(name)				\
+	.4byte __kcfi_typeid_##name ASM_NL		\
+	.rept CONFIG_ARM64_FUNCTION_PREFIX_NOPS ASM_NL	\
+	nop ASM_NL					\
+	.endr
+
 #define SYM_TYPED_FUNC_START(name)				\
 	SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)	\
 	bti c ;
diff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S
index 025140caafe74..95727fee3cc55 100644
--- a/arch/arm64/kernel/entry-ftrace.S
+++ b/arch/arm64/kernel/entry-ftrace.S
@@ -39,17 +39,17 @@ SYM_CODE_START(ftrace_caller)
 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS
 	/*
 	 * The literal pointer to the ops is at an 8-byte aligned boundary
-	 * which is either 12 or 16 bytes before the BL instruction in the call
-	 * site. See ftrace_call_adjust() for details.
+	 * before the BL instruction in the call site. See ftrace_call_adjust()
+	 * and <asm/ftrace.h> for details.
 	 *
-	 * Therefore here the LR points at `literal + 16` or `literal + 20`,
-	 * and we can find the address of the literal in either case by
-	 * aligning to an 8-byte boundary and subtracting 16. We do the
-	 * alignment first as this allows us to fold the subtraction into the
-	 * LDR.
+	 * Therefore here the LR points at `literal + FTRACE_CALL_OPS_BIAS` or
+	 * `literal + FTRACE_CALL_OPS_BIAS + 4`, and we can find the address of
+	 * the literal in either case by aligning to an 8-byte boundary and
+	 * subtracting FTRACE_CALL_OPS_BIAS. We do the alignment first as this
+	 * allows us to fold the subtraction into the LDR.
 	 */
 	bic	x11, x30, 0x7
-	ldr	x11, [x11, #-(4 * AARCH64_INSN_SIZE)]		// op
+	ldr	x11, [x11, #-FTRACE_CALL_OPS_BIAS]		// op
 
 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
 	/*
diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
index e1a3c0b3a0514..0d922fa63f71b 100644
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -60,6 +60,73 @@ int ftrace_regs_query_register_offset(const char *name)
 }
 #endif
 
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS
+/*
+ * The address of the ops literal for a callsite whose `BL <caller>` is at
+ * @pc, exactly as ftrace_caller derives it from the return address.
+ */
+static unsigned long ftrace_call_ops_literal(unsigned long pc)
+{
+	return ALIGN_DOWN(pc + AARCH64_INSN_SIZE, 8) - FTRACE_CALL_OPS_BIAS;
+}
+
+/*
+ * addr is the first of the FTRACE_PREFIX_NOPS NOPs before a function:
+ *
+ * addr-04:		.word		// kCFI type hash, address-taken and non-local only
+ * addr+00:		NOP		// FTRACE_PREFIX_NOPS of these, two hold the literal
+ * func+00:	func:	BTI	C	// only if BTI and the function may be called indirectly
+ * func+04:		NOP		// patched to MOV X9, LR
+ * func+08:		NOP		// patched to BL <caller>
+ *
+ * The compiler aligns whatever comes first to 8 bytes. ftrace_caller reads
+ * the literal at ALIGN_DOWN(LR, 8) - FTRACE_CALL_OPS_BIAS, with LR at
+ * func+8, or func+12 after a BTI:
+ *
+ *	NOPs	BIAS	literal at
+ *	2	16	func - 8
+ *	3	16	func - 8, or func - 12 if func % 8 == 4 (no hash, no BTI)
+ *	5	24	func - 16, or func - 12 / func - 20 if func % 8 == 4
+ *
+ * Return the address of the NOP to be patched to BL, or 0 when the two
+ * NOPs are not there or the literal would fall outside the prefix.
+ */
+static unsigned long ftrace_call_ops_adjust(unsigned long addr)
+{
+	unsigned long func = addr + FTRACE_PREFIX_NOPS * AARCH64_INSN_SIZE;
+	unsigned long pc = func + AARCH64_INSN_SIZE;
+	unsigned long literal;
+	u32 nop = aarch64_insn_gen_nop();
+
+	if (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL) &&
+	    aarch64_insn_is_bti(le32_to_cpu(*(__le32 *)func)))
+		pc += AARCH64_INSN_SIZE;
+
+	/* Objects built with only the prefix NOPs have nothing to patch. */
+	if (le32_to_cpu(*(__le32 *)(pc - AARCH64_INSN_SIZE)) != nop ||
+	    le32_to_cpu(*(__le32 *)pc) != nop) {
+		pr_warn_ratelimited("ftrace: no patchable entry at %ps\n",
+				    (void *)func);
+		return 0;
+	}
+
+	/* The literal would overlap the type hash or the entry point. */
+	literal = ftrace_call_ops_literal(pc);
+	if (literal < addr || literal + sizeof(u64) > func) {
+		pr_warn_ratelimited("ftrace: cannot trace %ps: no room for the ops literal\n",
+				    (void *)func);
+		return 0;
+	}
+
+	return pc;
+}
+#else
+static unsigned long ftrace_call_ops_adjust(unsigned long addr)
+{
+	return 0;
+}
+#endif /* CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS */
+
 unsigned long ftrace_call_adjust(unsigned long addr)
 {
 	/*
@@ -91,56 +158,7 @@ unsigned long ftrace_call_adjust(unsigned long addr)
 	if (!IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))
 		return addr + AARCH64_INSN_SIZE;
 
-	/*
-	 * When using patchable-function-entry with pre-function NOPs, addr is
-	 * the address of the first pre-function NOP.
-	 *
-	 * Starting from an 8-byte aligned base, the compiler has either
-	 * generated:
-	 *
-	 * addr+00:		NOP		// Literal (first 32 bits)
-	 * addr+04:		NOP		// Literal (last 32 bits)
-	 * addr+08:	func:	NOP		// To be patched to MOV X9, LR
-	 * addr+12:		NOP		// To be patched to BL <caller>
-	 *
-	 * Or:
-	 *
-	 * addr+00:		NOP		// Literal (first 32 bits)
-	 * addr+04:		NOP		// Literal (last 32 bits)
-	 * addr+08:	func:	BTI	C
-	 * addr+12:		NOP		// To be patched to MOV X9, LR
-	 * addr+16:		NOP		// To be patched to BL <caller>
-	 *
-	 * We must adjust addr to the address of the NOP which will be patched
-	 * to `BL <caller>`, which is at either addr+12 or addr+16 depending on
-	 * whether there is a BTI.
-	 */
-
-	if (!IS_ALIGNED(addr, sizeof(unsigned long))) {
-		WARN_RATELIMIT(1, "Misaligned patch-site %pS\n",
-			       (void *)(addr + 8));
-		return 0;
-	}
-
-	/* Skip the NOPs placed before the function entry point */
-	addr += 2 * AARCH64_INSN_SIZE;
-
-	/* Skip any BTI */
-	if (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)) {
-		u32 insn = le32_to_cpu(*(__le32 *)addr);
-
-		if (aarch64_insn_is_bti(insn)) {
-			addr += AARCH64_INSN_SIZE;
-		} else if (insn != aarch64_insn_gen_nop()) {
-			WARN_RATELIMIT(1, "unexpected insn in patch-site %pS: 0x%08x\n",
-				       (void *)addr, insn);
-		}
-	}
-
-	/* Skip the first NOP after function entry */
-	addr += AARCH64_INSN_SIZE;
-
-	return addr;
+	return ftrace_call_ops_adjust(addr);
 }
 
 /* Convert fentry_ip to the symbol address without kallsyms */
@@ -368,7 +386,7 @@ static const struct ftrace_ops *arm64_rec_get_ops(struct dyn_ftrace *rec)
 static int ftrace_rec_set_ops(const struct dyn_ftrace *rec,
 			      const struct ftrace_ops *ops)
 {
-	unsigned long literal = ALIGN_DOWN(rec->ip - 12, 8);
+	unsigned long literal = ftrace_call_ops_literal(rec->ip);
 	return aarch64_insn_write_literal_u64((void *)literal,
 					      (unsigned long)ops);
 }
diff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile
index be92d73c25b21..df9f78dd9daec 100644
--- a/arch/arm64/kernel/pi/Makefile
+++ b/arch/arm64/kernel/pi/Makefile
@@ -18,6 +18,8 @@ CFLAGS_map_range.o += -mstrict-align
 KBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
 # disable LTO
 KBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
+# the discard section holds absolute relocations, which relacheck rejects
+KBUILD_CFLAGS	:= $(filter-out $(CFI_PREFIX_CFLAGS), $(KBUILD_CFLAGS))
 
 hostprogs	:= relacheck
 
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
index 7dec05dd33b70..44f4a6622ccd2 100644
--- a/arch/arm64/kernel/vdso/Makefile
+++ b/arch/arm64/kernel/vdso/Makefile
@@ -38,7 +38,7 @@ ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
 CC_FLAGS_REMOVE_VDSO := $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \
 			$(RANDSTRUCT_CFLAGS) $(KSTACK_ERASE_CFLAGS) \
 			$(GCC_PLUGINS_CFLAGS) \
-			$(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \
+			$(CC_FLAGS_LTO) $(CC_FLAGS_CFI) $(CFI_PREFIX_CFLAGS) \
 			-Wmissing-prototypes -Wmissing-declarations
 
 CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index c18e005a41dbe..7ad14d9847138 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -185,8 +185,12 @@ static inline void emit_bti(u32 insn, struct jit_ctx *ctx)
 
 static inline void emit_kcfi(u32 hash, struct jit_ctx *ctx)
 {
-	if (IS_ENABLED(CONFIG_CFI))
-		emit_u32_data(hash, ctx);
+	if (!IS_ENABLED(CONFIG_CFI))
+		return;
+
+	emit_u32_data(hash, ctx);
+	for (int i = 0; i < CONFIG_ARM64_FUNCTION_PREFIX_NOPS; i++)
+		emit(A64_NOP, ctx);
 }
 
 /*
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 77a2b2d74f3f6..9fb4e23da4535 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -53,7 +53,7 @@ KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS))
 # remove SCS flags from all objects in this directory
 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
 # disable CFI
-KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_CFI), $(KBUILD_CFLAGS))
+KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_CFI) $(CFI_PREFIX_CFLAGS), $(KBUILD_CFLAGS))
 # disable LTO
 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
 
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index c5921f1390079..43dafaa061942 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -211,6 +211,15 @@ struct ftrace_likely_data {
 
 #if defined(CC_USING_HOTPATCH)
 #define notrace			__attribute__((hotpatch(0, 0)))
+#elif defined(CC_USING_PATCHABLE_FUNCTION_PREFIX) && !defined(__BINDGEN__)
+/*
+ * Not for bindgen: its libclang may not support the section argument
+ * (Clang >= 21), and leaving the attribute out does not change the ABI.
+ */
+#define notrace								\
+	__attribute__((patchable_function_entry(CC_USING_PATCHABLE_FUNCTION_PREFIX, \
+						 CC_USING_PATCHABLE_FUNCTION_PREFIX, \
+						 ".discard.patchable_function_entries")))
 #elif defined(CC_USING_PATCHABLE_FUNCTION_ENTRY)
 #define notrace			__attribute__((patchable_function_entry(0, 0)))
 #else
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f9d80c7bd9f16..fa541d3e8784a 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -7676,6 +7676,11 @@ static int ftrace_process_locs(struct module *mod,
 		}
 
 		addr = ftrace_call_adjust(addr);
+		/* The architecture may return 0 to reject a patch site */
+		if (!addr) {
+			skipped++;
+			continue;
+		}
 
 		end_offset = (pg->index+1) * sizeof(pg->records[0]);
 		if (end_offset > PAGE_SIZE << pg->order) {
@@ -7689,6 +7694,20 @@ static int ftrace_process_locs(struct module *mod,
 		rec->ip = addr;
 	}
 
+	/*
+	 * ftrace_release_mod() finds a module's page groups by their first
+	 * record. If every entry was skipped there is none, so unlink the
+	 * new page groups and free them now.
+	 */
+	if (mod && !start_pg->index) {
+		ftrace_pages->next = NULL;
+		mutex_unlock(&ftrace_lock);
+		/* Need to synchronize with ftrace_location_range() */
+		synchronize_rcu();
+		ftrace_free_pages(start_pg);
+		return 0;
+	}
+
 	if (pg->next) {
 		pg_unuse = pg->next;
 		pg->next = NULL;
diff --git a/rust/Makefile b/rust/Makefile
index da1a7409d9845..b402ab768f729 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -511,7 +511,12 @@ endif
 # prototypes for functions like `memcpy` -- if this flag is not passed,
 # `bindgen`-generated prototypes use `c_ulong` or `c_uint` depending on
 # architecture instead of generating `usize`.
-bindgen_c_flags_final = $(bindgen_c_flags_lto) -fno-builtin -D__BINDGEN__
+#
+# Do not pass -fpatchable-function-entry to bindgen: its libclang may not
+# support the section argument (Clang >= 21), and removing the flag does not
+# change the ABI.
+bindgen_c_flags_final = $(filter-out -fpatchable-function-entry=%, \
+	$(bindgen_c_flags_lto)) -fno-builtin -D__BINDGEN__
 
 # `--rust-target` points to our minimum supported Rust version.
 quiet_cmd_bindgen = BINDGEN $@
diff --git a/scripts/Makefile b/scripts/Makefile
index 3434a82a119f0..daad9b9540b8d 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -51,6 +51,10 @@ endif
 
 ifdef CONFIG_BUILDTIME_MCOUNT_SORT
 HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
+# 0 or unset (no prefix NOPs) leaves sorttable's built-in default in place.
+ifneq ($(filter-out 0,$(CONFIG_ARM64_FUNCTION_PREFIX_NOPS)),)
+HOSTCFLAGS_sorttable.o += -DFUNCTION_PREFIX_BYTES=$(shell expr 4 \* $(CONFIG_ARM64_FUNCTION_PREFIX_NOPS))
+endif
 endif
 
 # The following programs are only built on demand
diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index d8dc2a1b7c312..925382bb23dcc 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -281,6 +281,11 @@ static int add_field(uint64_t addr, uint64_t size)
 /* Used for when mcount/fentry is before the function entry */
 static int before_func;
 
+/* How far before the function entry a patchable entry may be recorded */
+#ifndef FUNCTION_PREFIX_BYTES
+#define FUNCTION_PREFIX_BYTES	8
+#endif
+
 /* Only return match if the address lies inside the function size */
 static int cmp_func_addr(const void *K, const void *A)
 {
@@ -899,7 +904,7 @@ static int do_file(char const *const fname, void *addr)
 		/* fallthrough */
 	case EM_RISCV:
 		/* arm64 and RISC-V place patchable entries before the function. */
-		before_func = 8;
+		before_func = FUNCTION_PREFIX_BYTES;
 #else
 	case EM_AARCH64:
 	case EM_RISCV:

3/2 2026/09/27 03:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 10020
							output: 31
							thoughts: 927
						

Thoughts:
**Analyzing the Patch Series: A Deep Dive**

Okay, so the task at hand is to evaluate this patch series. My first step is always to verify the target architecture – ah, good, it's for `amd64`. Now, let's carefully dissect this diff.

The modified files listed initially grab my attention: a mix of `arm64` architecture-specific files, along with these more generic files: `kernel/trace/ftrace.c`, `include/linux/compiler_types.h`, and `scripts/sorttable.c`. That's an immediate red flag – or at least, a point of heightened interest. Why are these generic files touched alongside architecture-specific ones?

Let's dive into `include/linux/compiler_types.h`. The new code introduces `CC_USING_PATCHABLE_FUNCTION_PREFIX` which immediately jumps out at me. It seems related to "hotpatching" or patching of function entries, specifically targeting patchable function entry attributes, conditional on that definition. I'm noting the use of the `patchable_function_entry` attribute and a section named ".discard.patchable_function_entries." The key here is that it's *only* defined within `arch/arm64/Makefile`... and I know from my experience that it's never defined for amd64, meaning that this added definition will never be used.

Now, let's shift focus to `kernel/trace/ftrace.c`. I spot a conditional check within `ftrace_process_locs` that explicitly handles a zero return from `ftrace_call_adjust(addr)`. Intriguing! The code explicitly handles cases where the architecture might reject a patch site by returning zero. And it includes logic to handle the scenario where *every* entry is skipped! This could be a very significant change depending on where it may return zero. This smells like an architecture-specific detail, and I'm very curious to see if `ftrace_call_adjust(addr)` *can* return 0 on x86/amd64! I'll need to use `grepper` to hunt down the definition and implementation of `ftrace_call_adjust` on x86/amd64 and see if this new conditional branch is ever triggered.



4/2 2026/09/27 03:18 tool grepper
0m Args:
{
  "Expression": "ftrace_call_adjust",
  "PathPrefix": "arch/x86"
}

Results:
{
  "Output": "arch/x86/include/asm/ftrace.h=26=extern void __fentry__(void);\narch/x86/include/asm/ftrace.h-27-\narch/x86/include/asm/ftrace.h:28:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/x86/include/asm/ftrace.h-29-{\n"
}

5/2 2026/09/27 03:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 11579
							output: 41
							thoughts: 20
						

Thoughts:
Okay, let's dive into this. Here's my take on those initial thoughts:

**Peering into the x86 Ftrace Implementation**

Alright, time to get my hands dirty and dig into the heart of the x86 architecture's tracing capabilities. My focus today is on understanding the fundamental structures and definitions that drive `ftrace` on x86. The first logical step is to crack open `arch/x86/include/asm/ftrace.h`. I need to refresh my understanding of how the kernel hooks and manages function tracing at this level. I'm expecting to find key macros, data structures defining the trace record format and probably some platform-specific details related to instruction patching or the use of specific registers. The goal is to build a solid foundation and understand exactly how low-level tracing is implemented on x86.



6/2 2026/09/27 03:18 tool read-file
0m Args:
{
  "File": "arch/x86/include/asm/ftrace.h",
  "FirstLine": 25,
  "LineCount": 20
}

Results:
{
  "Contents": "  25:\t#ifndef __ASSEMBLER__\n  26:\textern void __fentry__(void);\n  27:\t\n  28:\tstatic inline unsigned long ftrace_call_adjust(unsigned long addr)\n  29:\t{\n  30:\t\t/*\n  31:\t\t * addr is the address of the mcount call instruction.\n  32:\t\t * recordmcount does the necessary offset calculation.\n  33:\t\t */\n  34:\t\treturn addr;\n  35:\t}\n  36:\t\n  37:\tstatic inline unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)\n  38:\t{\n  39:\t\tif (is_endbr((void*)(fentry_ip - ENDBR_INSN_SIZE)))\n  40:\t\t\tfentry_ip -= ENDBR_INSN_SIZE;\n  41:\t\n  42:\t\treturn fentry_ip;\n  43:\t}\n  44:\t#define ftrace_get_symaddr(fentry_ip)\tarch_ftrace_get_symaddr(fentry_ip)\n"
}

7/2 2026/09/27 03:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 12108
							output: 37
							thoughts: 92
						

Thoughts:
Here's my analysis of this code snippet:

**Considering the Ftrace Call Adjustment**

Okay, so I'm looking at this seemingly straightforward inline function, `ftrace_call_adjust`, specifically for x86/amd64. Right now, it just returns the address it's given – `addr`. That's... simple. But my mind immediately jumps to the edge cases. Is it possible for `addr` to be zero when passed into `ftrace_call_adjust`? That would be interesting, and could indicate some problem with the initial address calculation. To figure this out, I really need to understand where `ftrace_call_adjust` is *used*. I'll need to dig into the call sites. Let's start by looking at `ftrace_process_locs` in `kernel/trace/ftrace.c`. That seems like a good place to start my investigation. I'll need to trace the flow of execution from there to understand if `addr` is potentially zero at that point in the code.



8/2 2026/09/27 03:18 tool read-file
0m Args:
{
  "File": "kernel/trace/ftrace.c",
  "FirstLine": 7660,
  "LineCount": 50
}

Results:
{
  "Contents": "7660:\t\t\t * Skip any NULL pointers.\n7661:\t\t\t */\n7662:\t\t\tif (!addr) {\n7663:\t\t\t\tskipped++;\n7664:\t\t\t\tcontinue;\n7665:\t\t\t}\n7666:\t\n7667:\t\t\t/*\n7668:\t\t\t * If this is core kernel, make sure the address is in core\n7669:\t\t\t * or inittext, as weak functions get zeroed and KASLR can\n7670:\t\t\t * move them to something other than zero. It just will not\n7671:\t\t\t * move it to an area where kernel text is.\n7672:\t\t\t */\n7673:\t\t\tif (!mod \u0026\u0026 !(is_kernel_text(addr) || is_kernel_inittext(addr))) {\n7674:\t\t\t\tskipped++;\n7675:\t\t\t\tcontinue;\n7676:\t\t\t}\n7677:\t\n7678:\t\t\taddr = ftrace_call_adjust(addr);\n7679:\t\t\t/* The architecture may return 0 to reject a patch site */\n7680:\t\t\tif (!addr) {\n7681:\t\t\t\tskipped++;\n7682:\t\t\t\tcontinue;\n7683:\t\t\t}\n7684:\t\n7685:\t\t\tend_offset = (pg-\u003eindex+1) * sizeof(pg-\u003erecords[0]);\n7686:\t\t\tif (end_offset \u003e PAGE_SIZE \u003c\u003c pg-\u003eorder) {\n7687:\t\t\t\t/* We should have allocated enough */\n7688:\t\t\t\tif (WARN_ON(!pg-\u003enext))\n7689:\t\t\t\t\tbreak;\n7690:\t\t\t\tpg = pg-\u003enext;\n7691:\t\t\t}\n7692:\t\n7693:\t\t\trec = \u0026pg-\u003erecords[pg-\u003eindex++];\n7694:\t\t\trec-\u003eip = addr;\n7695:\t\t}\n7696:\t\n7697:\t\t/*\n7698:\t\t * ftrace_release_mod() finds a module's page groups by their first\n7699:\t\t * record. If every entry was skipped there is none, so unlink the\n7700:\t\t * new page groups and free them now.\n7701:\t\t */\n7702:\t\tif (mod \u0026\u0026 !start_pg-\u003eindex) {\n7703:\t\t\tftrace_pages-\u003enext = NULL;\n7704:\t\t\tmutex_unlock(\u0026ftrace_lock);\n7705:\t\t\t/* Need to synchronize with ftrace_location_range() */\n7706:\t\t\tsynchronize_rcu();\n7707:\t\t\tftrace_free_pages(start_pg);\n7708:\t\t\treturn 0;\n7709:\t\t}\n"
}

9/2 2026/09/27 03:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 13147
							output: 31
							thoughts: 230
						

Thoughts:
**Analyzing Potential Redundancy in Ftrace Code**

Okay, so I'm looking closely at this code snippet, specifically lines 7660-7665. My first reaction is, "Hold on, if `addr` is zero, hasn't it *already* been skipped before we even get to that `if` statement? Because `addr = ftrace_call_adjust(addr);` seems to be the first line that could actually change the state of `addr`." The comment explicitly says we are skipping NULL pointers, which reinforces this suspicion.

And, if we're on x86, isn't `ftrace_call_adjust(addr)` just a no-op? It simply returns `addr` as-is. Therefore, if `addr` is non-zero (after that assignment), then `ftrace_call_adjust(addr)` must *also* be non-zero on x86, right?

But then I start thinking...wait, could the condition `mod && !start_pg->index` *ever* actually be true on x86? Is there a possible scenario where this logic would be hit? And more specifically, what happens if every entry *was* null?

Could a module *actually* have zero valid ftrace locations, or all of them be NULL on x86? Is this code path even reachable in a real-world scenario, or is it a vestige of some earlier architectural consideration?

The more I look at this logic, the more I'm questioning why `ftrace_process_locs` is even *being* called in this case. I need to understand its context. I should probably trace the callers of `ftrace_process_locs` to get a better handle on the bigger picture.



10/2 2026/09/27 03:18 tool grepper
0m Args:
{
  "Expression": "ftrace_process_locs",
  "PathPrefix": "kernel/trace/"
}

Results:
{
  "Output": "kernel/trace/ftrace.c=7583=static void test_is_sorted(unsigned long *start, unsigned long count)\n--\nkernel/trace/ftrace.c-7587-\nkernel/trace/ftrace.c:7588:static int ftrace_process_locs(struct module *mod,\nkernel/trace/ftrace.c-7589-\t\t\t       unsigned long *start,\n--\nkernel/trace/ftrace.c=8086=void ftrace_module_init(struct module *mod)\n--\nkernel/trace/ftrace.c-8092-\nkernel/trace/ftrace.c:8093:\tret = ftrace_process_locs(mod, mod-\u003eftrace_callsites,\nkernel/trace/ftrace.c-8094-\t\t\t\t  mod-\u003eftrace_callsites + mod-\u003enum_ftrace_callsites);\n--\nkernel/trace/ftrace.c=8415=void __init ftrace_init(void)\n--\nkernel/trace/ftrace.c-8433-\nkernel/trace/ftrace.c:8434:\tret = ftrace_process_locs(NULL,\nkernel/trace/ftrace.c-8435-\t\t\t\t  __start_mcount_loc,\n"
}

11/2 2026/09/27 03:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 14116
							output: 37
							thoughts: 12
						

Thoughts:
Okay, let's dive into this. Here's my thought process on this specific topic, aimed at a fellow expert:

**Investigating `ftrace_module_init`**

Alright, let's take a look at `ftrace_module_init`. Seems like a critical entry point for any ftrace module. My immediate thought is, "What specifically does this do?" Given my experience, I know this is likely where the ftrace infrastructure is initialized for a particular module – registration of tracers, allocation of data structures, perhaps setting up per-cpu buffers or enabling various options specific to that module's functionality. I need to understand the control flow here, because knowing the initialization sequence is vital for debugging or adding modifications to the kernel. Where exactly does the call lead to? It would be interesting to confirm which global variables and data structures this function accesses and modifies, the goal being to determine the potential of adding user defined ftrace events.



12/2 2026/09/27 03:18 tool read-file
0m Args:
{
  "File": "kernel/trace/ftrace.c",
  "FirstLine": 8080,
  "LineCount": 40
}

Results:
{
  "Contents": "8080:\t out_unlock:\n8081:\t\tmutex_unlock(\u0026ftrace_lock);\n8082:\t\n8083:\t\tprocess_cached_mods(mod-\u003ename);\n8084:\t}\n8085:\t\n8086:\tvoid ftrace_module_init(struct module *mod)\n8087:\t{\n8088:\t\tint ret;\n8089:\t\n8090:\t\tif (ftrace_disabled || !mod-\u003enum_ftrace_callsites)\n8091:\t\t\treturn;\n8092:\t\n8093:\t\tret = ftrace_process_locs(mod, mod-\u003eftrace_callsites,\n8094:\t\t\t\t\t  mod-\u003eftrace_callsites + mod-\u003enum_ftrace_callsites);\n8095:\t\tif (ret)\n8096:\t\t\tpr_warn(\"ftrace: failed to allocate entries for module '%s' functions\\n\",\n8097:\t\t\t\tmod-\u003ename);\n8098:\t}\n8099:\t\n8100:\tstatic void save_ftrace_mod_rec(struct ftrace_mod_map *mod_map,\n8101:\t\t\t\t\tstruct dyn_ftrace *rec)\n8102:\t{\n8103:\t\tstruct ftrace_mod_func *mod_func;\n8104:\t\tunsigned long symsize;\n8105:\t\tunsigned long offset;\n8106:\t\tchar str[KSYM_SYMBOL_LEN];\n8107:\t\tchar *modname;\n8108:\t\tconst char *ret;\n8109:\t\n8110:\t\tret = kallsyms_lookup(rec-\u003eip, \u0026symsize, \u0026offset, \u0026modname, str);\n8111:\t\tif (!ret)\n8112:\t\t\treturn;\n8113:\t\n8114:\t\tmod_func = kmalloc_obj(*mod_func);\n8115:\t\tif (!mod_func)\n8116:\t\t\treturn;\n8117:\t\n8118:\t\tmod_func-\u003ename = kstrdup(str, GFP_KERNEL);\n8119:\t\tif (!mod_func-\u003ename) {\n"
}

13/2 2026/09/27 03:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 14934
							output: 37
							thoughts: 2461
						

Thoughts:
**Ftrace Investigation - WorthFuzzing Analysis**

Okay, let's break this down. I'm looking at `ftrace_module_init`. The check `if (ftrace_disabled || !mod->num_ftrace_callsites) return;` is pretty straightforward. It bails out if ftrace is disabled or if the module doesn't have any ftrace callsites. My focus is on the `num_ftrace_callsites > 0` case. That means the compiler has generated `mcount`/`fentry` callsites, which should be valid addresses, right? On x86, they *shouldn't* be NULL or zero unless something is seriously broken, so why even have that check? Time to check the commit log for that code.

Can I get the git log with a grepper? No, but I can look for the commit message or carefully review the diff. Let's look at the diff again... aha! It involves `arm64/Kconfig` and enables `DYNAMIC_FTRACE_WITH_CALL_OPS` with `CFI` under specific circumstances. This is what the commit is doing! This is about enabling `DYNAMIC_FTRACE_WITH_CALL_OPS` with `CFI` on arm64! On arm64, it looks like, when this is enabled, there's NOP padding needed before functions. KCFIs are involved, type hashes before functions, and `.discard.patchable_function_entries`.

Now, the rabbit hole begins. I see changes in `kernel/trace/ftrace.c`. specifically with `ftrace_process_locs`, which contains the following:

```c
		addr = ftrace_call_adjust(addr);
		/* The architecture may return 0 to reject a patch site */
		if (!addr) {
			skipped++;
			continue;
		}
```

And:

```c
	/*
	 * ftrace_release_mod() finds a module's page groups by their first
	 * record. If every entry was skipped there is none, so unlink the
	 * new page groups and free them now.
	 */
	if (mod && !start_pg->index) {
		ftrace_pages->next = NULL;
		mutex_unlock(&ftrace_lock);
		/* Need to synchronize with ftrace_location_range() */
		synchronize_rcu();
		ftrace_free_pages(start_pg);
		return 0;
	}
```

Wait, this `ftrace_call_adjust` sounds a bit like it could cause problems, and `start_pg->index` is 0, which also could cause a problem. Then I see a specific implementation for `ftrace_call_ops_adjust` for arm64.

Okay, let's be sure about this - the target architecture is amd64. Therefore, it is important to follow the rules outlined in section 2 in the documentation. One of the rules includes:
"Code paths exclusive to architectures other than the target architecture."

Is the modified code in `kernel/trace/ftrace.c` exclusive to architectures other than amd64?
I see that `kernel/trace/ftrace.c` *is* compiled on amd64 when `CONFIG_FUNCTION_TRACER` is enabled. But the question is, is the *modified* code path reachable on amd64?

Okay, let's analyze the relevant code:
... *copy of code from above*...

Can `addr` ever be zero on amd64? Let's check `ftrace_call_adjust`:
`static inline unsigned long ftrace_call_adjust(unsigned long addr) { return addr; }`
`ftrace_call_adjust` just returns the same address. Thus, if the address is non-zero, then after the return from `ftrace_call_adjust` the address is non-zero. The line `if (!addr)` will never be true on amd64! This seems to be unreachable on amd64! And what about `if (mod && !start_pg->index)`? Could this ever happen? When is `ftrace_process_locs` called? `ftrace_module_init`!

Wait, what if every callsite is NULL? Could that even happen?
Okay, `mod->ftrace_callsites` contains addresses from `__mcount_loc`. These are basically references in the ELF files. Could they be null?
Oh wait! The original lines of code already check this:
```c
			/*
			 * Skip any NULL pointers.
			 */
			if (!addr) {
				skipped++;


14/2 2026/09/27 03:19 tool read-file
0m Args:
{
  "File": "kernel/trace/ftrace.c",
  "FirstLine": 7640,
  "LineCount": 45
}

Results:
{
  "Contents": "7640:\t\t\tif (WARN_ON(ftrace_pages-\u003enext)) {\n7641:\t\t\t\t/* Hmm, we have free pages? */\n7642:\t\t\t\twhile (ftrace_pages-\u003enext)\n7643:\t\t\t\t\tftrace_pages = ftrace_pages-\u003enext;\n7644:\t\t\t}\n7645:\t\n7646:\t\t\tftrace_pages-\u003enext = start_pg;\n7647:\t\t}\n7648:\t\n7649:\t\tp = start;\n7650:\t\tpg = start_pg;\n7651:\t\twhile (p \u003c end) {\n7652:\t\t\tunsigned long end_offset;\n7653:\t\n7654:\t\t\taddr = *p++;\n7655:\t\n7656:\t\t\t/*\n7657:\t\t\t * Some architecture linkers will pad between\n7658:\t\t\t * the different mcount_loc sections of different\n7659:\t\t\t * object files to satisfy alignments.\n7660:\t\t\t * Skip any NULL pointers.\n7661:\t\t\t */\n7662:\t\t\tif (!addr) {\n7663:\t\t\t\tskipped++;\n7664:\t\t\t\tcontinue;\n7665:\t\t\t}\n7666:\t\n7667:\t\t\t/*\n7668:\t\t\t * If this is core kernel, make sure the address is in core\n7669:\t\t\t * or inittext, as weak functions get zeroed and KASLR can\n7670:\t\t\t * move them to something other than zero. It just will not\n7671:\t\t\t * move it to an area where kernel text is.\n7672:\t\t\t */\n7673:\t\t\tif (!mod \u0026\u0026 !(is_kernel_text(addr) || is_kernel_inittext(addr))) {\n7674:\t\t\t\tskipped++;\n7675:\t\t\t\tcontinue;\n7676:\t\t\t}\n7677:\t\n7678:\t\t\taddr = ftrace_call_adjust(addr);\n7679:\t\t\t/* The architecture may return 0 to reject a patch site */\n7680:\t\t\tif (!addr) {\n7681:\t\t\t\tskipped++;\n7682:\t\t\t\tcontinue;\n7683:\t\t\t}\n7684:\t\n"
}

15/2 2026/09/27 03:19 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 19032
							output: 21
							thoughts: 568
						

Thoughts:
**My Analysis of the Ftrace Patch**

Okay, so I'm looking at this patch and immediately, my mind jumps to alignment issues with linkers and those `mcount_loc` sections. But wait, it's skipping NULL pointers? That seems odd. Could an entire module *only* consist of null pointers? No, that's absurd. Modules are made of functions. Why would a module just have padding? Doesn't make sense.

I need to back up. What's the *point* of this patch? Let's refresh my memory. The commit message...right, it mentions the architecture returning 0 to reject a patch site. And then `ftrace_release_mod()` is involved, which finds the module's page groups using the first record. So, it's about what happens if all the entries are skipped. If they're all skipped, then there is no first entry, so we need to unlink and free the page groups.

But *why* would all the entries be skipped? Let's dig deeper. Ah, I see! This `arch/arm64/ftrace.c` file is key. It's checking for a prefix of NOPs. It's looking for the typical function entry stub. Specifically, it's checking:

```c
	/* Objects built with only the prefix NOPs have nothing to patch. */
	if (le32_to_cpu(*(__le32 *)(pc - AARCH64_INSN_SIZE)) != nop ||
	    le32_to_cpu(*(__le32 *)pc) != nop) {
		pr_warn_ratelimited("ftrace: no patchable entry at %ps\n",
				    (void *)func);
		return 0;
	}
```

Okay, so the `arm64/Makefile` is setting it up. This ties it together. If CFI is enabled, all objects get a prefix of NOPs. This is even for Rust functions or untraced modules. It's using `-fpatchable-function-entry`. The Rust compiler is even using a similar flag. If no patchable entries are defined in the module, it's all NOPs, so we skip it.

So, in the case of ARM64, and likely other architectures which define `ftrace_call_adjust`, a module with NOPs is not patched by ftrace. Thus, `ftrace_release_mod()` will be passed a module with skipped entries.

Now, to solidify my understanding, I need to understand where `ftrace_call_adjust` is defined, to see what other architectures it applies to.



16/2 2026/09/27 03:19 tool grepper
0m Args:
{
  "Expression": "ftrace_call_adjust\\("
}

Results:
{
  "Output": "Documentation/trace/ftrace-design.rst=251=Once those are out of the way, you will need to implement:\n--\nDocumentation/trace/ftrace-design.rst-253-\t\t- MCOUNT_ADDR\nDocumentation/trace/ftrace-design.rst:254:\t\t- ftrace_call_adjust()\nDocumentation/trace/ftrace-design.rst-255-\t\t- struct dyn_arch_ftrace{}\n--\nDocumentation/trace/ftrace-design.rst=273=Since no one else will have a decl for that function, you will need to::\n--\nDocumentation/trace/ftrace-design.rst-276-\nDocumentation/trace/ftrace-design.rst:277:You will also need the helper function ftrace_call_adjust().  Most people\nDocumentation/trace/ftrace-design.rst-278-will be able to stub it out like so::\nDocumentation/trace/ftrace-design.rst-279-\nDocumentation/trace/ftrace-design.rst:280:\tstatic inline unsigned long ftrace_call_adjust(unsigned long addr)\nDocumentation/trace/ftrace-design.rst-281-\t{\n--\narch/arm/include/asm/ftrace.h=19=struct dyn_arch_ftrace {\n--\narch/arm/include/asm/ftrace.h-24-\narch/arm/include/asm/ftrace.h:25:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/arm/include/asm/ftrace.h-26-{\n--\narch/arm64/include/asm/ftrace.h=68=extern void return_to_handler(void);\narch/arm64/include/asm/ftrace.h-69-\narch/arm64/include/asm/ftrace.h:70:unsigned long ftrace_call_adjust(unsigned long addr);\narch/arm64/include/asm/ftrace.h-71-unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip);\n--\narch/arm64/kernel/entry-ftrace.S=36=SYM_CODE_START(ftrace_caller)\n--\narch/arm64/kernel/entry-ftrace.S-41-\t * The literal pointer to the ops is at an 8-byte aligned boundary\narch/arm64/kernel/entry-ftrace.S:42:\t * before the BL instruction in the call site. See ftrace_call_adjust()\narch/arm64/kernel/entry-ftrace.S-43-\t * and \u003casm/ftrace.h\u003e for details.\n--\narch/arm64/kernel/ftrace.c=124=static unsigned long ftrace_call_ops_adjust(unsigned long addr)\n--\narch/arm64/kernel/ftrace.c-129-\narch/arm64/kernel/ftrace.c:130:unsigned long ftrace_call_adjust(unsigned long addr)\narch/arm64/kernel/ftrace.c-131-{\n--\narch/csky/include/asm/ftrace.h=18=extern void ftrace_graph_call(void);\narch/csky/include/asm/ftrace.h-19-\narch/csky/include/asm/ftrace.h:20:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/csky/include/asm/ftrace.h-21-{\n--\narch/loongarch/include/asm/ftrace.h=33=int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);\narch/loongarch/include/asm/ftrace.h-34-\narch/loongarch/include/asm/ftrace.h:35:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/loongarch/include/asm/ftrace.h-36-{\n--\narch/microblaze/include/asm/ftrace.h=13=void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr);\n--\narch/microblaze/include/asm/ftrace.h-17-/* relocation of mcount call site is the same as the address */\narch/microblaze/include/asm/ftrace.h:18:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/microblaze/include/asm/ftrace.h-19-{\n--\narch/mips/include/asm/ftrace.h=45=do {\t\t\t\t\t\t\\\n--\narch/mips/include/asm/ftrace.h-78-#ifdef CONFIG_DYNAMIC_FTRACE\narch/mips/include/asm/ftrace.h:79:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/mips/include/asm/ftrace.h-80-{\n--\narch/parisc/include/asm/ftrace.h=23=struct dyn_arch_ftrace {\n--\narch/parisc/include/asm/ftrace.h-25-\narch/parisc/include/asm/ftrace.h:26:unsigned long ftrace_call_adjust(unsigned long addr);\narch/parisc/include/asm/ftrace.h-27-\n--\narch/parisc/kernel/ftrace.c=102=int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,\n--\narch/parisc/kernel/ftrace.c-107-\narch/parisc/kernel/ftrace.c:108:unsigned long ftrace_call_adjust(unsigned long addr)\narch/parisc/kernel/ftrace.c-109-{\n--\narch/powerpc/include/asm/ftrace.h=156=void ftrace_free_init_tramp(void);\narch/powerpc/include/asm/ftrace.h:157:unsigned long ftrace_call_adjust(unsigned long addr);\narch/powerpc/include/asm/ftrace.h-158-\n--\narch/powerpc/include/asm/ftrace.h=175=static inline void ftrace_free_init_tramp(void) { }\narch/powerpc/include/asm/ftrace.h:176:static inline unsigned long ftrace_call_adjust(unsigned long addr) { return addr; }\narch/powerpc/include/asm/ftrace.h-177-#endif\n--\narch/powerpc/kernel/trace/ftrace.c=33=static unsigned long ftrace_tramps[NUM_FTRACE_TRAMPS];\narch/powerpc/kernel/trace/ftrace.c-34-\narch/powerpc/kernel/trace/ftrace.c:35:unsigned long ftrace_call_adjust(unsigned long addr)\narch/powerpc/kernel/trace/ftrace.c-36-{\n--\narch/powerpc/kernel/trace/ftrace_64_pg.c=38=static unsigned long ftrace_tramps[NUM_FTRACE_TRAMPS];\narch/powerpc/kernel/trace/ftrace_64_pg.c-39-\narch/powerpc/kernel/trace/ftrace_64_pg.c:40:unsigned long ftrace_call_adjust(unsigned long addr)\narch/powerpc/kernel/trace/ftrace_64_pg.c-41-{\n--\narch/riscv/include/asm/ftrace.h=22=void _mcount(void);\narch/riscv/include/asm/ftrace.h:23:unsigned long ftrace_call_adjust(unsigned long addr);\narch/riscv/include/asm/ftrace.h-24-unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip);\n--\narch/riscv/kernel/ftrace.c=24=void ftrace_arch_code_modify_post_process(void)\n--\narch/riscv/kernel/ftrace.c-29-\narch/riscv/kernel/ftrace.c:30:unsigned long ftrace_call_adjust(unsigned long addr)\narch/riscv/kernel/ftrace.c-31-{\n--\narch/riscv/kernel/ftrace.c=181=int ftrace_update_ftrace_func(ftrace_func_t func)\n--\narch/riscv/kernel/ftrace.c-207-#else /* CONFIG_DYNAMIC_FTRACE */\narch/riscv/kernel/ftrace.c:208:unsigned long ftrace_call_adjust(unsigned long addr)\narch/riscv/kernel/ftrace.c-209-{\n--\narch/s390/include/asm/ftrace.h=47=int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);\n--\narch/s390/include/asm/ftrace.h-49-\narch/s390/include/asm/ftrace.h:50:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/s390/include/asm/ftrace.h-51-{\n--\narch/sh/include/asm/ftrace.h=24=struct dyn_arch_ftrace {\n--\narch/sh/include/asm/ftrace.h-29-\narch/sh/include/asm/ftrace.h:30:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/sh/include/asm/ftrace.h-31-{\n--\narch/sparc/include/asm/ftrace.h=10=void _mcount(void);\n--\narch/sparc/include/asm/ftrace.h-20-/* relocation of mcount call site is the same as the address */\narch/sparc/include/asm/ftrace.h:21:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/sparc/include/asm/ftrace.h-22-{\n--\narch/x86/include/asm/ftrace.h=26=extern void __fentry__(void);\narch/x86/include/asm/ftrace.h-27-\narch/x86/include/asm/ftrace.h:28:static inline unsigned long ftrace_call_adjust(unsigned long addr)\narch/x86/include/asm/ftrace.h-29-{\n--\nkernel/trace/ftrace.c=7588=static int ftrace_process_locs(struct module *mod,\n--\nkernel/trace/ftrace.c-7677-\nkernel/trace/ftrace.c:7678:\t\taddr = ftrace_call_adjust(addr);\nkernel/trace/ftrace.c-7679-\t\t/* The architecture may return 0 to reject a patch site */\n"
}

17/2 2026/09/27 03:19 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 22854
							output: 195
							thoughts: 6195
						

Thoughts:
**Analysis of the Patch for Fuzzing Eligibility**

Okay, here's the breakdown. I've gone through this diff meticulously. My initial instinct was to check every single file, because anytime you see changes touching ftrace, you have to be cautious. However, after careful inspection, it's clear this patch series, while extensive in the number of files modified, is *highly* targeted.

First, I examined all the ARM64-specific files. These are obviously irrelevant to fuzzing AMD64. The Kconfig, Makefiles, include files and the kernel code (`arch/arm64/*`) are all architecture-specific and won't touch the AMD64 code base.

Then came the build system and host tool changes. `drivers/firmware/efi/libstub/Makefile`, `rust/Makefile`, `scripts/Makefile`, and `scripts/sorttable.c` change build configuration and scripts. These are important for *building* the kernel, but don't introduce new execution paths *within* the AMD64 kernel.

The `include/linux/compiler_types.h` change introduces a `notrace` attribute using `CC_USING_PATCHABLE_FUNCTION_PREFIX`.  That macro is only defined for ARM64 builds, making that change also AMD64-irrelevant.

Finally, I got to the `kernel/trace/ftrace.c` changes. I was a bit worried here. Any change to core kernel tracing is potentially interesting. The new code in there includes a check for `ftrace_call_adjust` returning 0. So, I looked at the call to `ftrace_call_adjust` carefully. On x86, this is an inline function that *always* returns the original address. The conditional logic is unreachable in AMD64 and can even be removed.

Furthermore, I have verified the case of every entry being rejected (all NULLs). In x86, and for that matter, other architectures, this condition is handled by the pre-existing logic that skips NULL addresses.

Therefore, because this patch series introduces code paths exclusive to ARM64 and build-system configuration, this specific patch series does *not* warrant fuzzing on AMD64. The target architecture is AMD64, and none of the code is reachable from it.



18/2 2026/09/27 03:19 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch series adds support for dynamic ftrace with call ops when Clang kCFI is enabled on ARM64. All functional kernel changes are either in ARM64-specific files (arch/arm64/), guarded by ARM64-only macros (CC_USING_PATCHABLE_FUNCTION_PREFIX in compiler_types.h), or in build system scripts (scripts/, rust/). The only generic C change in kernel/trace/ftrace.c handles cases where ftrace_call_adjust() returns 0 to reject patch sites; on amd64, ftrace_call_adjust(addr) unconditionally returns addr (which is already checked non-NULL immediately prior), making the new branch unreachable on the target architecture. Therefore, no reachable executable code is modified for amd64.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series adds support for dynamic ftrace with call ops when Clang kCFI is enabled on ARM64. All functional kernel changes are either in ARM64-specific files (arch/arm64/), guarded by ARM64-only macros (CC_USING_PATCHABLE_FUNCTION_PREFIX in compiler_types.h), or in build system scripts (scripts/, rust/). The only generic C change in kernel/trace/ftrace.c handles cases where ftrace_call_adjust() returns 0 to reject patch sites; on amd64, ftrace_call_adjust(addr) unconditionally returns addr (which is already checked non-NULL immediately prior), making the new branch unreachable on the target architecture. Therefore, no reachable executable code is modified for amd64.",
  "WorthFuzzing": false
}

19/1 2026/09/27 03:19 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)