[PATCH] fgraph: Do not mark index 0 in every shadow stack frame

From
Breno Leitao <leitao@debian.org>
Date
2026-11-12 15:19:47
Also in
lkml
We are seeing this warning on an arm64 host:

  WARNING: kernel/trace/fprobe.c:676 at fprobe_return+0x260/0x2c8, CPU#16: FuncSched/3281330
  Call trace:
   fprobe_return+0x260/0x2c8 (P)
   ftrace_return_to_handler+0x2bc/0x5a8
   return_to_handler+0x20/0x48
   futex_wait+0xa4/0x218
   do_futex+0xb4/0x1d0
   __arm64_sys_futex+0x15c/0x278

The theory is that function_graph_enter_regs() sets BIT(0) in the bitmap
of every frame, a leftover of an old tail-call check, while the return
path calls the retfunc of every set bit.

A reproducer on linux-next supports the theory. On a fresh boot, with no
other fgraph user yet:

  cd /sys/kernel/tracing
  echo 'f:fpexit vfs_read%return' >> dynamic_events
  echo 1 > events/fprobes/fpexit/enable	# fprobe_graph_ops: index 0
  echo vfs_write > set_ftrace_filter
  echo function_graph > current_tracer	# function_graph: index 1
  echo x > /dev/null			# WARN on vfs_write return

Removing the bit was agreed in the review of the series that added it
[0], but the line stayed. Drop it now.

Link: https://lore.kernel.org/all/20240527093436.7060d358a64cc2ea3213b07b@kernel.org/ (local) [0]
Fixes: 7aa1eaef9f42 ("function_graph: Allow multiple users to attach to function graph")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 kernel/trace/fgraph.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index 6d87143b3ddb5f..a674874e6a05a6 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -700,11 +700,7 @@ int function_graph_enter_regs(unsigned long ret, unsigned long func,
 	if (!bitmap)
 		goto out_ret;
 
-	/*
-	 * Since this function uses fgraph_idx = 0 as a tail-call checking
-	 * flag, set that bit always.
-	 */
-	set_bitmap(current, offset, bitmap | BIT(0));
+	set_bitmap(current, offset, bitmap);
 	ftrace_test_recursion_unlock(bit);
 	return 0;
  out_ret:
---
base-commit: aaa2f954c21b205a0bcd0961e5b2be4e82e58455
change-id: 20261112-fgraph-bit0-cf3c487ef99c

Best regards,
--  
Breno Leitao [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help