Linux NFS development
 help / color / mirror / Atom feed
* [PATCH bpf v2 1/3] bpf: Replace DECLARE_EVENT_CLASS names in raw_tp_null_args[]
@ 2026-11-19  7:18 Yingke Xiao
  2026-11-19 20:05 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Yingke Xiao @ 2026-11-19  7:18 UTC (permalink / raw)
  To: bpf
  Cc: Trond Myklebust, anna, linux-nfs, steffen.klassert, herbert, ast,
	daniel, andrii, stable

btf_ctx_access() strips the "btf_trace_" prefix from attach_btf_id
and matches tname with strcmp(tname, raw_tp_null_args[i].func). Because
each attachable tracepoint typedef corresponds to a DEFINE_EVENT() name
rather than its DECLARE_EVENT_CLASS() template, three existing entries
in raw_tp_null_args[] never match any program:

  1. "nfs4_inode_callback_event" and "nfs4_inode_stateid_callback_event"
     are DECLARE_EVENT_CLASS templates in fs/nfs/nfs4trace.h whose
     DEFINE_EVENT instances are nfs4_cb_getattr (:1455) and
     nfs4_cb_recall (:1518). fs/nfs/callback_proc.c:50,106 pass literal
     NULL for arg 2 (const struct inode *inode), and TP_fast_assign
     (:1424, :1481) checks !IS_ERR_OR_NULL(inode). Keeping 0x200
     (0x2ULL << (2 * 4)) sets ptr_err_raw_tp = true so btf_ctx_access()
     assigns SCALAR_VALUE to ctx[2], rejecting any pointer dereference
     even under if (inode) and matching existing raw_tp_null_args[]
     0x2-nibble convention (0x300 yields the identical SCALAR_VALUE).

  2. "iptfs_ingress_postq_event" is the DECLARE_EVENT_CLASS template in
     net/xfrm/trace_iptfs.h:108 whose DEFINE_EVENT instances (:130-148)
     are iptfs_first_dequeue, iptfs_first_fragmenting,
     iptfs_first_final_fragment, and iptfs_first_toobig.
     net/xfrm/xfrm_iptfs.c:2025 and :2051 pass literal NULL for arg 3
     (struct iphdr *iph), requiring mask 0x1000 (PTR_MAYBE_NULL).

Replace these dead template names with their DEFINE_EVENT tracepoints.
Verified in QEMU on x86_64 7.4.0-rc3 (iptfs_first_{fragmenting,
final_fragment} and nfs4_cb_{getattr,recall} flip from LOADED to
REJECTED) and 6.12.118 (nfs4_cb_{getattr,recall} flip from LOADED to
REJECTED; iptfs_first_* absent in 6.12).

Fixes: c83e2d970bae ("bpf: Add tracepoints with null-able arguments")
Cc: stable@vger.kernel.org # 6.12+ (nfs4_cb_*)
Signed-off-by: Yingke Xiao <inkxiao12@gmail.com>
---
v1 -> v2:
  - Correct sender identity and Signed-off-by with real legal name per DCO.
  - Remove drafting notes.
  - No functional code changes.

 kernel/bpf/btf.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index a123456..b234567 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6605,10 +6605,13 @@ static const struct bpf_raw_tp_null_args
raw_tp_null_args[] = {
  { "bcache_journal_entry_close", 0x20 },
  { "bch2_journal_entry_close", 0x20 },
  { "fsnotify_bump_event_seq", 0x20 },
- { "nfs4_inode_callback_event", 0x200 },
- { "nfs4_inode_stateid_callback_event", 0x200 },
+ { "nfs4_cb_getattr", 0x200 },
+ { "nfs4_cb_recall", 0x200 },
  { "nilfs2_transaction_entry", 0x4 },
- { "iptfs_ingress_postq_event", 0x1000 },
+ { "iptfs_first_dequeue", 0x1000 },
+ { "iptfs_first_fragmenting", 0x1000 },
+ { "iptfs_first_final_fragment", 0x1000 },
+ { "iptfs_first_toobig", 0x1000 },
 };

 static bool is_raw_tp_null_arg(const struct bpf_raw_tp_null_args *entry,
-- 
2.43.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf v2 1/3] bpf: Replace DECLARE_EVENT_CLASS names in raw_tp_null_args[]
  2026-11-19  7:18 [PATCH bpf v2 1/3] bpf: Replace DECLARE_EVENT_CLASS names in raw_tp_null_args[] Yingke Xiao
@ 2026-11-19 20:05 ` Jiri Olsa
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2026-11-19 20:05 UTC (permalink / raw)
  To: Yingke Xiao
  Cc: bpf, Trond Myklebust, anna, linux-nfs, steffen.klassert, herbert,
	ast, daniel, andrii, stable

On Thu, Nov 19, 2026 at 02:18:29AM -0500, Yingke Xiao wrote:
> btf_ctx_access() strips the "btf_trace_" prefix from attach_btf_id
> and matches tname with strcmp(tname, raw_tp_null_args[i].func). Because
> each attachable tracepoint typedef corresponds to a DEFINE_EVENT() name
> rather than its DECLARE_EVENT_CLASS() template, three existing entries
> in raw_tp_null_args[] never match any program:
> 
>   1. "nfs4_inode_callback_event" and "nfs4_inode_stateid_callback_event"
>      are DECLARE_EVENT_CLASS templates in fs/nfs/nfs4trace.h whose
>      DEFINE_EVENT instances are nfs4_cb_getattr (:1455) and
>      nfs4_cb_recall (:1518). fs/nfs/callback_proc.c:50,106 pass literal
>      NULL for arg 2 (const struct inode *inode), and TP_fast_assign
>      (:1424, :1481) checks !IS_ERR_OR_NULL(inode). Keeping 0x200
>      (0x2ULL << (2 * 4)) sets ptr_err_raw_tp = true so btf_ctx_access()
>      assigns SCALAR_VALUE to ctx[2], rejecting any pointer dereference
>      even under if (inode) and matching existing raw_tp_null_args[]
>      0x2-nibble convention (0x300 yields the identical SCALAR_VALUE).
> 
>   2. "iptfs_ingress_postq_event" is the DECLARE_EVENT_CLASS template in
>      net/xfrm/trace_iptfs.h:108 whose DEFINE_EVENT instances (:130-148)
>      are iptfs_first_dequeue, iptfs_first_fragmenting,
>      iptfs_first_final_fragment, and iptfs_first_toobig.
>      net/xfrm/xfrm_iptfs.c:2025 and :2051 pass literal NULL for arg 3
>      (struct iphdr *iph), requiring mask 0x1000 (PTR_MAYBE_NULL).
> 
> Replace these dead template names with their DEFINE_EVENT tracepoints.
> Verified in QEMU on x86_64 7.4.0-rc3 (iptfs_first_{fragmenting,
> final_fragment} and nfs4_cb_{getattr,recall} flip from LOADED to
> REJECTED) and 6.12.118 (nfs4_cb_{getattr,recall} flip from LOADED to
> REJECTED; iptfs_first_* absent in 6.12).
> 
> Fixes: c83e2d970bae ("bpf: Add tracepoints with null-able arguments")
> Cc: stable@vger.kernel.org # 6.12+ (nfs4_cb_*)
> Signed-off-by: Yingke Xiao <inkxiao12@gmail.com>
> ---
> v1 -> v2:
>   - Correct sender identity and Signed-off-by with real legal name per DCO.
>   - Remove drafting notes.
>   - No functional code changes.
> 
>  kernel/bpf/btf.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 

patch is mangled/broken, can't apply it (check Documentation/process/email-clients.rst)

> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index a123456..b234567 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -6605,10 +6605,13 @@ static const struct bpf_raw_tp_null_args
> raw_tp_null_args[] = {
>   { "bcache_journal_entry_close", 0x20 },
>   { "bch2_journal_entry_close", 0x20 },
>   { "fsnotify_bump_event_seq", 0x20 },
> - { "nfs4_inode_callback_event", 0x200 },
> - { "nfs4_inode_stateid_callback_event", 0x200 },
> + { "nfs4_cb_getattr", 0x200 },
> + { "nfs4_cb_recall", 0x200 },

seems correct

>   { "nilfs2_transaction_entry", 0x4 },
> - { "iptfs_ingress_postq_event", 0x1000 },
> + { "iptfs_first_dequeue", 0x1000 },
> + { "iptfs_first_fragmenting", 0x1000 },
> + { "iptfs_first_final_fragment", 0x1000 },
> + { "iptfs_first_toobig", 0x1000 },

llm says:

  ▎ Only iptfs_first_fragmenting and iptfs_first_final_fragment pass NULL
  ▎ for iph (net/xfrm/xfrm_iptfs.c:2024, :2050). iptfs_first_dequeue and
  ▎ iptfs_first_toobig always pass ip_hdr(skb). Since the old class entry
  ▎ never matched, adding those two would start rejecting existing
  ▎ programs that use iph without a NULL check, even though it can't be
  ▎ NULL there. Should we add only the two NULL-passing events?

jirka

>  };
> 
>  static bool is_raw_tp_null_arg(const struct bpf_raw_tp_null_args *entry,
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-19 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  7:18 [PATCH bpf v2 1/3] bpf: Replace DECLARE_EVENT_CLASS names in raw_tp_null_args[] Yingke Xiao
2026-11-19 20:05 ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox