| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/26 03:06 | flow | patch-triage |
2mArgs:null Results: {
"EnableConfigs": [
"INET",
"BPF_SYSCALL",
"BPF_JIT",
"CGROUP_BPF",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"bpf_tcp_ops_set_rcvlowat",
"bpf_tcp_ops_cb_flags_set",
"bpf_tcp_ops_rcvlowat_kfunc_filter",
"__tcp_set_rcvlowat",
"tcp_set_rcvlowat",
"bpf_sock_ops_cb_flags_set",
"bpf_sol_tcp_setsockopt",
"tcp_fastopen_add_skb"
],
"KMSANReasoning": "The patch series introduces two new callbacks to `struct bpf_tcp_ops` (`enqueue_rcvq` and `dequeue_rcvq`), adds a new callback flag `BPF_SOCK_OPS_RCVQ_CB_FLAG`, refactors `tcp_set_rcvlowat()` into `__tcp_set_rcvlowat()` with a `wakeup` parameter, exposes the `bpf_tcp_ops_set_rcvlowat` kfunc and `bpf_tcp_ops_cb_flags_set` helper, and adds corresponding selftests.\n\nAnalysis regarding KMSAN applicability:\n1. No uninitialized memory or info-leak risks:\n - No new heap/stack allocations or structures are copied to user space.\n - All local variables in newly added and modified functions (`val`, `err`, `moff`, `wakeup`) are explicitly and deterministically initialized before use.\n - The changes do not manipulate buffer sizes, data lengths, or padding in ways that could expose uninitialized data to reads or user space.\n2. Failure modes:\n - The primary risks introduced by this change involve socket locking assumptions, re-entrancy, or object lifetime/reference counting when executing BPF callbacks in TCP receive/cleanup paths (`tcp_fastopen_add_skb`, `tcp_ofo_queue`, `tcp_queue_rcv`, `tcp_cleanup_rbuf`).\n - These risks (use-after-free, null pointer dereference, locking/deadlock issues) are properly covered by KASAN and LOCKDEP.\n - KMSAN would provide no additional bug-finding value here over standard KASAN/LOCKDEP builds.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies core TCP stack and BPF logic by introducing new BPF struct_ops callbacks (enqueue_rcvq, dequeue_rcvq) triggered during TCP receive queue enqueue and dequeue events, a new BPF callback flag (BPF_SOCK_OPS_RCVQ_CB_FLAG), a new BPF helper (bpf_tcp_ops_cb_flags_set), a new kfunc (bpf_tcp_ops_set_rcvlowat), and refactoring TCP rcvlowat handling (__tcp_set_rcvlowat) with selective wakeup suppression. These changes are in reachable core networking/BPF paths and warrant fuzzing to identify potential races, lockdep violations, or assertion failures.",
"WorthFuzzing": true
} |
| 1/1 | 2026/09/26 03:06 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit aae1221aa43202109cc11e718b161f41f4587711\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Sep 26 03:06:07 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/net/tcp.h b/include/net/tcp.h\nindex d61ee00052e33..d3cf655da9ecd 100644\n--- a/include/net/tcp.h\n+++ b/include/net/tcp.h\n@@ -512,6 +512,7 @@ void tcp_set_keepalive(struct sock *sk, int val);\n void tcp_syn_ack_timeout(const struct request_sock *req);\n int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,\n \t\tint flags);\n+int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup);\n int tcp_set_rcvlowat(struct sock *sk, int val);\n void tcp_set_rcvbuf(struct sock *sk, int val);\n int tcp_set_window_clamp(struct sock *sk, int val);\n@@ -2931,6 +2932,16 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2,\n \treturn tcp_call_bpf(sk, op, 3, args);\n }\n \n+static inline int tcp_set_sock_ops_cb_flags(struct sock *sk, int val)\n+{\n+\tif (sk_is_mptcp(sk) \u0026\u0026\n+\t (val \u0026 BPF_SOCK_OPS_RCVQ_CB_FLAG))\n+\t\treturn -EOPNOTSUPP;\n+\n+\ttcp_sk(sk)-\u003ebpf_sock_ops_cb_flags = val;\n+\treturn 0;\n+}\n+\n static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk)\n {\n \ttcp_sk(sk)-\u003ebpf_sock_ops_cb_flags = 0;\n@@ -2953,6 +2964,11 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2,\n \treturn -EPERM;\n }\n \n+static inline int tcp_set_sock_ops_cb_flags(struct sock *sk, int val)\n+{\n+\treturn -EOPNOTSUPP;\n+}\n+\n static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk)\n {\n }\n@@ -3053,6 +3069,12 @@ struct bpf_tcp_ops {\n \t\t\t struct request_sock *req, struct sk_buff *syn_skb,\n \t\t\t enum tcp_synack_type synack_type,\n \t\t\t u32 opt_off);\n+\n+\t/* Called when an incoming skb is enqueued to sk-\u003esk_receive_queue. */\n+\tvoid (*enqueue_rcvq)(struct sock *sk, struct sk_buff *skb);\n+\n+\t/* Called after data is dequeued from sk-\u003esk_receive_queue. */\n+\tvoid (*dequeue_rcvq)(struct sock *sk);\n };\n \n #define bpf_tcp_ops_call(op, sk, ...)\t\t\t\t\t\\\n@@ -3144,6 +3166,18 @@ static inline void tcp_bpf_rtt(struct sock *sk, long mrtt, u32 srtt)\n \tbpf_tcp_ops_call(rtt, sk, mrtt, srtt);\n }\n \n+static inline void bpf_tcp_ops_enqueue_rcvq(struct sock *sk, struct sk_buff *skb)\n+{\n+\tif (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RCVQ_CB_FLAG))\n+\t\tbpf_tcp_ops_call(enqueue_rcvq, sk, skb);\n+}\n+\n+static inline void bpf_tcp_ops_dequeue_rcvq(struct sock *sk)\n+{\n+\tif (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RCVQ_CB_FLAG))\n+\t\tbpf_tcp_ops_call(dequeue_rcvq, sk);\n+}\n+\n #if IS_ENABLED(CONFIG_SMC)\n extern struct static_key_false tcp_have_smc;\n #endif\ndiff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h\nindex 6330b7d745c57..8cdf22667775f 100644\n--- a/include/uapi/linux/bpf.h\n+++ b/include/uapi/linux/bpf.h\n@@ -3264,7 +3264,7 @@ union bpf_attr {\n * \tReturn\n * \t\t0\n *\n- * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)\n+ * long bpf_sock_ops_cb_flags_set(void *bpf_sock, int argval)\n * \tDescription\n * \t\tAttempt to set the value of the **bpf_sock_ops_cb_flags** field\n * \t\tfor the full TCP socket associated to *bpf_sock_ops* to\n@@ -7148,8 +7148,17 @@ enum {\n \t * options first before the BPF program does.\n \t */\n \tBPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1\u003c\u003c6),\n+\t/* Call bpf when the TCP stack enqueues/dequeues payload\n+\t * to/from sk-\u003esk_receive_queue.\n+\t *\n+\t * Only bpf_tcp_ops is supported.\n+\t *\n+\t * It can be used to adjust sk-\u003esk_rcvlowat and suppress\n+\t * unnecessary wakeups before sufficient data is available.\n+\t */\n+\tBPF_SOCK_OPS_RCVQ_CB_FLAG = (1\u003c\u003c7),\n /* Mask of all currently supported cb flags */\n-\tBPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,\n+\tBPF_SOCK_OPS_ALL_CB_FLAGS = 0xFF,\n };\n \n enum {\ndiff --git a/net/core/filter.c b/net/core/filter.c\nindex 5feb998846825..f29c061bb0664 100644\n--- a/net/core/filter.c\n+++ b/net/core/filter.c\n@@ -5588,8 +5588,7 @@ static int bpf_sol_tcp_setsockopt(struct sock *sk, int optname,\n \tcase TCP_BPF_SOCK_OPS_CB_FLAGS:\n \t\tif (val \u0026 ~(BPF_SOCK_OPS_ALL_CB_FLAGS))\n \t\t\treturn -EINVAL;\n-\t\ttp-\u003ebpf_sock_ops_cb_flags = val;\n-\t\tbreak;\n+\t\treturn tcp_set_sock_ops_cb_flags(sk, val);\n \tdefault:\n \t\treturn -EINVAL;\n \t}\n@@ -6178,8 +6177,9 @@ static const struct bpf_func_proto bpf_sock_ops_getsockopt_proto = {\n BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock,\n \t int, argval)\n {\n-\tstruct sock *sk = bpf_sock-\u003esk;\n \tint val = argval \u0026 BPF_SOCK_OPS_ALL_CB_FLAGS;\n+\tstruct sock *sk = bpf_sock-\u003esk;\n+\tint err;\n \n \tif (!is_locked_tcp_sock_ops(bpf_sock))\n \t\treturn -EOPNOTSUPP;\n@@ -6187,7 +6187,9 @@ BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock,\n \tif (!IS_ENABLED(CONFIG_INET) || !sk_fullsock(sk))\n \t\treturn -EINVAL;\n \n-\ttcp_sk(sk)-\u003ebpf_sock_ops_cb_flags = val;\n+\terr = tcp_set_sock_ops_cb_flags(sk, val);\n+\tif (err)\n+\t\treturn err;\n \n \treturn argval \u0026 (~BPF_SOCK_OPS_ALL_CB_FLAGS);\n }\ndiff --git a/net/ipv4/bpf_tcp_ops.c b/net/ipv4/bpf_tcp_ops.c\nindex 681fed6429999..e93c8d13684ef 100644\n--- a/net/ipv4/bpf_tcp_ops.c\n+++ b/net/ipv4/bpf_tcp_ops.c\n@@ -76,6 +76,14 @@ static void write_hdr_opt_stub(struct sock *sk, struct sk_buff *skb,\n {\n }\n \n+static void enqueue_rcvq_stub(struct sock *sk, struct sk_buff *skb)\n+{\n+}\n+\n+static void dequeue_rcvq_stub(struct sock *sk)\n+{\n+}\n+\n static struct bpf_tcp_ops __bpf_tcp_ops = {\n \t.timeout_init = timeout_init_stub,\n \t.rwnd_init = rwnd_init_stub,\n@@ -90,6 +98,8 @@ static struct bpf_tcp_ops __bpf_tcp_ops = {\n \t.parse_hdr = parse_hdr_stub,\n \t.hdr_opt_len = hdr_opt_len_stub,\n \t.write_hdr_opt = write_hdr_opt_stub,\n+\t.enqueue_rcvq = enqueue_rcvq_stub,\n+\t.dequeue_rcvq = dequeue_rcvq_stub,\n };\n \n BPF_CALL_4(bpf_tcp_ops_store_hdr_opt, void *, ctx, const void *, from,\n@@ -210,6 +220,45 @@ const struct bpf_func_proto bpf_tcp_ops_get_retval_proto = {\n \t.ret_type\t= RET_INTEGER,\n };\n \n+BPF_CALL_2(bpf_tcp_ops_cb_flags_set, struct sock *, sk, int, argval)\n+{\n+\tint val = argval \u0026 BPF_SOCK_OPS_ALL_CB_FLAGS;\n+\tint err;\n+\n+\terr = tcp_set_sock_ops_cb_flags(sk, val);\n+\tif (err)\n+\t\treturn err;\n+\n+\treturn argval \u0026 ~BPF_SOCK_OPS_ALL_CB_FLAGS;\n+}\n+\n+static const struct bpf_func_proto bpf_tcp_ops_cb_flags_set_proto = {\n+\t.func\t\t= bpf_tcp_ops_cb_flags_set,\n+\t.gpl_only\t= false,\n+\t.ret_type\t= RET_INTEGER,\n+\t.arg1_type\t= ARG_PTR_TO_BTF_ID,\n+\t.arg1_btf_id\t= \u0026btf_sock_ids[BTF_SOCK_TYPE_TCP],\n+\t.arg2_type\t= ARG_ANYTHING,\n+};\n+\n+static bool is_sockopt_supported(u32 moff)\n+{\n+\tswitch (moff) {\n+\tcase offsetof(struct bpf_tcp_ops, active_established):\n+\tcase offsetof(struct bpf_tcp_ops, passive_established):\n+\tcase offsetof(struct bpf_tcp_ops, rto):\n+\tcase offsetof(struct bpf_tcp_ops, rtt):\n+\tcase offsetof(struct bpf_tcp_ops, set_state):\n+\tcase offsetof(struct bpf_tcp_ops, retrans):\n+\tcase offsetof(struct bpf_tcp_ops, connect):\n+\tcase offsetof(struct bpf_tcp_ops, listen):\n+\tcase offsetof(struct bpf_tcp_ops, parse_hdr):\n+\t\treturn true;\n+\t}\n+\n+\treturn false;\n+}\n+\n static const struct bpf_func_proto *\n get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)\n {\n@@ -221,22 +270,13 @@ get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)\n \tcase BPF_FUNC_sk_storage_delete:\n \t\treturn \u0026bpf_sk_storage_delete_proto;\n \tcase BPF_FUNC_setsockopt:\n-\t\t/* The sk may be an unlocked listener (synack path) or NULL\n-\t\t * fullsock; disable for members that can run unlocked.\n-\t\t */\n-\t\tif (moff == offsetof(struct bpf_tcp_ops, rwnd_init) ||\n-\t\t moff == offsetof(struct bpf_tcp_ops, timeout_init) ||\n-\t\t moff == offsetof(struct bpf_tcp_ops, hdr_opt_len) ||\n-\t\t moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))\n-\t\t\treturn NULL;\n-\t\treturn \u0026bpf_sk_setsockopt_proto;\n+\t\tif (is_sockopt_supported(moff))\n+\t\t\treturn \u0026bpf_sk_setsockopt_proto;\n+\t\treturn NULL;\n \tcase BPF_FUNC_getsockopt:\n-\t\tif (moff == offsetof(struct bpf_tcp_ops, rwnd_init) ||\n-\t\t moff == offsetof(struct bpf_tcp_ops, timeout_init) ||\n-\t\t moff == offsetof(struct bpf_tcp_ops, hdr_opt_len) ||\n-\t\t moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))\n-\t\t\treturn NULL;\n-\t\treturn \u0026bpf_sk_getsockopt_proto;\n+\t\tif (is_sockopt_supported(moff))\n+\t\t\treturn \u0026bpf_sk_getsockopt_proto;\n+\t\treturn NULL;\n \tcase BPF_FUNC_get_retval:\n \t\tif (moff == offsetof(struct bpf_tcp_ops, timeout_init) ||\n \t\t moff == offsetof(struct bpf_tcp_ops, rwnd_init))\n@@ -255,6 +295,15 @@ get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)\n \t\tif (moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))\n \t\t\treturn \u0026bpf_tcp_ops_store_hdr_opt_proto;\n \t\treturn NULL;\n+\tcase BPF_FUNC_sock_ops_cb_flags_set:\n+\t\tif (moff == offsetof(struct bpf_tcp_ops, connect) ||\n+\t\t moff == offsetof(struct bpf_tcp_ops, listen) ||\n+\t\t moff == offsetof(struct bpf_tcp_ops, active_established) ||\n+\t\t moff == offsetof(struct bpf_tcp_ops, passive_established) ||\n+\t\t moff == offsetof(struct bpf_tcp_ops, enqueue_rcvq) ||\n+\t\t moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))\n+\t\t\treturn \u0026bpf_tcp_ops_cb_flags_set_proto;\n+\t\treturn NULL;\n \tdefault:\n \t\treturn bpf_base_func_proto(func_id, prog);\n \t}\n@@ -319,8 +368,62 @@ static struct bpf_struct_ops bpf_tcp_ops = {\n \t.owner = THIS_MODULE,\n };\n \n+__bpf_kfunc_start_defs();\n+\n+__bpf_kfunc int bpf_tcp_ops_set_rcvlowat(struct sock *sk, int rcvlowat,\n+\t\t\t\t\t const struct bpf_prog_aux *aux)\n+{\n+\tu32 moff = aux-\u003eattach_st_ops_member_off;\n+\tbool wakeup = false;\n+\n+\tif (moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))\n+\t\twakeup = true;\n+\n+\tif (rcvlowat \u003c 0)\n+\t\trcvlowat = INT_MAX;\n+\n+\treturn __tcp_set_rcvlowat(sk, rcvlowat, wakeup);\n+}\n+\n+__bpf_kfunc_end_defs();\n+\n+BTF_KFUNCS_START(bpf_tcp_ops_rcvlowat_kfunc_set)\n+BTF_ID_FLAGS(func, bpf_tcp_ops_set_rcvlowat, KF_IMPLICIT_ARGS)\n+BTF_KFUNCS_END(bpf_tcp_ops_rcvlowat_kfunc_set)\n+\n+static int bpf_tcp_ops_rcvlowat_kfunc_filter(const struct bpf_prog *prog,\n+\t\t\t\t\t u32 kfunc_id)\n+{\n+\tu32 moff;\n+\n+\tif (!btf_id_set8_contains(\u0026bpf_tcp_ops_rcvlowat_kfunc_set, kfunc_id))\n+\t\treturn 0;\n+\n+\tif (prog-\u003eaux-\u003est_ops != \u0026bpf_tcp_ops)\n+\t\treturn -EACCES;\n+\n+\tmoff = prog-\u003eaux-\u003eattach_st_ops_member_off;\n+\tif (moff != offsetof(struct bpf_tcp_ops, enqueue_rcvq) \u0026\u0026\n+\t moff != offsetof(struct bpf_tcp_ops, dequeue_rcvq))\n+\t\treturn -EACCES;\n+\n+\treturn 0;\n+}\n+\n+static const struct btf_kfunc_id_set bpf_tcp_ops_rcvlowat_kfunc_id_set = {\n+\t.owner = THIS_MODULE,\n+\t.set = \u0026bpf_tcp_ops_rcvlowat_kfunc_set,\n+\t.filter = bpf_tcp_ops_rcvlowat_kfunc_filter,\n+};\n+\n static int __init __bpf_tcp_ops_init(void)\n {\n-\treturn register_bpf_struct_ops(\u0026bpf_tcp_ops, bpf_tcp_ops);\n+\tint ret;\n+\n+\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\n+\t\t\t\t\t\u0026bpf_tcp_ops_rcvlowat_kfunc_id_set);\n+\tret = ret ?: register_bpf_struct_ops(\u0026bpf_tcp_ops, bpf_tcp_ops);\n+\n+\treturn ret;\n }\n late_initcall(__bpf_tcp_ops_init);\ndiff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c\nindex a4456b4194122..aa7593fc8334e 100644\n--- a/net/ipv4/tcp.c\n+++ b/net/ipv4/tcp.c\n@@ -1610,6 +1610,8 @@ void tcp_cleanup_rbuf(struct sock *sk, int copied)\n \t \"cleanup rbuf bug: copied %X seq %X rcvnxt %X\\n\",\n \t tp-\u003ecopied_seq, TCP_SKB_CB(skb)-\u003eend_seq, tp-\u003ercv_nxt);\n \t__tcp_cleanup_rbuf(sk, copied);\n+\n+\tbpf_tcp_ops_dequeue_rcvq(sk);\n }\n \n static void tcp_eat_recv_skb(struct sock *sk, struct sk_buff *skb)\n@@ -1826,8 +1828,7 @@ int tcp_peek_len(struct socket *sock)\n \treturn tcp_inq(sock-\u003esk);\n }\n \n-/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */\n-int tcp_set_rcvlowat(struct sock *sk, int val)\n+int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup)\n {\n \tstruct tcp_sock *tp = tcp_sk(sk);\n \tint space, cap;\n@@ -1840,7 +1841,8 @@ int tcp_set_rcvlowat(struct sock *sk, int val)\n \tWRITE_ONCE(sk-\u003esk_rcvlowat, val ? : 1);\n \n \t/* Check if we need to signal EPOLLIN right now */\n-\ttcp_data_ready(sk);\n+\tif (wakeup)\n+\t\ttcp_data_ready(sk);\n \n \tif (sk-\u003esk_userlocks \u0026 SOCK_RCVBUF_LOCK)\n \t\treturn 0;\n@@ -1855,6 +1857,12 @@ int tcp_set_rcvlowat(struct sock *sk, int val)\n \treturn 0;\n }\n \n+/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */\n+int tcp_set_rcvlowat(struct sock *sk, int val)\n+{\n+\treturn __tcp_set_rcvlowat(sk, val, true);\n+}\n+\n void tcp_set_rcvbuf(struct sock *sk, int val)\n {\n \ttcp_set_window_clamp(sk, tcp_win_from_space(sk, val));\ndiff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c\nindex 471c78be55137..4939bcbc81d17 100644\n--- a/net/ipv4/tcp_fastopen.c\n+++ b/net/ipv4/tcp_fastopen.c\n@@ -281,6 +281,8 @@ void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb)\n \tTCP_SKB_CB(skb)-\u003eseq++;\n \tTCP_SKB_CB(skb)-\u003etcp_flags \u0026= ~TCPHDR_SYN;\n \n+\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\n+\n \ttp-\u003ercv_nxt = TCP_SKB_CB(skb)-\u003eend_seq;\n \ttcp_add_receive_queue(sk, skb);\n \ttp-\u003esyn_data_acked = 1;\ndiff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c\nindex 6ac6f9d5b6c38..c60c61bb0a715 100644\n--- a/net/ipv4/tcp_input.c\n+++ b/net/ipv4/tcp_input.c\n@@ -5344,6 +5344,8 @@ static void tcp_ofo_queue(struct sock *sk)\n \t\t\tcontinue;\n \t\t}\n \n+\t\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\n+\n \t\ttail = skb_peek_tail(\u0026sk-\u003esk_receive_queue);\n \t\teaten = tail \u0026\u0026 tcp_try_coalesce(sk, tail, skb, \u0026fragstolen);\n \t\ttcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)-\u003eend_seq);\n@@ -5547,6 +5549,8 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb,\n \tint eaten;\n \tstruct sk_buff *tail = skb_peek_tail(\u0026sk-\u003esk_receive_queue);\n \n+\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\n+\n \teaten = (tail \u0026\u0026\n \t\t tcp_try_coalesce(sk, tail,\n \t\t\t\t skb, fragstolen)) ? 1 : 0;\ndiff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h\nindex 6330b7d745c57..8cdf22667775f 100644\n--- a/tools/include/uapi/linux/bpf.h\n+++ b/tools/include/uapi/linux/bpf.h\n@@ -3264,7 +3264,7 @@ union bpf_attr {\n * \tReturn\n * \t\t0\n *\n- * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)\n+ * long bpf_sock_ops_cb_flags_set(void *bpf_sock, int argval)\n * \tDescription\n * \t\tAttempt to set the value of the **bpf_sock_ops_cb_flags** field\n * \t\tfor the full TCP socket associated to *bpf_sock_ops* to\n@@ -7148,8 +7148,17 @@ enum {\n \t * options first before the BPF program does.\n \t */\n \tBPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1\u003c\u003c6),\n+\t/* Call bpf when the TCP stack enqueues/dequeues payload\n+\t * to/from sk-\u003esk_receive_queue.\n+\t *\n+\t * Only bpf_tcp_ops is supported.\n+\t *\n+\t * It can be used to adjust sk-\u003esk_rcvlowat and suppress\n+\t * unnecessary wakeups before sufficient data is available.\n+\t */\n+\tBPF_SOCK_OPS_RCVQ_CB_FLAG = (1\u003c\u003c7),\n /* Mask of all currently supported cb flags */\n-\tBPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,\n+\tBPF_SOCK_OPS_ALL_CB_FLAGS = 0xFF,\n };\n \n enum {\ndiff --git a/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c b/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c\nnew file mode 100644\nindex 0000000000000..337f9d34a39c5\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c\n@@ -0,0 +1,350 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright 2026 Google LLC */\n+#include \u003csys/epoll.h\u003e\n+\n+#include \"test_progs.h\"\n+#include \"cgroup_helpers.h\"\n+#include \"network_helpers.h\"\n+\n+#include \"tcp_autolowat.skel.h\"\n+\n+#define SOL_BPF\t\t\t0xdeadbeef\n+#define BPF_TCP_AUTOLOWAT\t0x8badf00d\n+\n+struct rpc_descriptor {\n+\tu32 header_len;\n+\tu32 payload_len;\n+};\n+\n+enum rpc_event_type {\n+\tRPC_EVENT_END,\n+\tRPC_EVENT_AUTOLOWAT,\n+\tRPC_EVENT_SEND,\n+\tRPC_EVENT_RECV,\n+\tRPC_EVENT_EPOLL,\n+\tRPC_EVENT_RCVLOWAT,\n+};\n+\n+struct rpc_event {\n+\tenum rpc_event_type type;\n+\tunion {\n+\t\tint len;\n+\t\tint nfds;\n+\t\tint val;\n+\t\tint rcvlowat;\n+\t};\n+};\n+\n+#define RPC_DESC_SIZE (sizeof(struct rpc_descriptor))\n+\n+static struct rpc_test_case {\n+\tchar data[4096];\n+\tstruct rpc_descriptor desc[32];\n+\tstruct rpc_event event[32];\n+} rpc_test_cases[] = {\n+\t{\n+\t\t.desc = {\n+\t\t\t{ .header_len = 100, .payload_len = 150 },\n+\t\t},\n+\t\t.event = {\n+\t\t\t{ .type = RPC_EVENT_AUTOLOWAT,\t.val = 1},\n+\t\t\t/* Single full RPC message in skb. */\n+\t\t\t{ .type = RPC_EVENT_SEND,\t.len = RPC_DESC_SIZE + 100 + 150},\n+\t\t\t{ .type = RPC_EVENT_EPOLL,\t.nfds = 1},\n+\t\t\t{ .type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = RPC_DESC_SIZE + 100 + 150},\n+\t\t},\n+\t},\n+\t{\n+\t\t.desc = {\n+\t\t\t{.header_len = 100, .payload_len = 150},\n+\t\t\t{.header_len = 100, .payload_len = 150},\n+\t\t\t{.header_len = 100, .payload_len = 150},\n+\t\t},\n+\t\t.event = {\n+\t\t\t{ .type = RPC_EVENT_AUTOLOWAT,\t.val = 1},\n+\t\t\t/* Two full RPC messages in skb. */\n+\t\t\t{.type = RPC_EVENT_SEND,\t.len = (RPC_DESC_SIZE + 100 + 150) * 2},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 1},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},\n+\t\t\t/* Single full RPC message in skb. */\n+\t\t\t{ .type = RPC_EVENT_SEND,\t.len = RPC_DESC_SIZE + 100 + 150},\n+\t\t\t{ .type = RPC_EVENT_EPOLL,\t.nfds = 1},\n+\t\t\t{ .type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 3},\n+\t\t},\n+\t},\n+\t{\n+\t\t.desc = {\n+\t\t\t{.header_len = 100, .payload_len = 150},\n+\t\t\t{.header_len = 100, .payload_len = 150},\n+\t\t\t{.header_len = 100, .payload_len = 150},\n+\t\t},\n+\t\t.event = {\n+\t\t\t{ .type = RPC_EVENT_AUTOLOWAT,\t.val = 1},\n+\t\t\t/* Two full RPC messages in skb. */\n+\t\t\t{.type = RPC_EVENT_SEND,\t.len = (RPC_DESC_SIZE + 100 + 150) * 2},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 1},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},\n+\t\t\t/* Only the next descriptor in skb. */\n+\t\t\t{ .type = RPC_EVENT_SEND,\t.len = RPC_DESC_SIZE},\n+\t\t\t{ .type = RPC_EVENT_EPOLL,\t.nfds = 1},\n+\t\t\t{ .type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},\n+\t\t},\n+\t},\n+\t{\n+\t\t.desc = {\n+\t\t\t{.header_len = 100, .payload_len = 150},\n+\t\t\t{.header_len = 200, .payload_len = 500},\n+\t\t},\n+\t\t.event = {\n+\t\t\t{ .type = RPC_EVENT_AUTOLOWAT,\t.val = 1},\n+\t\t\t/* The first descriptor is partial. */\n+\t\t\t{.type = RPC_EVENT_SEND,\t.len = 1},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 0},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = RPC_DESC_SIZE},\n+\t\t\t/* The first descriptor is available. */\n+\t\t\t{.type = RPC_EVENT_SEND,\t.len = RPC_DESC_SIZE - 1},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 0},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = RPC_DESC_SIZE + 150 + 100},\n+\t\t\t/* The first header is ready. */\n+\t\t\t{.type = RPC_EVENT_SEND,\t.len = 100},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 0},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = RPC_DESC_SIZE + 150 + 100},\n+\t\t\t/* skb has the first payload and 1 byte of the next descriptor. */\n+\t\t\t{.type = RPC_EVENT_SEND,\t.len = 150 + 1},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 1},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = RPC_DESC_SIZE + 150 + 100},\n+\t\t\t/* After reading the first RPC message, SO_RCVLOWAT should be RPC_DESC_SIZE. */\n+\t\t\t{.type = RPC_EVENT_RECV,\t.len = RPC_DESC_SIZE + 150 + 100},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 0},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = RPC_DESC_SIZE},\n+\t\t\t/* The second descriptor is available. */\n+\t\t\t{.type = RPC_EVENT_SEND,\t.len = RPC_DESC_SIZE - 1},\n+\t\t\t{.type = RPC_EVENT_EPOLL,\t.nfds = 0},\n+\t\t\t{.type = RPC_EVENT_RCVLOWAT,\t.rcvlowat = RPC_DESC_SIZE + 200 + 500},\n+\t\t},\n+\t},\n+};\n+\n+struct tcp_autolowat_test_cb {\n+\tint saved_netns;\n+\tunion {\n+\t\tint fd[4];\n+\t\tstruct {\n+\t\t\tint server, client, child;\n+\t\t\tint epoll;\n+\t\t};\n+\t};\n+};\n+\n+static void tcp_autolowat_teardown_cb(struct tcp_autolowat_test_cb *cb)\n+{\n+\tint i, err;\n+\n+\tfor (i = 0; i \u003c ARRAY_SIZE(cb-\u003efd); i++) {\n+\t\tif (cb-\u003efd[i] != -1)\n+\t\t\tclose(cb-\u003efd[i]);\n+\t}\n+\n+\tif (cb-\u003esaved_netns != -1) {\n+\t\terr = setns(cb-\u003esaved_netns, CLONE_NEWNET);\n+\t\tASSERT_OK(err, \"restore netns\");\n+\n+\t\tclose(cb-\u003esaved_netns);\n+\t}\n+}\n+\n+static int tcp_autolowat_setup_cb(struct tcp_autolowat_test_cb *cb, int family)\n+{\n+\tstruct epoll_event ev = {};\n+\tint err;\n+\tint i;\n+\n+\tfor (i = 0; i \u003c ARRAY_SIZE(cb-\u003efd); i++)\n+\t\tcb-\u003efd[i] = -1;\n+\n+\tcb-\u003esaved_netns = open(\"/proc/self/ns/net\", O_RDONLY);\n+\tif (!ASSERT_OK_FD(cb-\u003esaved_netns, \"save netns\"))\n+\t\tgoto err;\n+\n+\terr = unshare(CLONE_NEWNET);\n+\tif (!ASSERT_OK(err, \"unshare\"))\n+\t\tgoto err;\n+\n+\terr = system(\"ip link set dev lo up\");\n+\tif (!ASSERT_OK(err, \"set up lo\"))\n+\t\tgoto err;\n+\n+\tcb-\u003eserver = start_server(family, SOCK_STREAM, NULL, 0, 0);\n+\tif (!ASSERT_OK_FD(cb-\u003eserver, \"start_server\"))\n+\t\tgoto err;\n+\n+\tcb-\u003eclient = connect_to_fd(cb-\u003eserver, 0);\n+\tif (!ASSERT_OK_FD(cb-\u003eclient, \"connect_to_fd\"))\n+\t\tgoto err;\n+\n+\tcb-\u003echild = accept(cb-\u003eserver, NULL, NULL);\n+\tif (!ASSERT_OK_FD(cb-\u003echild, \"accept\"))\n+\t\tgoto err;\n+\n+\tcb-\u003eepoll = epoll_create1(0);\n+\tif (!ASSERT_OK_FD(cb-\u003eepoll, \"epoll_create\"))\n+\t\tgoto err;\n+\n+\tev.events = EPOLLIN;\n+\tev.data.fd = cb-\u003echild;\n+\n+\terr = epoll_ctl(cb-\u003eepoll, EPOLL_CTL_ADD, cb-\u003echild, \u0026ev);\n+\tif (!ASSERT_OK(err, \"epoll_ctl\"))\n+\t\tgoto err;\n+\n+\treturn 0;\n+\n+err:\n+\ttcp_autolowat_teardown_cb(cb);\n+\treturn -1;\n+}\n+\n+static int tcp_autolowat_build_data(struct rpc_test_case *test_case)\n+{\n+\tstruct rpc_descriptor *desc = test_case-\u003edesc;\n+\tchar *ptr = test_case-\u003edata;\n+\tint rpc_size;\n+\n+\tmemset(ptr, 0, sizeof(test_case-\u003edata));\n+\n+\twhile (desc-\u003eheader_len + desc-\u003epayload_len) {\n+\t\trpc_size = sizeof(*desc) + desc-\u003eheader_len + desc-\u003epayload_len;\n+\n+\t\tif (!ASSERT_LE(ptr + rpc_size - test_case-\u003edata,\n+\t\t\t sizeof(test_case-\u003edata), \"data overflow\"))\n+\t\t\treturn 1;\n+\n+\t\tmemcpy(ptr, desc, sizeof(*desc));\n+\t\tptr += rpc_size;\n+\t\tdesc++;\n+\t}\n+\n+\tif (!ASSERT_GT(ptr - test_case-\u003edata, 0, \"no data\"))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+static void tcp_autolowat_run_rpc_test(struct tcp_autolowat_test_cb *cb,\n+\t\t\t\t struct rpc_test_case *test_case)\n+{\n+\tstruct rpc_event *event = test_case-\u003eevent;\n+\tchar *ptr = test_case-\u003edata;\n+\tstruct epoll_event ev;\n+\tsocklen_t optlen;\n+\tint err, optval;\n+\tchar buf[4096];\n+\n+\tif (tcp_autolowat_build_data(test_case))\n+\t\treturn;\n+\n+\twhile (1) {\n+\t\tswitch (event-\u003etype) {\n+\t\tcase RPC_EVENT_END:\n+\t\t\treturn;\n+\t\tcase RPC_EVENT_AUTOLOWAT:\n+\t\t\terr = setsockopt(cb-\u003echild, SOL_BPF, BPF_TCP_AUTOLOWAT,\n+\t\t\t\t\t \u0026event-\u003eval, sizeof(event-\u003eval));\n+\t\t\tif (!ASSERT_OK(err, \"setsockopt\"))\n+\t\t\t\treturn;\n+\t\t\tbreak;\n+\t\tcase RPC_EVENT_SEND:\n+\t\t\terr = send(cb-\u003eclient, ptr, event-\u003elen, 0);\n+\t\t\tif (!ASSERT_EQ(err, event-\u003elen, \"send\"))\n+\t\t\t\treturn;\n+\n+\t\t\tptr += event-\u003elen;\n+\t\t\tbreak;\n+\t\tcase RPC_EVENT_RECV:\n+\t\t\terr = recv(cb-\u003echild, buf, event-\u003elen, 0);\n+\t\t\tif (!ASSERT_EQ(err, event-\u003elen, \"recv\"))\n+\t\t\t\treturn;\n+\t\t\tbreak;\n+\t\tcase RPC_EVENT_EPOLL:\n+\t\t\terr = epoll_wait(cb-\u003eepoll, \u0026ev, 1, 100);\n+\t\t\tif (!ASSERT_EQ(err, event-\u003enfds, \"epoll_wait\"))\n+\t\t\t\treturn;\n+\t\t\tbreak;\n+\t\tcase RPC_EVENT_RCVLOWAT:\n+\t\t\toptval = 0;\n+\t\t\toptlen = sizeof(optval);\n+\n+\t\t\terr = getsockopt(cb-\u003echild, SOL_SOCKET, SO_RCVLOWAT, \u0026optval, \u0026optlen);\n+\t\t\tif (!ASSERT_OK(err, \"getsockopt\") ||\n+\t\t\t !ASSERT_EQ(optval, event-\u003ercvlowat, \"rcvlowat\"))\n+\t\t\t\treturn;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tevent++;\n+\t}\n+}\n+\n+static void tcp_autolowat_run_rpc_tests(struct tcp_autolowat *skel, int family)\n+{\n+\tstruct tcp_autolowat_test_cb cb;\n+\tint err;\n+\tint i;\n+\n+\tfor (i = 0; i \u003c ARRAY_SIZE(rpc_test_cases); i++) {\n+\t\tmemset(skel-\u003ebss-\u003etest_name, 0, sizeof(skel-\u003ebss-\u003etest_name));\n+\n+\t\tsnprintf(skel-\u003ebss-\u003etest_name, sizeof(skel-\u003ebss-\u003etest_name),\n+\t\t\t \"AF_INET%c rpc_test_cases[%d]\",\n+\t\t\t family == AF_INET ? ' ' : '6', i);\n+\n+\t\tif (!test__start_subtest(skel-\u003ebss-\u003etest_name))\n+\t\t\tcontinue;\n+\n+\t\terr = tcp_autolowat_setup_cb(\u0026cb, family);\n+\t\tif (err)\n+\t\t\tcontinue;\n+\n+\t\ttcp_autolowat_run_rpc_test(\u0026cb, \u0026rpc_test_cases[i]);\n+\t\ttcp_autolowat_teardown_cb(\u0026cb);\n+\t}\n+}\n+\n+static void tcp_autolowat_run_tests(struct tcp_autolowat *skel)\n+{\n+\ttcp_autolowat_run_rpc_tests(skel, AF_INET);\n+\ttcp_autolowat_run_rpc_tests(skel, AF_INET6);\n+}\n+\n+void test_tcp_autolowat(void)\n+{\n+\tstruct tcp_autolowat *skel;\n+\tstruct bpf_link *link[2];\n+\tint cgroup;\n+\n+\tskel = tcp_autolowat__open_and_load();\n+\tif (!ASSERT_OK_PTR(skel, \"open_and_load\"))\n+\t\treturn;\n+\n+\tcgroup = test__join_cgroup(\"/tcp_autolowat\");\n+\tif (!ASSERT_GE(cgroup, 0, \"join_cgroup\"))\n+\t\tgoto destroy_skel;\n+\n+\tlink[0] = bpf_map__attach_cgroup_opts(skel-\u003emaps.tcp_autolowat_ops, cgroup, NULL);\n+\tif (!ASSERT_OK_PTR(link[0], \"attach_cgroup(tcp_autolowat_ops)\"))\n+\t\tgoto close_cgroup;\n+\n+\tlink[1] = bpf_program__attach_cgroup(skel-\u003eprogs.tcp_autolowat_setsockopt, cgroup);\n+\tif (!ASSERT_OK_PTR(link[1], \"attach_cgroup(SETSOCKOPT)\"))\n+\t\tgoto destroy_sockops;\n+\n+\ttcp_autolowat_run_tests(skel);\n+\n+\tbpf_link__destroy(link[1]);\n+destroy_sockops:\n+\tbpf_link__destroy(link[0]);\n+close_cgroup:\n+\tclose(cgroup);\n+destroy_skel:\n+\ttcp_autolowat__destroy(skel);\n+}\ndiff --git a/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c b/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c\nindex 7e8fe1bad03f5..e4849d2a2956f 100644\n--- a/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c\n+++ b/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c\n@@ -26,7 +26,8 @@ static void verify_result(struct tcpbpf_globals *result)\n \tASSERT_EQ(result-\u003ebytes_acked, 1002, \"bytes_acked\");\n \tASSERT_EQ(result-\u003edata_segs_in, 1, \"data_segs_in\");\n \tASSERT_EQ(result-\u003edata_segs_out, 1, \"data_segs_out\");\n-\tASSERT_EQ(result-\u003ebad_cb_test_rv, 0x80, \"bad_cb_test_rv\");\n+\tASSERT_EQ(result-\u003ebad_cb_test_rv, BPF_SOCK_OPS_ALL_CB_FLAGS + 1,\n+\t\t \"bad_cb_test_rv\");\n \tASSERT_EQ(result-\u003egood_cb_test_rv, 0, \"good_cb_test_rv\");\n \tASSERT_EQ(result-\u003enum_listen, 1, \"num_listen\");\n \ndiff --git a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h\nindex 593b38f904174..4c999d59cbbce 100644\n--- a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h\n+++ b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h\n@@ -79,6 +79,8 @@\n \n #define NEXTHDR_TCP\t\t6\n \n+#define TCPHDR_FIN\t\t0x01\n+\n #define TCPOPT_NOP\t\t1\n #define TCPOPT_EOL\t\t0\n #define TCPOPT_MSS\t\t2\ndiff --git a/tools/testing/selftests/bpf/progs/tcp_autolowat.c b/tools/testing/selftests/bpf/progs/tcp_autolowat.c\nnew file mode 100644\nindex 0000000000000..4fe7bdc98e69f\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/progs/tcp_autolowat.c\n@@ -0,0 +1,312 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright 2026 Google LLC */\n+#include \"vmlinux.h\"\n+\n+#include \u003cstring.h\u003e\n+#include \u003climits.h\u003e\n+#include \u003cbpf/bpf_helpers.h\u003e\n+#include \u003cbpf/bpf_tracing.h\u003e\n+#include \u003cbpf/bpf_core_read.h\u003e\n+\n+#include \"bpf_kfuncs.h\"\n+#include \"bpf_tracing_net.h\"\n+\n+#define SOL_BPF\t\t\t0xdeadbeef\n+#define BPF_TCP_AUTOLOWAT\t0x8badf00d\n+\n+//#define DEBUG /* For verbose output. */\n+\n+struct rpc_descriptor {\n+\tu32 header_len;\n+\tu32 payload_len;\n+};\n+\n+#define RPC_DESC_SIZE\t\t(sizeof(struct rpc_descriptor))\n+#define MAX_RPC_DESC_PER_SKB\t100\n+\n+struct tcp_autolowat_cb {\n+\t/* Don't put this field at the end; BPF verifier complains. */\n+\tchar rpc_desc_buf[RPC_DESC_SIZE];\n+\tu32 rpc_desc_seq;\n+\tu32 rpc_end_seq;\n+#ifdef DEBUG\n+\tu32 isn;\n+#endif\n+\tu8 rpc_desc_buff_len;\n+};\n+\n+struct {\n+\t__uint(type, BPF_MAP_TYPE_SK_STORAGE);\n+\t__uint(map_flags, BPF_F_NO_PREALLOC);\n+\t__type(key, int);\n+\t__type(value, struct tcp_autolowat_cb);\n+} tcp_autolowat_map SEC(\".maps\");\n+\n+char test_name[64];\n+\n+#ifdef DEBUG\n+#define LOG(str, ...)\t\t\t\t\t\t\t\\\n+\tbpf_printk(\"%s: \" str, test_name, ##__VA_ARGS__)\n+#else\n+#define LOG(...)\n+#endif\n+\n+#define SEQ(val)\t\t\t\t\\\n+\t(val - cb-\u003eisn)\n+#define TP_SEQ(field)\t\t\t\t\\\n+\t(tp-\u003efield - cb-\u003eisn)\n+#define CB_SEQ(field)\t\t\t\t\\\n+\t(cb-\u003efield - cb-\u003eisn)\n+\n+static int tcp_parse_descriptor(struct tcp_autolowat_cb *cb,\n+\t\t\t\tstruct bpf_dynptr *dptr,\n+\t\t\t\tu32 seq, u32 end_seq)\n+{\n+\tstruct rpc_descriptor *rpc_desc;\n+\tu32 rpc_copied_seq;\n+\tu64 copy_len; /* u32 should work, but not for no_alu32 :/ */\n+\tu64 rpc_len;\n+\tint err;\n+\n+\trpc_copied_seq = cb-\u003erpc_desc_seq + cb-\u003erpc_desc_buff_len;\n+\n+\tif (before(cb-\u003erpc_desc_seq + RPC_DESC_SIZE, end_seq))\n+\t\tcopy_len = RPC_DESC_SIZE - cb-\u003erpc_desc_buff_len;\n+\telse\n+\t\tcopy_len = end_seq - rpc_copied_seq;\n+\n+\tif (copy_len == 0)\n+\t\tgoto disable; /* FIN. */\n+\tif (copy_len \u003e RPC_DESC_SIZE)\n+\t\tgoto disable; /* always false, only for verifier. */\n+\tif (cb-\u003erpc_desc_buff_len \u003e= RPC_DESC_SIZE)\n+\t\tgoto disable; /* always false, only for verifier. */\n+\n+\terr = bpf_dynptr_read(cb-\u003erpc_desc_buf + cb-\u003erpc_desc_buff_len,\n+\t\t\t copy_len, dptr, rpc_copied_seq - seq, 0);\n+\tif (err)\n+\t\tgoto disable;\n+\n+\tcb-\u003erpc_desc_buff_len += copy_len;\n+\n+\tif (cb-\u003erpc_desc_buff_len != RPC_DESC_SIZE) {\n+\t\tLOG(\"Copied %d bytes: rpc_desc_buff_len: %u\", copy_len, cb-\u003erpc_desc_buff_len);\n+\t\tgoto partial;\n+\t}\n+\n+\trpc_desc = (struct rpc_descriptor *)cb-\u003erpc_desc_buf;\n+\trpc_len = RPC_DESC_SIZE + rpc_desc-\u003eheader_len + rpc_desc-\u003epayload_len;\n+\n+\tif (rpc_len \u003e INT_MAX)\n+\t\tgoto disable;\n+\n+\tcb-\u003erpc_end_seq = cb-\u003erpc_desc_seq + rpc_len;\n+\n+\tLOG(\"Copied full descriptor: rpc_desc_seq: %u, rpc_end_seq: %u, header_len: %u, payload_len: %u\",\n+\t CB_SEQ(rpc_desc_seq), CB_SEQ(rpc_end_seq),\n+\t rpc_desc-\u003eheader_len, rpc_desc-\u003epayload_len);\n+\n+\treturn 0;\n+disable:\n+\treturn -1;\n+partial:\n+\treturn 1;\n+}\n+\n+static void tcp_set_autolowat(struct tcp_autolowat_cb *cb,\n+\t\t\t struct sock *sk)\n+{\n+\tstruct tcp_sock *tp = (struct tcp_sock *)sk;\n+\tu32 val; /* To handle wraparound. */\n+\n+\tLOG(\"Setting rcvlowat: tp-\u003ecopied_seq: %u, rpc_desc_seq: %u, rpc_end_seq: %u, rpc_desc_buff_len: %u\",\n+\t TP_SEQ(copied_seq), CB_SEQ(rpc_desc_seq),\n+\t CB_SEQ(rpc_end_seq), cb-\u003erpc_desc_buff_len);\n+\n+\tif (before(tp-\u003ecopied_seq, cb-\u003erpc_desc_seq))\n+\t\tval = cb-\u003erpc_desc_seq - tp-\u003ecopied_seq;\n+\telse if (cb-\u003erpc_desc_buff_len != RPC_DESC_SIZE)\n+\t\tval = RPC_DESC_SIZE;\n+\telse\n+\t\tval = cb-\u003erpc_end_seq - tp-\u003ecopied_seq;\n+\n+\tif (val != tp-\u003einet_conn.icsk_inet.sk.sk_rcvlowat) {\n+\t\tbpf_tcp_ops_set_rcvlowat(sk, val);\n+\n+\t\tLOG(\"Set rcvlowat: expected: %u, actual: %d\\n\",\n+\t\t val, tp-\u003einet_conn.icsk_inet.sk.sk_rcvlowat);\n+\t} else {\n+\t\tLOG(\"No need to set rcvlowat: %u\\n\", val);\n+\t}\n+}\n+\n+static void tcp_disable_autolowat(struct sock *sk)\n+{\n+\tstruct tcp_sock *tp = (struct tcp_sock *)sk;\n+\tint flags;\n+\n+\tflags = tp-\u003ebpf_sock_ops_cb_flags \u0026 ~BPF_SOCK_OPS_RCVQ_CB_FLAG;\n+\tbpf_sock_ops_cb_flags_set(sk, flags);\n+\n+\tbpf_tcp_ops_set_rcvlowat(sk, 1);\n+\n+\tLOG(\"Disabled autolowat\");\n+}\n+\n+static void tcp_do_autolowat(struct tcp_autolowat_cb *cb,\n+\t\t\t struct sock *sk, struct sk_buff *skb)\n+{\n+\tstruct bpf_dynptr dptr;\n+\tstruct tcp_skb_cb *tcb;\n+\tu32 seq, end_seq;\n+\tint ret = 0, i;\n+\n+\tif (bpf_dynptr_from_skb((struct __sk_buff *)skb, 0, \u0026dptr)) {\n+\t\tret = -1;\n+\t\tgoto update;\n+\t}\n+\n+\ttcb = bpf_core_cast(skb-\u003ecb, struct tcp_skb_cb);\n+\tseq = tcb-\u003eseq;\n+\tend_seq = tcb-\u003eend_seq - !!(tcb-\u003etcp_flags \u0026 TCPHDR_FIN);\n+\n+\tLOG(\"Start parsing skb: seq: %u, end_seq: %u, len: %u, rpc_desc_seq: %u, rpc_end_seq: %u, rpc_buff_len: %u\",\n+\t SEQ(seq), SEQ(end_seq), end_seq - seq,\n+\t CB_SEQ(rpc_desc_seq), CB_SEQ(rpc_end_seq), cb-\u003erpc_desc_buff_len);\n+\n+\tif (cb-\u003erpc_desc_buff_len != RPC_DESC_SIZE) {\n+\t\tret = tcp_parse_descriptor(cb, \u0026dptr, seq, end_seq);\n+\t\tif (ret)\n+\t\t\tgoto update;\n+\t}\n+\n+\ti = 0;\n+\n+\twhile (1) {\n+\t\tif (i++ \u003e MAX_RPC_DESC_PER_SKB) {\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (after(cb-\u003erpc_end_seq, end_seq)) {\n+\t\t\tLOG(\"No more descriptor: rpc_end_seq: %u, end_seq: %u\",\n+\t\t\t CB_SEQ(rpc_end_seq), SEQ(end_seq));\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcb-\u003erpc_desc_seq = cb-\u003erpc_end_seq;\n+\t\tcb-\u003erpc_desc_buff_len = 0;\n+\n+\t\tif (cb-\u003erpc_end_seq == end_seq)\n+\t\t\tbreak;\n+\n+\t\tLOG(\"Found next descriptor: rpc_end_seq: %u, end_seq: %u, len: %u\",\n+\t\t CB_SEQ(rpc_end_seq), SEQ(end_seq), end_seq - cb-\u003erpc_end_seq);\n+\n+\t\tret = tcp_parse_descriptor(cb, \u0026dptr, seq, end_seq);\n+\t\tif (ret)\n+\t\t\tbreak;\n+\t}\n+\n+update:\n+\tif (ret \u003e= 0)\n+\t\ttcp_set_autolowat(cb, sk);\n+\telse\n+\t\ttcp_disable_autolowat(sk);\n+}\n+\n+SEC(\"struct_ops\")\n+void BPF_PROG(tcp_autolowat_enqueue_rcvq, struct sock *sk, struct sk_buff *skb)\n+{\n+\tstruct tcp_autolowat_cb *cb;\n+\n+\tcb = bpf_sk_storage_get(\u0026tcp_autolowat_map, sk, 0, 0);\n+\tif (!cb)\n+\t\treturn;\n+\n+\ttcp_do_autolowat(cb, sk, skb);\n+}\n+\n+SEC(\"struct_ops\")\n+void BPF_PROG(tcp_autolowat_dequeue_rcvq, struct sock *sk)\n+{\n+\tstruct tcp_autolowat_cb *cb;\n+\n+\tcb = bpf_sk_storage_get(\u0026tcp_autolowat_map, sk, 0, 0);\n+\tif (!cb)\n+\t\treturn;\n+\n+\ttcp_set_autolowat(cb, sk);\n+}\n+\n+SEC(\".struct_ops.link\")\n+struct bpf_tcp_ops tcp_autolowat_ops = {\n+\t.enqueue_rcvq = (void *)tcp_autolowat_enqueue_rcvq,\n+\t.dequeue_rcvq = (void *)tcp_autolowat_dequeue_rcvq,\n+};\n+\n+static int tcp_init_autolowat_cb(struct bpf_sockopt *sockopt,\n+\t\t\t\t struct bpf_tcp_sock *btp)\n+{\n+\tstruct tcp_autolowat_cb *cb;\n+\tstruct tcp_sock *tp;\n+\tint flags;\n+\n+\tcb = bpf_sk_storage_get(\u0026tcp_autolowat_map, btp, 0,\n+\t\t\t\tBPF_SK_STORAGE_GET_F_CREATE);\n+\tif (!cb)\n+\t\treturn -1;\n+\n+\ttp = bpf_core_cast(btp, struct tcp_sock);\n+\tif (!tp)\n+\t\treturn -1;\n+\n+\tcb-\u003erpc_desc_seq = tp-\u003ecopied_seq;\n+\tcb-\u003erpc_end_seq = tp-\u003ecopied_seq;\n+#ifdef DEBUG\n+\tcb-\u003eisn = tp-\u003ecopied_seq;\n+#endif\n+\n+\tif (bpf_getsockopt(sockopt-\u003esk, SOL_TCP, TCP_BPF_SOCK_OPS_CB_FLAGS,\n+\t\t\t \u0026flags, sizeof(flags)))\n+\t\treturn -1;\n+\n+\tflags |= BPF_SOCK_OPS_RCVQ_CB_FLAG;\n+\n+\tif (bpf_setsockopt(sockopt-\u003esk, SOL_TCP, TCP_BPF_SOCK_OPS_CB_FLAGS,\n+\t\t\t \u0026flags, sizeof(flags)))\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+SEC(\"cgroup/setsockopt\")\n+int tcp_autolowat_setsockopt(struct bpf_sockopt *ctx)\n+{\n+\tvoid *optval_end = ctx-\u003eoptval_end;\n+\tint *optval = ctx-\u003eoptval;\n+\tstruct bpf_tcp_sock *btp;\n+\n+\tif (ctx-\u003elevel != SOL_BPF || ctx-\u003eoptname != BPF_TCP_AUTOLOWAT)\n+\t\tgoto out;\n+\n+\tif (optval + 1 \u003e optval_end)\n+\t\treturn 0; /* -EPERM */\n+\n+\tbtp = bpf_tcp_sock(ctx-\u003esk);\n+\tif (!btp)\n+\t\tgoto out;\n+\n+\tif (*optval \u0026\u0026 tcp_init_autolowat_cb(ctx, btp))\n+\t\treturn 0; /* -EPERM */\n+\n+\t/*\n+\t * BPF has consumed this option, don't call kernel\n+\t * setsockopt handler.\n+\t */\n+\tctx-\u003eoptlen = -1;\n+out:\n+\treturn 1;\n+}\n+\n+char _license[] SEC(\"license\") = \"GPL\";\ndiff --git a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c\nindex 6935f32eeb8fd..e30cb1fab0790 100644\n--- a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c\n+++ b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c\n@@ -92,7 +92,8 @@ int bpf_testcb(struct bpf_sock_ops *skops)\n \t\tbreak;\n \tcase BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:\n \t\t/* Test failure to set largest cb flag (assumes not defined) */\n-\t\tglobal.bad_cb_test_rv = bpf_sock_ops_cb_flags_set(skops, 0x80);\n+\t\tglobal.bad_cb_test_rv = bpf_sock_ops_cb_flags_set(skops,\n+\t\t\t\t\t\t\t\t BPF_SOCK_OPS_ALL_CB_FLAGS + 1);\n \t\t/* Set callback */\n \t\tglobal.good_cb_test_rv = bpf_sock_ops_cb_flags_set(skops,\n \t\t\t\t\t\t BPF_SOCK_OPS_STATE_CB_FLAG);\n"
} |
| 2/1 | 2026/09/26 03:06 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": [
"INET",
"BPF_SYSCALL",
"BPF_JIT",
"CGROUP_BPF",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"bpf_tcp_ops_set_rcvlowat",
"bpf_tcp_ops_cb_flags_set",
"bpf_tcp_ops_rcvlowat_kfunc_filter",
"__tcp_set_rcvlowat",
"tcp_set_rcvlowat",
"bpf_sock_ops_cb_flags_set",
"bpf_sol_tcp_setsockopt",
"tcp_fastopen_add_skb"
],
"Reasoning": "The patch modifies core TCP stack and BPF logic by introducing new BPF struct_ops callbacks (enqueue_rcvq, dequeue_rcvq) triggered during TCP receive queue enqueue and dequeue events, a new BPF callback flag (BPF_SOCK_OPS_RCVQ_CB_FLAG), a new BPF helper (bpf_tcp_ops_cb_flags_set), a new kfunc (bpf_tcp_ops_set_rcvlowat), and refactoring TCP rcvlowat handling (__tcp_set_rcvlowat) with selective wakeup suppression. These changes are in reachable core networking/BPF paths and warrant fuzzing to identify potential races, lockdep violations, or assertion failures.",
"WorthFuzzing": true
}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 aae1221aa43202109cc11e718b161f41f4587711
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Sep 26 03:06:07 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/net/tcp.h b/include/net/tcp.h
index d61ee00052e33..d3cf655da9ecd 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -512,6 +512,7 @@ void tcp_set_keepalive(struct sock *sk, int val);
void tcp_syn_ack_timeout(const struct request_sock *req);
int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int flags);
+int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup);
int tcp_set_rcvlowat(struct sock *sk, int val);
void tcp_set_rcvbuf(struct sock *sk, int val);
int tcp_set_window_clamp(struct sock *sk, int val);
@@ -2931,6 +2932,16 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2,
return tcp_call_bpf(sk, op, 3, args);
}
+static inline int tcp_set_sock_ops_cb_flags(struct sock *sk, int val)
+{
+ if (sk_is_mptcp(sk) &&
+ (val & BPF_SOCK_OPS_RCVQ_CB_FLAG))
+ return -EOPNOTSUPP;
+
+ tcp_sk(sk)->bpf_sock_ops_cb_flags = val;
+ return 0;
+}
+
static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk)
{
tcp_sk(sk)->bpf_sock_ops_cb_flags = 0;
@@ -2953,6 +2964,11 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2,
return -EPERM;
}
+static inline int tcp_set_sock_ops_cb_flags(struct sock *sk, int val)
+{
+ return -EOPNOTSUPP;
+}
+
static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk)
{
}
@@ -3053,6 +3069,12 @@ struct bpf_tcp_ops {
struct request_sock *req, struct sk_buff *syn_skb,
enum tcp_synack_type synack_type,
u32 opt_off);
+
+ /* Called when an incoming skb is enqueued to sk->sk_receive_queue. */
+ void (*enqueue_rcvq)(struct sock *sk, struct sk_buff *skb);
+
+ /* Called after data is dequeued from sk->sk_receive_queue. */
+ void (*dequeue_rcvq)(struct sock *sk);
};
#define bpf_tcp_ops_call(op, sk, ...) \
@@ -3144,6 +3166,18 @@ static inline void tcp_bpf_rtt(struct sock *sk, long mrtt, u32 srtt)
bpf_tcp_ops_call(rtt, sk, mrtt, srtt);
}
+static inline void bpf_tcp_ops_enqueue_rcvq(struct sock *sk, struct sk_buff *skb)
+{
+ if (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RCVQ_CB_FLAG))
+ bpf_tcp_ops_call(enqueue_rcvq, sk, skb);
+}
+
+static inline void bpf_tcp_ops_dequeue_rcvq(struct sock *sk)
+{
+ if (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RCVQ_CB_FLAG))
+ bpf_tcp_ops_call(dequeue_rcvq, sk);
+}
+
#if IS_ENABLED(CONFIG_SMC)
extern struct static_key_false tcp_have_smc;
#endif
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 6330b7d745c57..8cdf22667775f 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -3264,7 +3264,7 @@ union bpf_attr {
* Return
* 0
*
- * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)
+ * long bpf_sock_ops_cb_flags_set(void *bpf_sock, int argval)
* Description
* Attempt to set the value of the **bpf_sock_ops_cb_flags** field
* for the full TCP socket associated to *bpf_sock_ops* to
@@ -7148,8 +7148,17 @@ enum {
* options first before the BPF program does.
*/
BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1<<6),
+ /* Call bpf when the TCP stack enqueues/dequeues payload
+ * to/from sk->sk_receive_queue.
+ *
+ * Only bpf_tcp_ops is supported.
+ *
+ * It can be used to adjust sk->sk_rcvlowat and suppress
+ * unnecessary wakeups before sufficient data is available.
+ */
+ BPF_SOCK_OPS_RCVQ_CB_FLAG = (1<<7),
/* Mask of all currently supported cb flags */
- BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
+ BPF_SOCK_OPS_ALL_CB_FLAGS = 0xFF,
};
enum {
diff --git a/net/core/filter.c b/net/core/filter.c
index 5feb998846825..f29c061bb0664 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5588,8 +5588,7 @@ static int bpf_sol_tcp_setsockopt(struct sock *sk, int optname,
case TCP_BPF_SOCK_OPS_CB_FLAGS:
if (val & ~(BPF_SOCK_OPS_ALL_CB_FLAGS))
return -EINVAL;
- tp->bpf_sock_ops_cb_flags = val;
- break;
+ return tcp_set_sock_ops_cb_flags(sk, val);
default:
return -EINVAL;
}
@@ -6178,8 +6177,9 @@ static const struct bpf_func_proto bpf_sock_ops_getsockopt_proto = {
BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock,
int, argval)
{
- struct sock *sk = bpf_sock->sk;
int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS;
+ struct sock *sk = bpf_sock->sk;
+ int err;
if (!is_locked_tcp_sock_ops(bpf_sock))
return -EOPNOTSUPP;
@@ -6187,7 +6187,9 @@ BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock,
if (!IS_ENABLED(CONFIG_INET) || !sk_fullsock(sk))
return -EINVAL;
- tcp_sk(sk)->bpf_sock_ops_cb_flags = val;
+ err = tcp_set_sock_ops_cb_flags(sk, val);
+ if (err)
+ return err;
return argval & (~BPF_SOCK_OPS_ALL_CB_FLAGS);
}
diff --git a/net/ipv4/bpf_tcp_ops.c b/net/ipv4/bpf_tcp_ops.c
index 681fed6429999..e93c8d13684ef 100644
--- a/net/ipv4/bpf_tcp_ops.c
+++ b/net/ipv4/bpf_tcp_ops.c
@@ -76,6 +76,14 @@ static void write_hdr_opt_stub(struct sock *sk, struct sk_buff *skb,
{
}
+static void enqueue_rcvq_stub(struct sock *sk, struct sk_buff *skb)
+{
+}
+
+static void dequeue_rcvq_stub(struct sock *sk)
+{
+}
+
static struct bpf_tcp_ops __bpf_tcp_ops = {
.timeout_init = timeout_init_stub,
.rwnd_init = rwnd_init_stub,
@@ -90,6 +98,8 @@ static struct bpf_tcp_ops __bpf_tcp_ops = {
.parse_hdr = parse_hdr_stub,
.hdr_opt_len = hdr_opt_len_stub,
.write_hdr_opt = write_hdr_opt_stub,
+ .enqueue_rcvq = enqueue_rcvq_stub,
+ .dequeue_rcvq = dequeue_rcvq_stub,
};
BPF_CALL_4(bpf_tcp_ops_store_hdr_opt, void *, ctx, const void *, from,
@@ -210,6 +220,45 @@ const struct bpf_func_proto bpf_tcp_ops_get_retval_proto = {
.ret_type = RET_INTEGER,
};
+BPF_CALL_2(bpf_tcp_ops_cb_flags_set, struct sock *, sk, int, argval)
+{
+ int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS;
+ int err;
+
+ err = tcp_set_sock_ops_cb_flags(sk, val);
+ if (err)
+ return err;
+
+ return argval & ~BPF_SOCK_OPS_ALL_CB_FLAGS;
+}
+
+static const struct bpf_func_proto bpf_tcp_ops_cb_flags_set_proto = {
+ .func = bpf_tcp_ops_cb_flags_set,
+ .gpl_only = false,
+ .ret_type = RET_INTEGER,
+ .arg1_type = ARG_PTR_TO_BTF_ID,
+ .arg1_btf_id = &btf_sock_ids[BTF_SOCK_TYPE_TCP],
+ .arg2_type = ARG_ANYTHING,
+};
+
+static bool is_sockopt_supported(u32 moff)
+{
+ switch (moff) {
+ case offsetof(struct bpf_tcp_ops, active_established):
+ case offsetof(struct bpf_tcp_ops, passive_established):
+ case offsetof(struct bpf_tcp_ops, rto):
+ case offsetof(struct bpf_tcp_ops, rtt):
+ case offsetof(struct bpf_tcp_ops, set_state):
+ case offsetof(struct bpf_tcp_ops, retrans):
+ case offsetof(struct bpf_tcp_ops, connect):
+ case offsetof(struct bpf_tcp_ops, listen):
+ case offsetof(struct bpf_tcp_ops, parse_hdr):
+ return true;
+ }
+
+ return false;
+}
+
static const struct bpf_func_proto *
get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
{
@@ -221,22 +270,13 @@ get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
case BPF_FUNC_sk_storage_delete:
return &bpf_sk_storage_delete_proto;
case BPF_FUNC_setsockopt:
- /* The sk may be an unlocked listener (synack path) or NULL
- * fullsock; disable for members that can run unlocked.
- */
- if (moff == offsetof(struct bpf_tcp_ops, rwnd_init) ||
- moff == offsetof(struct bpf_tcp_ops, timeout_init) ||
- moff == offsetof(struct bpf_tcp_ops, hdr_opt_len) ||
- moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))
- return NULL;
- return &bpf_sk_setsockopt_proto;
+ if (is_sockopt_supported(moff))
+ return &bpf_sk_setsockopt_proto;
+ return NULL;
case BPF_FUNC_getsockopt:
- if (moff == offsetof(struct bpf_tcp_ops, rwnd_init) ||
- moff == offsetof(struct bpf_tcp_ops, timeout_init) ||
- moff == offsetof(struct bpf_tcp_ops, hdr_opt_len) ||
- moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))
- return NULL;
- return &bpf_sk_getsockopt_proto;
+ if (is_sockopt_supported(moff))
+ return &bpf_sk_getsockopt_proto;
+ return NULL;
case BPF_FUNC_get_retval:
if (moff == offsetof(struct bpf_tcp_ops, timeout_init) ||
moff == offsetof(struct bpf_tcp_ops, rwnd_init))
@@ -255,6 +295,15 @@ get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
if (moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))
return &bpf_tcp_ops_store_hdr_opt_proto;
return NULL;
+ case BPF_FUNC_sock_ops_cb_flags_set:
+ if (moff == offsetof(struct bpf_tcp_ops, connect) ||
+ moff == offsetof(struct bpf_tcp_ops, listen) ||
+ moff == offsetof(struct bpf_tcp_ops, active_established) ||
+ moff == offsetof(struct bpf_tcp_ops, passive_established) ||
+ moff == offsetof(struct bpf_tcp_ops, enqueue_rcvq) ||
+ moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))
+ return &bpf_tcp_ops_cb_flags_set_proto;
+ return NULL;
default:
return bpf_base_func_proto(func_id, prog);
}
@@ -319,8 +368,62 @@ static struct bpf_struct_ops bpf_tcp_ops = {
.owner = THIS_MODULE,
};
+__bpf_kfunc_start_defs();
+
+__bpf_kfunc int bpf_tcp_ops_set_rcvlowat(struct sock *sk, int rcvlowat,
+ const struct bpf_prog_aux *aux)
+{
+ u32 moff = aux->attach_st_ops_member_off;
+ bool wakeup = false;
+
+ if (moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))
+ wakeup = true;
+
+ if (rcvlowat < 0)
+ rcvlowat = INT_MAX;
+
+ return __tcp_set_rcvlowat(sk, rcvlowat, wakeup);
+}
+
+__bpf_kfunc_end_defs();
+
+BTF_KFUNCS_START(bpf_tcp_ops_rcvlowat_kfunc_set)
+BTF_ID_FLAGS(func, bpf_tcp_ops_set_rcvlowat, KF_IMPLICIT_ARGS)
+BTF_KFUNCS_END(bpf_tcp_ops_rcvlowat_kfunc_set)
+
+static int bpf_tcp_ops_rcvlowat_kfunc_filter(const struct bpf_prog *prog,
+ u32 kfunc_id)
+{
+ u32 moff;
+
+ if (!btf_id_set8_contains(&bpf_tcp_ops_rcvlowat_kfunc_set, kfunc_id))
+ return 0;
+
+ if (prog->aux->st_ops != &bpf_tcp_ops)
+ return -EACCES;
+
+ moff = prog->aux->attach_st_ops_member_off;
+ if (moff != offsetof(struct bpf_tcp_ops, enqueue_rcvq) &&
+ moff != offsetof(struct bpf_tcp_ops, dequeue_rcvq))
+ return -EACCES;
+
+ return 0;
+}
+
+static const struct btf_kfunc_id_set bpf_tcp_ops_rcvlowat_kfunc_id_set = {
+ .owner = THIS_MODULE,
+ .set = &bpf_tcp_ops_rcvlowat_kfunc_set,
+ .filter = bpf_tcp_ops_rcvlowat_kfunc_filter,
+};
+
static int __init __bpf_tcp_ops_init(void)
{
- return register_bpf_struct_ops(&bpf_tcp_ops, bpf_tcp_ops);
+ int ret;
+
+ ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
+ &bpf_tcp_ops_rcvlowat_kfunc_id_set);
+ ret = ret ?: register_bpf_struct_ops(&bpf_tcp_ops, bpf_tcp_ops);
+
+ return ret;
}
late_initcall(__bpf_tcp_ops_init);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index a4456b4194122..aa7593fc8334e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1610,6 +1610,8 @@ void tcp_cleanup_rbuf(struct sock *sk, int copied)
"cleanup rbuf bug: copied %X seq %X rcvnxt %X\n",
tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);
__tcp_cleanup_rbuf(sk, copied);
+
+ bpf_tcp_ops_dequeue_rcvq(sk);
}
static void tcp_eat_recv_skb(struct sock *sk, struct sk_buff *skb)
@@ -1826,8 +1828,7 @@ int tcp_peek_len(struct socket *sock)
return tcp_inq(sock->sk);
}
-/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */
-int tcp_set_rcvlowat(struct sock *sk, int val)
+int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup)
{
struct tcp_sock *tp = tcp_sk(sk);
int space, cap;
@@ -1840,7 +1841,8 @@ int tcp_set_rcvlowat(struct sock *sk, int val)
WRITE_ONCE(sk->sk_rcvlowat, val ? : 1);
/* Check if we need to signal EPOLLIN right now */
- tcp_data_ready(sk);
+ if (wakeup)
+ tcp_data_ready(sk);
if (sk->sk_userlocks & SOCK_RCVBUF_LOCK)
return 0;
@@ -1855,6 +1857,12 @@ int tcp_set_rcvlowat(struct sock *sk, int val)
return 0;
}
+/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */
+int tcp_set_rcvlowat(struct sock *sk, int val)
+{
+ return __tcp_set_rcvlowat(sk, val, true);
+}
+
void tcp_set_rcvbuf(struct sock *sk, int val)
{
tcp_set_window_clamp(sk, tcp_win_from_space(sk, val));
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 471c78be55137..4939bcbc81d17 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -281,6 +281,8 @@ void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb)
TCP_SKB_CB(skb)->seq++;
TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_SYN;
+ bpf_tcp_ops_enqueue_rcvq(sk, skb);
+
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
tcp_add_receive_queue(sk, skb);
tp->syn_data_acked = 1;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 6ac6f9d5b6c38..c60c61bb0a715 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5344,6 +5344,8 @@ static void tcp_ofo_queue(struct sock *sk)
continue;
}
+ bpf_tcp_ops_enqueue_rcvq(sk, skb);
+
tail = skb_peek_tail(&sk->sk_receive_queue);
eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
@@ -5547,6 +5549,8 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb,
int eaten;
struct sk_buff *tail = skb_peek_tail(&sk->sk_receive_queue);
+ bpf_tcp_ops_enqueue_rcvq(sk, skb);
+
eaten = (tail &&
tcp_try_coalesce(sk, tail,
skb, fragstolen)) ? 1 : 0;
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 6330b7d745c57..8cdf22667775f 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -3264,7 +3264,7 @@ union bpf_attr {
* Return
* 0
*
- * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)
+ * long bpf_sock_ops_cb_flags_set(void *bpf_sock, int argval)
* Description
* Attempt to set the value of the **bpf_sock_ops_cb_flags** field
* for the full TCP socket associated to *bpf_sock_ops* to
@@ -7148,8 +7148,17 @@ enum {
* options first before the BPF program does.
*/
BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1<<6),
+ /* Call bpf when the TCP stack enqueues/dequeues payload
+ * to/from sk->sk_receive_queue.
+ *
+ * Only bpf_tcp_ops is supported.
+ *
+ * It can be used to adjust sk->sk_rcvlowat and suppress
+ * unnecessary wakeups before sufficient data is available.
+ */
+ BPF_SOCK_OPS_RCVQ_CB_FLAG = (1<<7),
/* Mask of all currently supported cb flags */
- BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
+ BPF_SOCK_OPS_ALL_CB_FLAGS = 0xFF,
};
enum {
diff --git a/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c b/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c
new file mode 100644
index 0000000000000..337f9d34a39c5
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c
@@ -0,0 +1,350 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright 2026 Google LLC */
+#include <sys/epoll.h>
+
+#include "test_progs.h"
+#include "cgroup_helpers.h"
+#include "network_helpers.h"
+
+#include "tcp_autolowat.skel.h"
+
+#define SOL_BPF 0xdeadbeef
+#define BPF_TCP_AUTOLOWAT 0x8badf00d
+
+struct rpc_descriptor {
+ u32 header_len;
+ u32 payload_len;
+};
+
+enum rpc_event_type {
+ RPC_EVENT_END,
+ RPC_EVENT_AUTOLOWAT,
+ RPC_EVENT_SEND,
+ RPC_EVENT_RECV,
+ RPC_EVENT_EPOLL,
+ RPC_EVENT_RCVLOWAT,
+};
+
+struct rpc_event {
+ enum rpc_event_type type;
+ union {
+ int len;
+ int nfds;
+ int val;
+ int rcvlowat;
+ };
+};
+
+#define RPC_DESC_SIZE (sizeof(struct rpc_descriptor))
+
+static struct rpc_test_case {
+ char data[4096];
+ struct rpc_descriptor desc[32];
+ struct rpc_event event[32];
+} rpc_test_cases[] = {
+ {
+ .desc = {
+ { .header_len = 100, .payload_len = 150 },
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* Single full RPC message in skb. */
+ { .type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE + 100 + 150},
+ { .type = RPC_EVENT_EPOLL, .nfds = 1},
+ { .type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 100 + 150},
+ },
+ },
+ {
+ .desc = {
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* Two full RPC messages in skb. */
+ {.type = RPC_EVENT_SEND, .len = (RPC_DESC_SIZE + 100 + 150) * 2},
+ {.type = RPC_EVENT_EPOLL, .nfds = 1},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},
+ /* Single full RPC message in skb. */
+ { .type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE + 100 + 150},
+ { .type = RPC_EVENT_EPOLL, .nfds = 1},
+ { .type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 3},
+ },
+ },
+ {
+ .desc = {
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* Two full RPC messages in skb. */
+ {.type = RPC_EVENT_SEND, .len = (RPC_DESC_SIZE + 100 + 150) * 2},
+ {.type = RPC_EVENT_EPOLL, .nfds = 1},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},
+ /* Only the next descriptor in skb. */
+ { .type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE},
+ { .type = RPC_EVENT_EPOLL, .nfds = 1},
+ { .type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},
+ },
+ },
+ {
+ .desc = {
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 200, .payload_len = 500},
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* The first descriptor is partial. */
+ {.type = RPC_EVENT_SEND, .len = 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE},
+ /* The first descriptor is available. */
+ {.type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE - 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 150 + 100},
+ /* The first header is ready. */
+ {.type = RPC_EVENT_SEND, .len = 100},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 150 + 100},
+ /* skb has the first payload and 1 byte of the next descriptor. */
+ {.type = RPC_EVENT_SEND, .len = 150 + 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 1},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 150 + 100},
+ /* After reading the first RPC message, SO_RCVLOWAT should be RPC_DESC_SIZE. */
+ {.type = RPC_EVENT_RECV, .len = RPC_DESC_SIZE + 150 + 100},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE},
+ /* The second descriptor is available. */
+ {.type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE - 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 200 + 500},
+ },
+ },
+};
+
+struct tcp_autolowat_test_cb {
+ int saved_netns;
+ union {
+ int fd[4];
+ struct {
+ int server, client, child;
+ int epoll;
+ };
+ };
+};
+
+static void tcp_autolowat_teardown_cb(struct tcp_autolowat_test_cb *cb)
+{
+ int i, err;
+
+ for (i = 0; i < ARRAY_SIZE(cb->fd); i++) {
+ if (cb->fd[i] != -1)
+ close(cb->fd[i]);
+ }
+
+ if (cb->saved_netns != -1) {
+ err = setns(cb->saved_netns, CLONE_NEWNET);
+ ASSERT_OK(err, "restore netns");
+
+ close(cb->saved_netns);
+ }
+}
+
+static int tcp_autolowat_setup_cb(struct tcp_autolowat_test_cb *cb, int family)
+{
+ struct epoll_event ev = {};
+ int err;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(cb->fd); i++)
+ cb->fd[i] = -1;
+
+ cb->saved_netns = open("/proc/self/ns/net", O_RDONLY);
+ if (!ASSERT_OK_FD(cb->saved_netns, "save netns"))
+ goto err;
+
+ err = unshare(CLONE_NEWNET);
+ if (!ASSERT_OK(err, "unshare"))
+ goto err;
+
+ err = system("ip link set dev lo up");
+ if (!ASSERT_OK(err, "set up lo"))
+ goto err;
+
+ cb->server = start_server(family, SOCK_STREAM, NULL, 0, 0);
+ if (!ASSERT_OK_FD(cb->server, "start_server"))
+ goto err;
+
+ cb->client = connect_to_fd(cb->server, 0);
+ if (!ASSERT_OK_FD(cb->client, "connect_to_fd"))
+ goto err;
+
+ cb->child = accept(cb->server, NULL, NULL);
+ if (!ASSERT_OK_FD(cb->child, "accept"))
+ goto err;
+
+ cb->epoll = epoll_create1(0);
+ if (!ASSERT_OK_FD(cb->epoll, "epoll_create"))
+ goto err;
+
+ ev.events = EPOLLIN;
+ ev.data.fd = cb->child;
+
+ err = epoll_ctl(cb->epoll, EPOLL_CTL_ADD, cb->child, &ev);
+ if (!ASSERT_OK(err, "epoll_ctl"))
+ goto err;
+
+ return 0;
+
+err:
+ tcp_autolowat_teardown_cb(cb);
+ return -1;
+}
+
+static int tcp_autolowat_build_data(struct rpc_test_case *test_case)
+{
+ struct rpc_descriptor *desc = test_case->desc;
+ char *ptr = test_case->data;
+ int rpc_size;
+
+ memset(ptr, 0, sizeof(test_case->data));
+
+ while (desc->header_len + desc->payload_len) {
+ rpc_size = sizeof(*desc) + desc->header_len + desc->payload_len;
+
+ if (!ASSERT_LE(ptr + rpc_size - test_case->data,
+ sizeof(test_case->data), "data overflow"))
+ return 1;
+
+ memcpy(ptr, desc, sizeof(*desc));
+ ptr += rpc_size;
+ desc++;
+ }
+
+ if (!ASSERT_GT(ptr - test_case->data, 0, "no data"))
+ return 1;
+
+ return 0;
+}
+
+static void tcp_autolowat_run_rpc_test(struct tcp_autolowat_test_cb *cb,
+ struct rpc_test_case *test_case)
+{
+ struct rpc_event *event = test_case->event;
+ char *ptr = test_case->data;
+ struct epoll_event ev;
+ socklen_t optlen;
+ int err, optval;
+ char buf[4096];
+
+ if (tcp_autolowat_build_data(test_case))
+ return;
+
+ while (1) {
+ switch (event->type) {
+ case RPC_EVENT_END:
+ return;
+ case RPC_EVENT_AUTOLOWAT:
+ err = setsockopt(cb->child, SOL_BPF, BPF_TCP_AUTOLOWAT,
+ &event->val, sizeof(event->val));
+ if (!ASSERT_OK(err, "setsockopt"))
+ return;
+ break;
+ case RPC_EVENT_SEND:
+ err = send(cb->client, ptr, event->len, 0);
+ if (!ASSERT_EQ(err, event->len, "send"))
+ return;
+
+ ptr += event->len;
+ break;
+ case RPC_EVENT_RECV:
+ err = recv(cb->child, buf, event->len, 0);
+ if (!ASSERT_EQ(err, event->len, "recv"))
+ return;
+ break;
+ case RPC_EVENT_EPOLL:
+ err = epoll_wait(cb->epoll, &ev, 1, 100);
+ if (!ASSERT_EQ(err, event->nfds, "epoll_wait"))
+ return;
+ break;
+ case RPC_EVENT_RCVLOWAT:
+ optval = 0;
+ optlen = sizeof(optval);
+
+ err = getsockopt(cb->child, SOL_SOCKET, SO_RCVLOWAT, &optval, &optlen);
+ if (!ASSERT_OK(err, "getsockopt") ||
+ !ASSERT_EQ(optval, event->rcvlowat, "rcvlowat"))
+ return;
+ break;
+ }
+
+ event++;
+ }
+}
+
+static void tcp_autolowat_run_rpc_tests(struct tcp_autolowat *skel, int family)
+{
+ struct tcp_autolowat_test_cb cb;
+ int err;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(rpc_test_cases); i++) {
+ memset(skel->bss->test_name, 0, sizeof(skel->bss->test_name));
+
+ snprintf(skel->bss->test_name, sizeof(skel->bss->test_name),
+ "AF_INET%c rpc_test_cases[%d]",
+ family == AF_INET ? ' ' : '6', i);
+
+ if (!test__start_subtest(skel->bss->test_name))
+ continue;
+
+ err = tcp_autolowat_setup_cb(&cb, family);
+ if (err)
+ continue;
+
+ tcp_autolowat_run_rpc_test(&cb, &rpc_test_cases[i]);
+ tcp_autolowat_teardown_cb(&cb);
+ }
+}
+
+static void tcp_autolowat_run_tests(struct tcp_autolowat *skel)
+{
+ tcp_autolowat_run_rpc_tests(skel, AF_INET);
+ tcp_autolowat_run_rpc_tests(skel, AF_INET6);
+}
+
+void test_tcp_autolowat(void)
+{
+ struct tcp_autolowat *skel;
+ struct bpf_link *link[2];
+ int cgroup;
+
+ skel = tcp_autolowat__open_and_load();
+ if (!ASSERT_OK_PTR(skel, "open_and_load"))
+ return;
+
+ cgroup = test__join_cgroup("/tcp_autolowat");
+ if (!ASSERT_GE(cgroup, 0, "join_cgroup"))
+ goto destroy_skel;
+
+ link[0] = bpf_map__attach_cgroup_opts(skel->maps.tcp_autolowat_ops, cgroup, NULL);
+ if (!ASSERT_OK_PTR(link[0], "attach_cgroup(tcp_autolowat_ops)"))
+ goto close_cgroup;
+
+ link[1] = bpf_program__attach_cgroup(skel->progs.tcp_autolowat_setsockopt, cgroup);
+ if (!ASSERT_OK_PTR(link[1], "attach_cgroup(SETSOCKOPT)"))
+ goto destroy_sockops;
+
+ tcp_autolowat_run_tests(skel);
+
+ bpf_link__destroy(link[1]);
+destroy_sockops:
+ bpf_link__destroy(link[0]);
+close_cgroup:
+ close(cgroup);
+destroy_skel:
+ tcp_autolowat__destroy(skel);
+}
diff --git a/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c b/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c
index 7e8fe1bad03f5..e4849d2a2956f 100644
--- a/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c
+++ b/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c
@@ -26,7 +26,8 @@ static void verify_result(struct tcpbpf_globals *result)
ASSERT_EQ(result->bytes_acked, 1002, "bytes_acked");
ASSERT_EQ(result->data_segs_in, 1, "data_segs_in");
ASSERT_EQ(result->data_segs_out, 1, "data_segs_out");
- ASSERT_EQ(result->bad_cb_test_rv, 0x80, "bad_cb_test_rv");
+ ASSERT_EQ(result->bad_cb_test_rv, BPF_SOCK_OPS_ALL_CB_FLAGS + 1,
+ "bad_cb_test_rv");
ASSERT_EQ(result->good_cb_test_rv, 0, "good_cb_test_rv");
ASSERT_EQ(result->num_listen, 1, "num_listen");
diff --git a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
index 593b38f904174..4c999d59cbbce 100644
--- a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
+++ b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
@@ -79,6 +79,8 @@
#define NEXTHDR_TCP 6
+#define TCPHDR_FIN 0x01
+
#define TCPOPT_NOP 1
#define TCPOPT_EOL 0
#define TCPOPT_MSS 2
diff --git a/tools/testing/selftests/bpf/progs/tcp_autolowat.c b/tools/testing/selftests/bpf/progs/tcp_autolowat.c
new file mode 100644
index 0000000000000..4fe7bdc98e69f
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/tcp_autolowat.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright 2026 Google LLC */
+#include "vmlinux.h"
+
+#include <string.h>
+#include <limits.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+#include <bpf/bpf_core_read.h>
+
+#include "bpf_kfuncs.h"
+#include "bpf_tracing_net.h"
+
+#define SOL_BPF 0xdeadbeef
+#define BPF_TCP_AUTOLOWAT 0x8badf00d
+
+//#define DEBUG /* For verbose output. */
+
+struct rpc_descriptor {
+ u32 header_len;
+ u32 payload_len;
+};
+
+#define RPC_DESC_SIZE (sizeof(struct rpc_descriptor))
+#define MAX_RPC_DESC_PER_SKB 100
+
+struct tcp_autolowat_cb {
+ /* Don't put this field at the end; BPF verifier complains. */
+ char rpc_desc_buf[RPC_DESC_SIZE];
+ u32 rpc_desc_seq;
+ u32 rpc_end_seq;
+#ifdef DEBUG
+ u32 isn;
+#endif
+ u8 rpc_desc_buff_len;
+};
+
+struct {
+ __uint(type, BPF_MAP_TYPE_SK_STORAGE);
+ __uint(map_flags, BPF_F_NO_PREALLOC);
+ __type(key, int);
+ __type(value, struct tcp_autolowat_cb);
+} tcp_autolowat_map SEC(".maps");
+
+char test_name[64];
+
+#ifdef DEBUG
+#define LOG(str, ...) \
+ bpf_printk("%s: " str, test_name, ##__VA_ARGS__)
+#else
+#define LOG(...)
+#endif
+
+#define SEQ(val) \
+ (val - cb->isn)
+#define TP_SEQ(field) \
+ (tp->field - cb->isn)
+#define CB_SEQ(field) \
+ (cb->field - cb->isn)
+
+static int tcp_parse_descriptor(struct tcp_autolowat_cb *cb,
+ struct bpf_dynptr *dptr,
+ u32 seq, u32 end_seq)
+{
+ struct rpc_descriptor *rpc_desc;
+ u32 rpc_copied_seq;
+ u64 copy_len; /* u32 should work, but not for no_alu32 :/ */
+ u64 rpc_len;
+ int err;
+
+ rpc_copied_seq = cb->rpc_desc_seq + cb->rpc_desc_buff_len;
+
+ if (before(cb->rpc_desc_seq + RPC_DESC_SIZE, end_seq))
+ copy_len = RPC_DESC_SIZE - cb->rpc_desc_buff_len;
+ else
+ copy_len = end_seq - rpc_copied_seq;
+
+ if (copy_len == 0)
+ goto disable; /* FIN. */
+ if (copy_len > RPC_DESC_SIZE)
+ goto disable; /* always false, only for verifier. */
+ if (cb->rpc_desc_buff_len >= RPC_DESC_SIZE)
+ goto disable; /* always false, only for verifier. */
+
+ err = bpf_dynptr_read(cb->rpc_desc_buf + cb->rpc_desc_buff_len,
+ copy_len, dptr, rpc_copied_seq - seq, 0);
+ if (err)
+ goto disable;
+
+ cb->rpc_desc_buff_len += copy_len;
+
+ if (cb->rpc_desc_buff_len != RPC_DESC_SIZE) {
+ LOG("Copied %d bytes: rpc_desc_buff_len: %u", copy_len, cb->rpc_desc_buff_len);
+ goto partial;
+ }
+
+ rpc_desc = (struct rpc_descriptor *)cb->rpc_desc_buf;
+ rpc_len = RPC_DESC_SIZE + rpc_desc->header_len + rpc_desc->payload_len;
+
+ if (rpc_len > INT_MAX)
+ goto disable;
+
+ cb->rpc_end_seq = cb->rpc_desc_seq + rpc_len;
+
+ LOG("Copied full descriptor: rpc_desc_seq: %u, rpc_end_seq: %u, header_len: %u, payload_len: %u",
+ CB_SEQ(rpc_desc_seq), CB_SEQ(rpc_end_seq),
+ rpc_desc->header_len, rpc_desc->payload_len);
+
+ return 0;
+disable:
+ return -1;
+partial:
+ return 1;
+}
+
+static void tcp_set_autolowat(struct tcp_autolowat_cb *cb,
+ struct sock *sk)
+{
+ struct tcp_sock *tp = (struct tcp_sock *)sk;
+ u32 val; /* To handle wraparound. */
+
+ LOG("Setting rcvlowat: tp->copied_seq: %u, rpc_desc_seq: %u, rpc_end_seq: %u, rpc_desc_buff_len: %u",
+ TP_SEQ(copied_seq), CB_SEQ(rpc_desc_seq),
+ CB_SEQ(rpc_end_seq), cb->rpc_desc_buff_len);
+
+ if (before(tp->copied_seq, cb->rpc_desc_seq))
+ val = cb->rpc_desc_seq - tp->copied_seq;
+ else if (cb->rpc_desc_buff_len != RPC_DESC_SIZE)
+ val = RPC_DESC_SIZE;
+ else
+ val = cb->rpc_end_seq - tp->copied_seq;
+
+ if (val != tp->inet_conn.icsk_inet.sk.sk_rcvlowat) {
+ bpf_tcp_ops_set_rcvlowat(sk, val);
+
+ LOG("Set rcvlowat: expected: %u, actual: %d\n",
+ val, tp->inet_conn.icsk_inet.sk.sk_rcvlowat);
+ } else {
+ LOG("No need to set rcvlowat: %u\n", val);
+ }
+}
+
+static void tcp_disable_autolowat(struct sock *sk)
+{
+ struct tcp_sock *tp = (struct tcp_sock *)sk;
+ int flags;
+
+ flags = tp->bpf_sock_ops_cb_flags & ~BPF_SOCK_OPS_RCVQ_CB_FLAG;
+ bpf_sock_ops_cb_flags_set(sk, flags);
+
+ bpf_tcp_ops_set_rcvlowat(sk, 1);
+
+ LOG("Disabled autolowat");
+}
+
+static void tcp_do_autolowat(struct tcp_autolowat_cb *cb,
+ struct sock *sk, struct sk_buff *skb)
+{
+ struct bpf_dynptr dptr;
+ struct tcp_skb_cb *tcb;
+ u32 seq, end_seq;
+ int ret = 0, i;
+
+ if (bpf_dynptr_from_skb((struct __sk_buff *)skb, 0, &dptr)) {
+ ret = -1;
+ goto update;
+ }
+
+ tcb = bpf_core_cast(skb->cb, struct tcp_skb_cb);
+ seq = tcb->seq;
+ end_seq = tcb->end_seq - !!(tcb->tcp_flags & TCPHDR_FIN);
+
+ LOG("Start parsing skb: seq: %u, end_seq: %u, len: %u, rpc_desc_seq: %u, rpc_end_seq: %u, rpc_buff_len: %u",
+ SEQ(seq), SEQ(end_seq), end_seq - seq,
+ CB_SEQ(rpc_desc_seq), CB_SEQ(rpc_end_seq), cb->rpc_desc_buff_len);
+
+ if (cb->rpc_desc_buff_len != RPC_DESC_SIZE) {
+ ret = tcp_parse_descriptor(cb, &dptr, seq, end_seq);
+ if (ret)
+ goto update;
+ }
+
+ i = 0;
+
+ while (1) {
+ if (i++ > MAX_RPC_DESC_PER_SKB) {
+ ret = -1;
+ break;
+ }
+
+ if (after(cb->rpc_end_seq, end_seq)) {
+ LOG("No more descriptor: rpc_end_seq: %u, end_seq: %u",
+ CB_SEQ(rpc_end_seq), SEQ(end_seq));
+ break;
+ }
+
+ cb->rpc_desc_seq = cb->rpc_end_seq;
+ cb->rpc_desc_buff_len = 0;
+
+ if (cb->rpc_end_seq == end_seq)
+ break;
+
+ LOG("Found next descriptor: rpc_end_seq: %u, end_seq: %u, len: %u",
+ CB_SEQ(rpc_end_seq), SEQ(end_seq), end_seq - cb->rpc_end_seq);
+
+ ret = tcp_parse_descriptor(cb, &dptr, seq, end_seq);
+ if (ret)
+ break;
+ }
+
+update:
+ if (ret >= 0)
+ tcp_set_autolowat(cb, sk);
+ else
+ tcp_disable_autolowat(sk);
+}
+
+SEC("struct_ops")
+void BPF_PROG(tcp_autolowat_enqueue_rcvq, struct sock *sk, struct sk_buff *skb)
+{
+ struct tcp_autolowat_cb *cb;
+
+ cb = bpf_sk_storage_get(&tcp_autolowat_map, sk, 0, 0);
+ if (!cb)
+ return;
+
+ tcp_do_autolowat(cb, sk, skb);
+}
+
+SEC("struct_ops")
+void BPF_PROG(tcp_autolowat_dequeue_rcvq, struct sock *sk)
+{
+ struct tcp_autolowat_cb *cb;
+
+ cb = bpf_sk_storage_get(&tcp_autolowat_map, sk, 0, 0);
+ if (!cb)
+ return;
+
+ tcp_set_autolowat(cb, sk);
+}
+
+SEC(".struct_ops.link")
+struct bpf_tcp_ops tcp_autolowat_ops = {
+ .enqueue_rcvq = (void *)tcp_autolowat_enqueue_rcvq,
+ .dequeue_rcvq = (void *)tcp_autolowat_dequeue_rcvq,
+};
+
+static int tcp_init_autolowat_cb(struct bpf_sockopt *sockopt,
+ struct bpf_tcp_sock *btp)
+{
+ struct tcp_autolowat_cb *cb;
+ struct tcp_sock *tp;
+ int flags;
+
+ cb = bpf_sk_storage_get(&tcp_autolowat_map, btp, 0,
+ BPF_SK_STORAGE_GET_F_CREATE);
+ if (!cb)
+ return -1;
+
+ tp = bpf_core_cast(btp, struct tcp_sock);
+ if (!tp)
+ return -1;
+
+ cb->rpc_desc_seq = tp->copied_seq;
+ cb->rpc_end_seq = tp->copied_seq;
+#ifdef DEBUG
+ cb->isn = tp->copied_seq;
+#endif
+
+ if (bpf_getsockopt(sockopt->sk, SOL_TCP, TCP_BPF_SOCK_OPS_CB_FLAGS,
+ &flags, sizeof(flags)))
+ return -1;
+
+ flags |= BPF_SOCK_OPS_RCVQ_CB_FLAG;
+
+ if (bpf_setsockopt(sockopt->sk, SOL_TCP, TCP_BPF_SOCK_OPS_CB_FLAGS,
+ &flags, sizeof(flags)))
+ return -1;
+
+ return 0;
+}
+
+SEC("cgroup/setsockopt")
+int tcp_autolowat_setsockopt(struct bpf_sockopt *ctx)
+{
+ void *optval_end = ctx->optval_end;
+ int *optval = ctx->optval;
+ struct bpf_tcp_sock *btp;
+
+ if (ctx->level != SOL_BPF || ctx->optname != BPF_TCP_AUTOLOWAT)
+ goto out;
+
+ if (optval + 1 > optval_end)
+ return 0; /* -EPERM */
+
+ btp = bpf_tcp_sock(ctx->sk);
+ if (!btp)
+ goto out;
+
+ if (*optval && tcp_init_autolowat_cb(ctx, btp))
+ return 0; /* -EPERM */
+
+ /*
+ * BPF has consumed this option, don't call kernel
+ * setsockopt handler.
+ */
+ ctx->optlen = -1;
+out:
+ return 1;
+}
+
+char _license[] SEC("license") = "GPL";
diff --git a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
index 6935f32eeb8fd..e30cb1fab0790 100644
--- a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
@@ -92,7 +92,8 @@ int bpf_testcb(struct bpf_sock_ops *skops)
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
/* Test failure to set largest cb flag (assumes not defined) */
- global.bad_cb_test_rv = bpf_sock_ops_cb_flags_set(skops, 0x80);
+ global.bad_cb_test_rv = bpf_sock_ops_cb_flags_set(skops,
+ BPF_SOCK_OPS_ALL_CB_FLAGS + 1);
/* Set callback */
global.good_cb_test_rv = bpf_sock_ops_cb_flags_set(skops,
BPF_SOCK_OPS_STATE_CB_FLAG);
|
| 3/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18228 output: 30 thoughts: 792 Thoughts: **Analyzing This Patch: A Deep Dive into TCP and BPF Integration** Okay, so this patch is making some pretty significant changes, and my initial assessment screams "Worth Fuzzing!" It's definitely touching core stuff - TCP and BPF, which are foundational to modern networking stacks, and that *always* gets my attention. Let's break down my thought process: The patch is directly modifying TCP and BPF code, specifically: * **TCP Header (include/net/tcp.h):** It's adding functions like `__tcp_set_rcvlowat` and `tcp_set_sock_ops_cb_flags`, along with function pointers for enqueuing and dequeuing receive queue data (`enqueue_rcvq`, `dequeue_rcvq`) to the `bpf_tcp_ops` structure. This immediately flags as a potential for complex interactions with TCP's congestion control and flow control mechanisms, which are prime fuzzing targets. * **BPF Header (include/uapi/linux/bpf.h):** This is modifying BPF control flags. The addition of `BPF_SOCK_OPS_RCVQ_CB_FLAG` and updates to `BPF_SOCK_OPS_ALL_CB_FLAGS` indicates a tightening of BPF control over socket operations related to receive queue management. * **Filter and Core (net/core/filter.c):** Functions like `bpf_sol_tcp_setsockopt` and `bpf_sock_ops_cb_flags_set` are calling the new `tcp_set_sock_ops_cb_flags`, which implies a hook to allow BPF programs to set or influence TCP socket behaviors via `setsockopt`. This is a big deal; BPF program interaction with sockets is a notorious source of bugs and security vulnerabilities. * **BPF TCP Operations (net/ipv4/bpf_tcp_ops.c):** This is where the magic happens. The patch adds stubs for `enqueue_rcvq` and `dequeue_rcvq` (which are essentially callbacks). There's a new `bpf_tcp_ops_set_rcvlowat` kfunc, and support for `BPF_FUNC_sock_ops_cb_flags_set`, meaning BPF programs can now directly set socket flags related to the receive buffer. * **TCP Core Logic (net/ipv4/tcp.c):** Here, we see `bpf_tcp_ops_dequeue_rcvq` being called during `tcp_cleanup_rbuf()`. This is particularly critical; `tcp_cleanup_rbuf()` is a central function in TCP's receive path. Additionally, `tcp_set_rcvlowat()` is being refactored to `__tcp_set_rcvlowat()`. * **TCP Fast Open and Input (net/ipv4/tcp_fastopen.c, net/ipv4/tcp_input.c):** We're seeing calls to `bpf_tcp_ops_enqueue_rcvq` in `tcp_fastopen_add_skb()`, `tcp_ofo_queue()`, and `tcp_queue_rcv()`. These functions are critical for handling out-of-order packets and general TCP input processing. This means BPF can now influence data queuing within *multiple* core TCP input paths. My immediate conclusion: the risk is high. This touches core networking (TCP) and BPF subsystems directly! These are areas known to have complex interactions. TCP sockets and BPF are standard in a virtualized environment, and therefore, definitely reachable code. We know syzkaller is constantly fuzzing these, so we're talking about targets that have a demonstrated history of vulnerabilities. Now, because of the core nature of these components, **WorthFuzzing = true** is a no-brainer. This patch is definitely triggering code within those subsystems. I'd consider it a critical area. Next steps: I need to carefully examine configuration options and relevant symbols. I'll need to check the files touched, `net/ipv4/bpf_tcp_ops.c`, `net/ipv4/tcp.c`, and `net/core/filter.c`, to see what config options control inclusion of the code and any dependencies. I'll use `grepper` or `read-file` to get the Makefile information for those files. |
| 4/2 | 2026/09/26 03:06 | tool | grepper |
0mArgs:{
"Expression": "bpf_tcp_ops",
"PathPrefix": "net/ipv4"
}Results: {
"Output": "net/ipv4/Makefile=72=obj-$(CONFIG_BPF_SYSCALL) += bpf_tcp_ca.o\nnet/ipv4/Makefile:73:obj-$(CONFIG_CGROUP_BPF) += bpf_tcp_ops.o\nnet/ipv4/Makefile-74-endif\n--\nnet/ipv4/af_inet.c=198=int __inet_listen_sk(struct sock *sk, int backlog)\n--\nnet/ipv4/af_inet.c-229-\t\ttcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL);\nnet/ipv4/af_inet.c:230:\t\tbpf_tcp_ops_call(listen, sk);\nnet/ipv4/af_inet.c-231-\t}\n--\nnet/ipv4/bpf_tcp_ops.c=83=static void dequeue_rcvq_stub(struct sock *sk)\n--\nnet/ipv4/bpf_tcp_ops.c-86-\nnet/ipv4/bpf_tcp_ops.c:87:static struct bpf_tcp_ops __bpf_tcp_ops = {\nnet/ipv4/bpf_tcp_ops.c-88-\t.timeout_init = timeout_init_stub,\n--\nnet/ipv4/bpf_tcp_ops.c-104-\nnet/ipv4/bpf_tcp_ops.c:105:BPF_CALL_4(bpf_tcp_ops_store_hdr_opt, void *, ctx, const void *, from,\nnet/ipv4/bpf_tcp_ops.c-106-\t u32, len, u64, flags)\n--\nnet/ipv4/bpf_tcp_ops.c-114-\t/*\nnet/ipv4/bpf_tcp_ops.c:115:\t * bpf_tcp_ops does not keep track of the end of the written TCP header\nnet/ipv4/bpf_tcp_ops.c-116-\t * options, so search for it every time the helper is called. The free\n--\nnet/ipv4/bpf_tcp_ops.c-134-\nnet/ipv4/bpf_tcp_ops.c:135:static const struct bpf_func_proto bpf_tcp_ops_store_hdr_opt_proto = {\nnet/ipv4/bpf_tcp_ops.c:136:\t.func\t\t= bpf_tcp_ops_store_hdr_opt,\nnet/ipv4/bpf_tcp_ops.c-137-\t.gpl_only\t= false,\n--\nnet/ipv4/bpf_tcp_ops.c-144-\nnet/ipv4/bpf_tcp_ops.c:145:BPF_CALL_4(bpf_tcp_ops_load_hdr_opt, void *, ctx, void *, search_res,\nnet/ipv4/bpf_tcp_ops.c-146-\t u32, len, u64, flags)\n--\nnet/ipv4/bpf_tcp_ops.c-153-\t * No flags supported. In particular BPF_LOAD_HDR_OPT_TCP_SYN, which\nnet/ipv4/bpf_tcp_ops.c:154:\t * loads from the saved SYN, is not available because bpf_tcp_ops has no\nnet/ipv4/bpf_tcp_ops.c-155-\t * carrier to track the SYN source across the hooks.\n--\nnet/ipv4/bpf_tcp_ops.c-165-\nnet/ipv4/bpf_tcp_ops.c:166:static const struct bpf_func_proto bpf_tcp_ops_load_hdr_opt_proto = {\nnet/ipv4/bpf_tcp_ops.c:167:\t.func\t\t= bpf_tcp_ops_load_hdr_opt,\nnet/ipv4/bpf_tcp_ops.c-168-\t.gpl_only\t= false,\n--\nnet/ipv4/bpf_tcp_ops.c-175-\nnet/ipv4/bpf_tcp_ops.c:176:BPF_CALL_3(bpf_tcp_ops_reserve_hdr_opt, void *, ctx, u32, len, u64, flags)\nnet/ipv4/bpf_tcp_ops.c-177-{\n--\nnet/ipv4/bpf_tcp_ops.c-190-\nnet/ipv4/bpf_tcp_ops.c:191:static const struct bpf_func_proto bpf_tcp_ops_reserve_hdr_opt_proto = {\nnet/ipv4/bpf_tcp_ops.c:192:\t.func\t\t= bpf_tcp_ops_reserve_hdr_opt,\nnet/ipv4/bpf_tcp_ops.c-193-\t.gpl_only\t= false,\n--\nnet/ipv4/bpf_tcp_ops.c-199-\nnet/ipv4/bpf_tcp_ops.c:200:BPF_CALL_0(bpf_tcp_ops_get_retval)\nnet/ipv4/bpf_tcp_ops.c-201-{\n--\nnet/ipv4/bpf_tcp_ops.c-205-\t/* bpf_get_retval() is only exposed to timeout_init/rwnd_init, which\nnet/ipv4/bpf_tcp_ops.c:206:\t * always run via bpf_tcp_ops_call_int(). Its run_ctx carries the int\nnet/ipv4/bpf_tcp_ops.c:207:\t * return value chained across the bpf_tcp_ops attached to the cgroup\nnet/ipv4/bpf_tcp_ops.c-208-\t * and is this program's saved_run_ctx.\n--\nnet/ipv4/bpf_tcp_ops.c-216-\nnet/ipv4/bpf_tcp_ops.c:217:const struct bpf_func_proto bpf_tcp_ops_get_retval_proto = {\nnet/ipv4/bpf_tcp_ops.c:218:\t.func\t\t= bpf_tcp_ops_get_retval,\nnet/ipv4/bpf_tcp_ops.c-219-\t.gpl_only\t= false,\n--\nnet/ipv4/bpf_tcp_ops.c-222-\nnet/ipv4/bpf_tcp_ops.c:223:BPF_CALL_2(bpf_tcp_ops_cb_flags_set, struct sock *, sk, int, argval)\nnet/ipv4/bpf_tcp_ops.c-224-{\n--\nnet/ipv4/bpf_tcp_ops.c-234-\nnet/ipv4/bpf_tcp_ops.c:235:static const struct bpf_func_proto bpf_tcp_ops_cb_flags_set_proto = {\nnet/ipv4/bpf_tcp_ops.c:236:\t.func\t\t= bpf_tcp_ops_cb_flags_set,\nnet/ipv4/bpf_tcp_ops.c-237-\t.gpl_only\t= false,\n--\nnet/ipv4/bpf_tcp_ops.c=244=static bool is_sockopt_supported(u32 moff)\n--\nnet/ipv4/bpf_tcp_ops.c-246-\tswitch (moff) {\nnet/ipv4/bpf_tcp_ops.c:247:\tcase offsetof(struct bpf_tcp_ops, active_established):\nnet/ipv4/bpf_tcp_ops.c:248:\tcase offsetof(struct bpf_tcp_ops, passive_established):\nnet/ipv4/bpf_tcp_ops.c:249:\tcase offsetof(struct bpf_tcp_ops, rto):\nnet/ipv4/bpf_tcp_ops.c:250:\tcase offsetof(struct bpf_tcp_ops, rtt):\nnet/ipv4/bpf_tcp_ops.c:251:\tcase offsetof(struct bpf_tcp_ops, set_state):\nnet/ipv4/bpf_tcp_ops.c:252:\tcase offsetof(struct bpf_tcp_ops, retrans):\nnet/ipv4/bpf_tcp_ops.c:253:\tcase offsetof(struct bpf_tcp_ops, connect):\nnet/ipv4/bpf_tcp_ops.c:254:\tcase offsetof(struct bpf_tcp_ops, listen):\nnet/ipv4/bpf_tcp_ops.c:255:\tcase offsetof(struct bpf_tcp_ops, parse_hdr):\nnet/ipv4/bpf_tcp_ops.c-256-\t\treturn true;\n--\nnet/ipv4/bpf_tcp_ops.c=263=get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)\n--\nnet/ipv4/bpf_tcp_ops.c-280-\tcase BPF_FUNC_get_retval:\nnet/ipv4/bpf_tcp_ops.c:281:\t\tif (moff == offsetof(struct bpf_tcp_ops, timeout_init) ||\nnet/ipv4/bpf_tcp_ops.c:282:\t\t moff == offsetof(struct bpf_tcp_ops, rwnd_init))\nnet/ipv4/bpf_tcp_ops.c:283:\t\t\treturn \u0026bpf_tcp_ops_get_retval_proto;\nnet/ipv4/bpf_tcp_ops.c-284-\t\treturn NULL;\nnet/ipv4/bpf_tcp_ops.c-285-\tcase BPF_FUNC_reserve_hdr_opt:\nnet/ipv4/bpf_tcp_ops.c:286:\t\tif (moff == offsetof(struct bpf_tcp_ops, hdr_opt_len))\nnet/ipv4/bpf_tcp_ops.c:287:\t\t\treturn \u0026bpf_tcp_ops_reserve_hdr_opt_proto;\nnet/ipv4/bpf_tcp_ops.c-288-\t\treturn NULL;\nnet/ipv4/bpf_tcp_ops.c-289-\tcase BPF_FUNC_load_hdr_opt:\nnet/ipv4/bpf_tcp_ops.c:290:\t\tif (moff == offsetof(struct bpf_tcp_ops, parse_hdr) ||\nnet/ipv4/bpf_tcp_ops.c:291:\t\t moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))\nnet/ipv4/bpf_tcp_ops.c:292:\t\t\treturn \u0026bpf_tcp_ops_load_hdr_opt_proto;\nnet/ipv4/bpf_tcp_ops.c-293-\t\treturn NULL;\nnet/ipv4/bpf_tcp_ops.c-294-\tcase BPF_FUNC_store_hdr_opt:\nnet/ipv4/bpf_tcp_ops.c:295:\t\tif (moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))\nnet/ipv4/bpf_tcp_ops.c:296:\t\t\treturn \u0026bpf_tcp_ops_store_hdr_opt_proto;\nnet/ipv4/bpf_tcp_ops.c-297-\t\treturn NULL;\nnet/ipv4/bpf_tcp_ops.c-298-\tcase BPF_FUNC_sock_ops_cb_flags_set:\nnet/ipv4/bpf_tcp_ops.c:299:\t\tif (moff == offsetof(struct bpf_tcp_ops, connect) ||\nnet/ipv4/bpf_tcp_ops.c:300:\t\t moff == offsetof(struct bpf_tcp_ops, listen) ||\nnet/ipv4/bpf_tcp_ops.c:301:\t\t moff == offsetof(struct bpf_tcp_ops, active_established) ||\nnet/ipv4/bpf_tcp_ops.c:302:\t\t moff == offsetof(struct bpf_tcp_ops, passive_established) ||\nnet/ipv4/bpf_tcp_ops.c:303:\t\t moff == offsetof(struct bpf_tcp_ops, enqueue_rcvq) ||\nnet/ipv4/bpf_tcp_ops.c:304:\t\t moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))\nnet/ipv4/bpf_tcp_ops.c:305:\t\t\treturn \u0026bpf_tcp_ops_cb_flags_set_proto;\nnet/ipv4/bpf_tcp_ops.c-306-\t\treturn NULL;\n--\nnet/ipv4/bpf_tcp_ops.c=312=static bool is_valid_access(int off, int size, enum bpf_access_type type,\n--\nnet/ipv4/bpf_tcp_ops.c-326-\nnet/ipv4/bpf_tcp_ops.c:327:static int bpf_tcp_ops_init_member(const struct btf_type *t,\nnet/ipv4/bpf_tcp_ops.c-328-\t\t\t\t const struct btf_member *member,\n--\nnet/ipv4/bpf_tcp_ops.c-333-\nnet/ipv4/bpf_tcp_ops.c:334:static int bpf_tcp_ops_check_member(const struct btf_type *t,\nnet/ipv4/bpf_tcp_ops.c-335-\t\t\t\t const struct btf_member *member,\n--\nnet/ipv4/bpf_tcp_ops.c-343-\nnet/ipv4/bpf_tcp_ops.c:344:static int bpf_tcp_ops_init(struct btf *btf)\nnet/ipv4/bpf_tcp_ops.c-345-{\n--\nnet/ipv4/bpf_tcp_ops.c-348-\nnet/ipv4/bpf_tcp_ops.c:349:static int bpf_tcp_ops_validate(void *kdata)\nnet/ipv4/bpf_tcp_ops.c-350-{\n--\nnet/ipv4/bpf_tcp_ops.c-353-\nnet/ipv4/bpf_tcp_ops.c:354:static const struct bpf_verifier_ops bpf_tcp_ops_verifier = {\nnet/ipv4/bpf_tcp_ops.c-355-\t.get_func_proto\t\t= get_func_proto,\n--\nnet/ipv4/bpf_tcp_ops.c-358-\nnet/ipv4/bpf_tcp_ops.c:359:static struct bpf_struct_ops bpf_tcp_ops = {\nnet/ipv4/bpf_tcp_ops.c:360:\t.verifier_ops = \u0026bpf_tcp_ops_verifier,\nnet/ipv4/bpf_tcp_ops.c:361:\t.init_member = bpf_tcp_ops_init_member,\nnet/ipv4/bpf_tcp_ops.c:362:\t.check_member = bpf_tcp_ops_check_member,\nnet/ipv4/bpf_tcp_ops.c:363:\t.init = bpf_tcp_ops_init,\nnet/ipv4/bpf_tcp_ops.c:364:\t.validate = bpf_tcp_ops_validate,\nnet/ipv4/bpf_tcp_ops.c:365:\t.name = \"bpf_tcp_ops\",\nnet/ipv4/bpf_tcp_ops.c-366-\t.cgroup_atype = CGROUP_TCP_SOCK_OPS,\nnet/ipv4/bpf_tcp_ops.c:367:\t.cfi_stubs = \u0026__bpf_tcp_ops,\nnet/ipv4/bpf_tcp_ops.c-368-\t.owner = THIS_MODULE,\n--\nnet/ipv4/bpf_tcp_ops.c=371=__bpf_kfunc_start_defs();\nnet/ipv4/bpf_tcp_ops.c-372-\nnet/ipv4/bpf_tcp_ops.c:373:__bpf_kfunc int bpf_tcp_ops_set_rcvlowat(struct sock *sk, int rcvlowat,\nnet/ipv4/bpf_tcp_ops.c-374-\t\t\t\t\t const struct bpf_prog_aux *aux)\n--\nnet/ipv4/bpf_tcp_ops.c-378-\nnet/ipv4/bpf_tcp_ops.c:379:\tif (moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))\nnet/ipv4/bpf_tcp_ops.c-380-\t\twakeup = true;\n--\nnet/ipv4/bpf_tcp_ops.c=388=__bpf_kfunc_end_defs();\nnet/ipv4/bpf_tcp_ops.c-389-\nnet/ipv4/bpf_tcp_ops.c:390:BTF_KFUNCS_START(bpf_tcp_ops_rcvlowat_kfunc_set)\nnet/ipv4/bpf_tcp_ops.c:391:BTF_ID_FLAGS(func, bpf_tcp_ops_set_rcvlowat, KF_IMPLICIT_ARGS)\nnet/ipv4/bpf_tcp_ops.c:392:BTF_KFUNCS_END(bpf_tcp_ops_rcvlowat_kfunc_set)\nnet/ipv4/bpf_tcp_ops.c-393-\nnet/ipv4/bpf_tcp_ops.c:394:static int bpf_tcp_ops_rcvlowat_kfunc_filter(const struct bpf_prog *prog,\nnet/ipv4/bpf_tcp_ops.c-395-\t\t\t\t\t u32 kfunc_id)\n--\nnet/ipv4/bpf_tcp_ops.c-398-\nnet/ipv4/bpf_tcp_ops.c:399:\tif (!btf_id_set8_contains(\u0026bpf_tcp_ops_rcvlowat_kfunc_set, kfunc_id))\nnet/ipv4/bpf_tcp_ops.c-400-\t\treturn 0;\nnet/ipv4/bpf_tcp_ops.c-401-\nnet/ipv4/bpf_tcp_ops.c:402:\tif (prog-\u003eaux-\u003est_ops != \u0026bpf_tcp_ops)\nnet/ipv4/bpf_tcp_ops.c-403-\t\treturn -EACCES;\n--\nnet/ipv4/bpf_tcp_ops.c-405-\tmoff = prog-\u003eaux-\u003eattach_st_ops_member_off;\nnet/ipv4/bpf_tcp_ops.c:406:\tif (moff != offsetof(struct bpf_tcp_ops, enqueue_rcvq) \u0026\u0026\nnet/ipv4/bpf_tcp_ops.c:407:\t moff != offsetof(struct bpf_tcp_ops, dequeue_rcvq))\nnet/ipv4/bpf_tcp_ops.c-408-\t\treturn -EACCES;\n--\nnet/ipv4/bpf_tcp_ops.c-412-\nnet/ipv4/bpf_tcp_ops.c:413:static const struct btf_kfunc_id_set bpf_tcp_ops_rcvlowat_kfunc_id_set = {\nnet/ipv4/bpf_tcp_ops.c-414-\t.owner = THIS_MODULE,\nnet/ipv4/bpf_tcp_ops.c:415:\t.set = \u0026bpf_tcp_ops_rcvlowat_kfunc_set,\nnet/ipv4/bpf_tcp_ops.c:416:\t.filter = bpf_tcp_ops_rcvlowat_kfunc_filter,\nnet/ipv4/bpf_tcp_ops.c-417-};\nnet/ipv4/bpf_tcp_ops.c-418-\nnet/ipv4/bpf_tcp_ops.c:419:static int __init __bpf_tcp_ops_init(void)\nnet/ipv4/bpf_tcp_ops.c-420-{\n--\nnet/ipv4/bpf_tcp_ops.c-423-\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nnet/ipv4/bpf_tcp_ops.c:424:\t\t\t\t\t\u0026bpf_tcp_ops_rcvlowat_kfunc_id_set);\nnet/ipv4/bpf_tcp_ops.c:425:\tret = ret ?: register_bpf_struct_ops(\u0026bpf_tcp_ops, bpf_tcp_ops);\nnet/ipv4/bpf_tcp_ops.c-426-\n--\nnet/ipv4/bpf_tcp_ops.c-428-}\nnet/ipv4/bpf_tcp_ops.c:429:late_initcall(__bpf_tcp_ops_init);\n--\nnet/ipv4/tcp.c=1604=void tcp_cleanup_rbuf(struct sock *sk, int copied)\n--\nnet/ipv4/tcp.c-1613-\nnet/ipv4/tcp.c:1614:\tbpf_tcp_ops_dequeue_rcvq(sk);\nnet/ipv4/tcp.c-1615-}\n--\nnet/ipv4/tcp.c=2969=void tcp_set_state(struct sock *sk, int state)\n--\nnet/ipv4/tcp.c-3007-\t\ttcp_call_bpf_2arg(sk, BPF_SOCK_OPS_STATE_CB, oldstate, state);\nnet/ipv4/tcp.c:3008:\tbpf_tcp_ops_call(set_state, sk, state);\nnet/ipv4/tcp.c-3009-\n--\nnet/ipv4/tcp_fastopen.c=257=void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/tcp_fastopen.c-283-\nnet/ipv4/tcp_fastopen.c:284:\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\nnet/ipv4/tcp_fastopen.c-285-\n--\nnet/ipv4/tcp_input.c=205=static void bpf_skops_established(struct sock *sk, int bpf_op,\n--\nnet/ipv4/tcp_input.c-210-\nnet/ipv4/tcp_input.c:211:static void bpf_tcp_ops_parse_hdr(struct sock *sk, struct sk_buff *skb)\nnet/ipv4/tcp_input.c-212-{\n--\nnet/ipv4/tcp_input.c-219-\nnet/ipv4/tcp_input.c:220:\tbpf_tcp_ops_call(parse_hdr, sk, skb);\nnet/ipv4/tcp_input.c-221-}\n--\nnet/ipv4/tcp_input.c=5318=static void tcp_ofo_queue(struct sock *sk)\n--\nnet/ipv4/tcp_input.c-5346-\nnet/ipv4/tcp_input.c:5347:\t\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\nnet/ipv4/tcp_input.c-5348-\n--\nnet/ipv4/tcp_input.c=5546=static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/tcp_input.c-5551-\nnet/ipv4/tcp_input.c:5552:\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\nnet/ipv4/tcp_input.c-5553-\n--\nnet/ipv4/tcp_input.c=6338=static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/tcp_input.c-6479-\tbpf_skops_parse_hdr(sk, skb);\nnet/ipv4/tcp_input.c:6480:\tbpf_tcp_ops_parse_hdr(sk, skb);\nnet/ipv4/tcp_input.c-6481-\n--\nnet/ipv4/tcp_input.c=6722=void tcp_init_transfer(struct sock *sk, int bpf_op, struct sk_buff *skb)\n--\nnet/ipv4/tcp_input.c-6744-\tif (bpf_op == BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB)\nnet/ipv4/tcp_input.c:6745:\t\tbpf_tcp_ops_call(active_established, sk, skb);\nnet/ipv4/tcp_input.c-6746-\telse\nnet/ipv4/tcp_input.c:6747:\t\tbpf_tcp_ops_call(passive_established, sk, skb);\nnet/ipv4/tcp_input.c-6748-\t/* Initialize congestion control unless BPF initialized it already: */\n--\nnet/ipv4/tcp_output.c=533=static void bpf_skops_write_hdr_opt(struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/tcp_output.c-579-\t/*\nnet/ipv4/tcp_output.c:580:\t * bpf_tcp_ops portion is NOP-filled (everything past the sockops\nnet/ipv4/tcp_output.c-581-\t * writer's bytes). The writer finds the append point by scanning from\n--\nnet/ipv4/tcp_output.c-583-\t */\nnet/ipv4/tcp_output.c:584:\tbpf_tcp_ops_call(write_hdr_opt, sk, skb, req, syn_skb, synack_type,\nnet/ipv4/tcp_output.c-585-\t\t\t first_opt_off + nr_written);\n--\nnet/ipv4/tcp_output.c=598=static void bpf_skops_write_hdr_opt(struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/tcp_output.c-606-\nnet/ipv4/tcp_output.c:607:static u32 bpf_tcp_ops_hdr_opt_len(struct sock *sk, struct sk_buff *skb,\nnet/ipv4/tcp_output.c-608-\t\t\t\t struct request_sock *req,\n--\nnet/ipv4/tcp_output.c-618-\nnet/ipv4/tcp_output.c:619:\t/* bpf_tcp_ops_reserve_hdr_opt() reserves space via remaining_out */\nnet/ipv4/tcp_output.c:620:\tbpf_tcp_ops_call(hdr_opt_len, sk, skb, req, syn_skb, synack_type, \u0026remaining_out);\nnet/ipv4/tcp_output.c-621-\n--\nnet/ipv4/tcp_output.c=995=static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/tcp_output.c-1091-\t\t\t\t\t remaining);\nnet/ipv4/tcp_output.c:1092:\tremaining = bpf_tcp_ops_hdr_opt_len(sk, skb, NULL, NULL, 0, opts,\nnet/ipv4/tcp_output.c-1093-\t\t\t\t\t remaining);\n--\nnet/ipv4/tcp_output.c=1099=static unsigned int tcp_synack_options(const struct sock *sk,\n--\nnet/ipv4/tcp_output.c-1181-\t\t\t\t\t synack_type, opts, remaining);\nnet/ipv4/tcp_output.c:1182:\tremaining = bpf_tcp_ops_hdr_opt_len((struct sock *)sk, skb, req, syn_skb,\nnet/ipv4/tcp_output.c-1183-\t\t\t\t\t synack_type, opts, remaining);\n--\nnet/ipv4/tcp_output.c=1191=static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/tcp_output.c-1290-\nnet/ipv4/tcp_output.c:1291:\t\tremaining = bpf_tcp_ops_hdr_opt_len(sk, skb, NULL, NULL, 0, opts,\nnet/ipv4/tcp_output.c-1292-\t\t\t\t\t\t remaining);\n--\nnet/ipv4/tcp_output.c=3600=int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)\n--\nnet/ipv4/tcp_output.c-3730-\t\t\t\t TCP_SKB_CB(skb)-\u003eseq, segs, err);\nnet/ipv4/tcp_output.c:3731:\tbpf_tcp_ops_call(retrans, sk, skb, err);\nnet/ipv4/tcp_output.c-3732-\n--\nnet/ipv4/tcp_output.c=4349=int tcp_connect(struct sock *sk)\n--\nnet/ipv4/tcp_output.c-4355-\ttcp_call_bpf(sk, BPF_SOCK_OPS_TCP_CONNECT_CB, 0, NULL);\nnet/ipv4/tcp_output.c:4356:\tbpf_tcp_ops_call(connect, sk);\nnet/ipv4/tcp_output.c-4357-\n--\nnet/ipv4/tcp_timer.c=243=static int tcp_write_timeout(struct sock *sk)\n--\nnet/ipv4/tcp_timer.c-292-\t\t\t\t icsk-\u003eicsk_rto, (int)expired);\nnet/ipv4/tcp_timer.c:293:\tbpf_tcp_ops_call(rto, sk);\nnet/ipv4/tcp_timer.c-294-\n"
} |
| 5/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27688 output: 33 thoughts: 57 Thoughts: Here's my summary, as if I were thinking it: **Digging into the Kernel Makefile Structure** Okay, so I'm looking at `net/ipv4/Makefile`. Specifically, I'm zeroing in on line 73: `obj-$(CONFIG_CGROUP_BPF) += bpf_tcp_ops.o`. This immediately tells me that the compilation of `bpf_tcp_ops.o` is conditionally included based on the `CONFIG_CGROUP_BPF` kernel configuration option. My immediate instinct is to get a broader picture; let's verify contextually around line 70. I need to understand what this conditional inclusion depends on in the grand scheme of things! |
| 6/2 | 2026/09/26 03:06 | tool | read-file |
0mArgs:{
"File": "net/ipv4/Makefile",
"FirstLine": 60,
"LineCount": 25
}Results: {
"Contents": " 60:\tobj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o\n 61:\tobj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o\n 62:\tobj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o\n 63:\tobj-$(CONFIG_NET_SOCK_MSG) += tcp_bpf.o\n 64:\tobj-$(CONFIG_BPF_SYSCALL) += udp_bpf.o\n 65:\tobj-$(CONFIG_NETLABEL) += cipso_ipv4.o\n 66:\t\n 67:\tobj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \\\n 68:\t\t\t xfrm4_output.o xfrm4_protocol.o\n 69:\tobj-$(CONFIG_TCP_AO) += tcp_ao.o\n 70:\t\n 71:\tifeq ($(CONFIG_BPF_JIT),y)\n 72:\tobj-$(CONFIG_BPF_SYSCALL) += bpf_tcp_ca.o\n 73:\tobj-$(CONFIG_CGROUP_BPF) += bpf_tcp_ops.o\n 74:\tendif\n 75:\t\n 76:\tifdef CONFIG_GCOV_PROFILE_NETFILTER\n 77:\tGCOV_PROFILE_netfilter.o := y\n 78:\tendif\n"
} |
| 7/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28312 output: 31 thoughts: 143 Thoughts: **Analyzing Kernel Build Configuration for BPF TCP Components** Okay, so I'm looking at this build configuration snippet, specifically lines 71-74. It's pretty straightforward, but I need to make sure I understand the dependencies completely. It seems that `bpf_tcp_ops.o` is conditionally included, dependent on `CONFIG_BPF_JIT` and `CONFIG_CGROUP_BPF`. Clearly, to get this object file built and linked, both of those options need to be enabled in the kernel config. I know `CONFIG_CGROUP_BPF` has some other dependencies too, like `CONFIG_CGROUPS` and `CONFIG_BPF_SYSCALL`, but those are usually implied if we're dealing with `CGROUP_BPF`. This seems to be the critical part for BPF TCP-related operations within cgroups. To be absolutely sure, I'll need to double-check the `Kconfig` files and make sure the relationships are exactly what I expect. I'll need to confirm that `CONFIG_CGROUP_BPF` indeed depends on the other options. Just a quick sanity check to be thorough. |
| 8/2 | 2026/09/26 03:06 | tool | grepper |
0mArgs:{
"Expression": "config CGROUP_BPF",
"PathPrefix": "init/Kconfig"
}Results: {
"Output": "init/Kconfig=1353=config CGROUP_PERF\n--\ninit/Kconfig-1363-\ninit/Kconfig:1364:config CGROUP_BPF\ninit/Kconfig-1365-\tbool \"Support for eBPF programs attached to cgroups\"\n"
} |
| 9/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28825 output: 33 thoughts: 17 Thoughts: Okay, let's dive into this. I'm going to pull up `init/Kconfig` and navigate to around line 1364. My objective is to quickly grasp the context of whatever is happening around that line. I'm looking for a specific configuration option, perhaps, or a related piece of code, but the *why* of this line is currently unknown. I'll read and analyze what the author has put. The surrounding context is important, so I'll be reading a few lines above and below to get the bigger picture. I'm going to see what's being defined, what dependencies are in play, and how it ties into the broader kernel configuration landscape. I'll be looking for any hints or indicators, but there is no specific goal yet. |
| 10/2 | 2026/09/26 03:06 | tool | read-file |
0mArgs:{
"File": "init/Kconfig",
"FirstLine": 1363,
"LineCount": 20
}Results: {
"Contents": "1363:\t\n1364:\tconfig CGROUP_BPF\n1365:\t\tbool \"Support for eBPF programs attached to cgroups\"\n1366:\t\tdepends on BPF_SYSCALL\n1367:\t\tselect SOCK_CGROUP_DATA\n1368:\t\thelp\n1369:\t\t Allow attaching eBPF programs to a cgroup using the bpf(2)\n1370:\t\t syscall command BPF_PROG_ATTACH.\n1371:\t\n1372:\t\t In which context these programs are accessed depends on the type\n1373:\t\t of attachment. For instance, programs that are attached using\n1374:\t\t BPF_CGROUP_INET_INGRESS will be executed on the ingress path of\n1375:\t\t inet sockets.\n1376:\t\n1377:\tconfig CGROUP_MISC\n1378:\t\tbool \"Misc resource controller\"\n1379:\t\tdefault n\n1380:\t\thelp\n1381:\t\t Provides a controller for miscellaneous resources on a host.\n1382:\t\n"
} |
| 11/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29334 output: 22 thoughts: 122 Thoughts: Okay, let me break this down. **Investigating `register_btf_kfunc_id_set` and BTF in relation to BPF struct operations.** My immediate thought is, "Ah, here we have something interesting regarding the registration of BTF kfunc IDs within the BPF framework." The mention of `register_btf_kfunc_id_set` and BTF specifically grabs my attention. I know these mechanisms are key to linking BPF programs with kernel functions, especially when dealing with structured data. Now, I see a specific instance in `net/ipv4/bpf_tcp_ops.c`. The code uses `register_btf_kfunc_id_set` with `BPF_PROG_TYPE_STRUCT_OPS`. This is important because it tells me the system is defining the function linkage. It's using BTF (the Binary Type Format) to provide information for these structure operations. I'm starting to build a mental map of this. The next step is clear. The snippet refers to `register_bpf_struct_ops`. I know there might be configuration dependencies involved, in particular, I want to verify if the configurations `CONFIG_BPF_SYSCALL` and `CONFIG_DEBUG_INFO_BTF` are required. Therefore, I'll need to check the definition of `BPF_STRUCT_OPS` and the implementation of `register_bpf_struct_ops`. I have to dig into the relevant kernel code and documentation to confirm my assumptions and uncover any potential subtleties or conditional behavior. Understanding these dependencies is crucial for any effective BPF program design and troubleshooting. |
| 12/2 | 2026/09/26 03:06 | tool | grepper |
0mArgs:{
"Expression": "register_bpf_struct_ops"
}Results: {
"Output": "drivers/hid/bpf/hid_bpf_struct_ops.c=337=static int __init hid_bpf_struct_ops_init(void)\ndrivers/hid/bpf/hid_bpf_struct_ops.c-338-{\ndrivers/hid/bpf/hid_bpf_struct_ops.c:339:\treturn register_bpf_struct_ops(\u0026bpf_hid_bpf_ops, hid_bpf_ops);\ndrivers/hid/bpf/hid_bpf_struct_ops.c-340-}\n--\nfs/binfmt_misc_bpf.c=430=static int __init bm_bpf_struct_ops_init(void)\nfs/binfmt_misc_bpf.c-431-{\nfs/binfmt_misc_bpf.c:432:\treturn register_bpf_struct_ops(\u0026bpf_binfmt_misc_ops, binfmt_misc_ops);\nfs/binfmt_misc_bpf.c-433-}\n--\ninclude/linux/bpf.h=2253=static inline bool is_struct_ops_tramp(const struct bpf_tramp_nodes *fentry_nodes)\n--\ninclude/linux/bpf.h-2261- * type information correctly. Developers should use this macro to register\ninclude/linux/bpf.h:2262: * a struct_ops type instead of calling __register_bpf_struct_ops() directly.\ninclude/linux/bpf.h-2263- */\ninclude/linux/bpf.h:2264:#define register_bpf_struct_ops(st_ops, type)\t\t\t\t\\\ninclude/linux/bpf.h-2265-\t({\t\t\t\t\t\t\t\t\\\n--\ninclude/linux/bpf.h-2270-\t\tBTF_TYPE_EMIT(struct bpf_struct_ops_##type);\t\t\\\ninclude/linux/bpf.h:2271:\t\t__register_bpf_struct_ops(st_ops);\t\t\t\\\ninclude/linux/bpf.h-2272-\t})\n--\ninclude/linux/bpf.h=2335=void bpf_struct_ops_desc_release(struct bpf_struct_ops_desc *st_ops_desc);\ninclude/linux/bpf.h-2336-#else\ninclude/linux/bpf.h:2337:#define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })\ninclude/linux/bpf.h-2338-static inline bool bpf_try_module_get(const void *data, struct module *owner)\n--\ninclude/linux/btf.h=540=struct bpf_struct_ops;\ninclude/linux/btf.h:541:int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops);\ninclude/linux/btf.h-542-const struct bpf_struct_ops_desc *bpf_struct_ops_find_value(struct btf *btf, u32 value_id);\n--\nio_uring/bpf-ops.c=263=static int __init io_uring_bpf_init(void)\n--\nio_uring/bpf-ops.c-266-\nio_uring/bpf-ops.c:267:\tret = register_bpf_struct_ops(\u0026bpf_ring_ops, io_uring_bpf_ops);\nio_uring/bpf-ops.c-268-\tif (ret) {\n--\nkernel/bpf/btf.c=10087=bpf_struct_ops_find(struct btf *btf, u32 type_id)\n--\nkernel/bpf/btf.c-10107-\nkernel/bpf/btf.c:10108:int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops)\nkernel/bpf/btf.c-10109-{\n--\nkernel/bpf/btf.c-10135-}\nkernel/bpf/btf.c:10136:EXPORT_SYMBOL_GPL(__register_bpf_struct_ops);\nkernel/bpf/btf.c-10137-#endif\n--\nkernel/sched/ext/ext.c=10898=static int __init scx_init(void)\n--\nkernel/sched/ext/ext.c-11018-\nkernel/sched/ext/ext.c:11019:\tret = register_bpf_struct_ops(\u0026bpf_sched_ext_ops, sched_ext_ops);\nkernel/sched/ext/ext.c-11020-\tif (ret) {\n--\nkernel/sched/ext/ext.c-11024-\nkernel/sched/ext/ext.c:11025:\tret = register_bpf_struct_ops(\u0026bpf_sched_ext_ops_cid, sched_ext_ops_cid);\nkernel/sched/ext/ext.c-11026-\tif (ret) {\n--\nnet/bpf/bpf_dummy_struct_ops.c=319=static int __init bpf_dummy_struct_ops_init(void)\nnet/bpf/bpf_dummy_struct_ops.c-320-{\nnet/bpf/bpf_dummy_struct_ops.c:321:\treturn register_bpf_struct_ops(\u0026bpf_bpf_dummy_ops, bpf_dummy_ops);\nnet/bpf/bpf_dummy_struct_ops.c-322-}\n--\nnet/ipv4/bpf_tcp_ca.c=361=static int __init bpf_tcp_ca_kfunc_init(void)\n--\nnet/ipv4/bpf_tcp_ca.c-365-\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026bpf_tcp_ca_kfunc_set);\nnet/ipv4/bpf_tcp_ca.c:366:\tret = ret ?: register_bpf_struct_ops(\u0026bpf_tcp_congestion_ops, tcp_congestion_ops);\nnet/ipv4/bpf_tcp_ca.c-367-\n--\nnet/ipv4/bpf_tcp_ops.c=419=static int __init __bpf_tcp_ops_init(void)\n--\nnet/ipv4/bpf_tcp_ops.c-424-\t\t\t\t\t\u0026bpf_tcp_ops_rcvlowat_kfunc_id_set);\nnet/ipv4/bpf_tcp_ops.c:425:\tret = ret ?: register_bpf_struct_ops(\u0026bpf_tcp_ops, bpf_tcp_ops);\nnet/ipv4/bpf_tcp_ops.c-426-\n--\nnet/sched/bpf_qdisc.c=458=static int __init bpf_qdisc_kfunc_init(void)\n--\nnet/sched/bpf_qdisc.c-471-\t\t\t\t\t\t THIS_MODULE);\nnet/sched/bpf_qdisc.c:472:\tret = ret ?: register_bpf_struct_ops(\u0026bpf_Qdisc_ops, Qdisc_ops);\nnet/sched/bpf_qdisc.c-473-\n--\nnet/smc/smc_hs_bpf.c=137=int bpf_smc_hs_ctrl_init(void)\nnet/smc/smc_hs_bpf.c-138-{\nnet/smc/smc_hs_bpf.c:139:\treturn register_bpf_struct_ops(\u0026bpf_smc_hs_ctrl_ops, smc_hs_ctrl);\nnet/smc/smc_hs_bpf.c-140-}\n--\ntools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c=59=static int bpf_test_no_cfi_init(void)\n--\ntools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c-62-\ntools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c:63:\tret = register_bpf_struct_ops(\u0026test_no_cif_ops,\ntools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c-64-\t\t\t\t bpf_test_no_cfi_ops);\n--\ntools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c-68-\ttest_no_cif_ops.cfi_stubs = \u0026__test_no_cif_ops;\ntools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c:69:\tret = register_bpf_struct_ops(\u0026test_no_cif_ops,\ntools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c-70-\t\t\t\t bpf_test_no_cfi_ops);\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c=2431=static int bpf_testmod_init(void)\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-2447-\tret = ret ?: register_btf_fmodret_id_set(\u0026bpf_testmod_trampoline_count_fmodret_set);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:2448:\tret = ret ?: register_bpf_struct_ops(\u0026bpf_bpf_testmod_ops, bpf_testmod_ops);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:2449:\tret = ret ?: register_bpf_struct_ops(\u0026bpf_testmod_ops2, bpf_testmod_ops2);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:2450:\tret = ret ?: register_bpf_struct_ops(\u0026bpf_testmod_ops3, bpf_testmod_ops3);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:2451:\tret = ret ?: register_bpf_struct_ops(\u0026testmod_st_ops, bpf_testmod_st_ops);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:2452:\tret = ret ?: register_bpf_struct_ops(\u0026testmod_multi_st_ops, bpf_testmod_multi_st_ops);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-2453-\tret = ret ?: register_btf_id_dtor_kfuncs(bpf_testmod_dtors,\n"
} |
| 13/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32636 output: 37 thoughts: 36 Thoughts: Here's my take on the thought process: **Diving into the BPF Core: Unveiling `__register_bpf_struct_ops`** Okay, so I need to understand what's enabling `__register_bpf_struct_ops`. I know it's a key function related to BPF structure operations, so understanding its lifecycle is crucial. Given that I'm dealing with kernel-level BPF, the logical starting point is the core definition. I should head straight to the source. Let's start with `include/linux/bpf.h`. A quick scan should help me zero in on where `__register_bpf_struct_ops` is declared, and hopefully, I'll find some clues around line 2253. That area is likely to be related to the registration logic, initializations, or maybe even related macros. I'm expecting to find some crucial pieces of the puzzle there. This is where the real BPF magic is likely being wired up to the kernel. Let's get to work. |
| 14/2 | 2026/09/26 03:06 | tool | read-file |
0mArgs:{
"File": "include/linux/bpf.h",
"FirstLine": 2240,
"LineCount": 40
}Results: {
"Contents": "2240:\t\tactive[rctx]--;\n2241:\t\tpreempt_enable();\n2242:\t#else\n2243:\t\tthis_cpu_dec(*(int __percpu *)(prog-\u003eactive));\n2244:\t#endif\n2245:\t}\n2246:\t\n2247:\tstatic inline bool is_tracing_multi(enum bpf_attach_type type)\n2248:\t{\n2249:\t\treturn type == BPF_TRACE_FENTRY_MULTI || type == BPF_TRACE_FEXIT_MULTI ||\n2250:\t\t type == BPF_TRACE_FSESSION_MULTI;\n2251:\t}\n2252:\t\n2253:\tstatic inline bool is_struct_ops_tramp(const struct bpf_tramp_nodes *fentry_nodes)\n2254:\t{\n2255:\t\treturn fentry_nodes-\u003enr_nodes == 1 \u0026\u0026\n2256:\t\t fentry_nodes-\u003enodes[0]-\u003elink-\u003etype == BPF_LINK_TYPE_STRUCT_OPS;\n2257:\t}\n2258:\t\n2259:\t#if defined(CONFIG_BPF_JIT) \u0026\u0026 defined(CONFIG_BPF_SYSCALL)\n2260:\t/* This macro helps developer to register a struct_ops type and generate\n2261:\t * type information correctly. Developers should use this macro to register\n2262:\t * a struct_ops type instead of calling __register_bpf_struct_ops() directly.\n2263:\t */\n2264:\t#define register_bpf_struct_ops(st_ops, type)\t\t\t\t\\\n2265:\t\t({\t\t\t\t\t\t\t\t\\\n2266:\t\t\tstruct bpf_struct_ops_##type {\t\t\t\t\\\n2267:\t\t\t\tstruct bpf_struct_ops_common_value common;\t\\\n2268:\t\t\t\tstruct type data ____cacheline_aligned_in_smp;\t\\\n2269:\t\t\t};\t\t\t\t\t\t\t\\\n2270:\t\t\tBTF_TYPE_EMIT(struct bpf_struct_ops_##type);\t\t\\\n2271:\t\t\t__register_bpf_struct_ops(st_ops);\t\t\t\\\n2272:\t\t})\n2273:\t#define BPF_MODULE_OWNER ((void *)((0xeB9FUL \u003c\u003c 2) + POISON_POINTER_DELTA))\n2274:\tbool bpf_struct_ops_get(const void *kdata);\n2275:\tvoid bpf_struct_ops_put(const void *kdata);\n2276:\tint bpf_struct_ops_supported(const struct bpf_struct_ops *st_ops, u32 moff);\n2277:\tint bpf_struct_ops_map_sys_lookup_elem(struct bpf_map *map, void *key,\n2278:\t\t\t\t\t void *value);\n2279:\tint bpf_struct_ops_prepare_trampoline(struct bpf_tramp_nodes *tnodes,\n"
} |
| 15/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33712 output: 39 thoughts: 89 Thoughts: Okay, here's my breakdown of this. **Kernel Configuration Dependencies for BPF JIT and Network Functionality** Alright, so I'm digging into configuring this BPF setup and it's pretty clear that `CONFIG_BPF_JIT`, `CONFIG_BPF_SYSCALL`, and `CONFIG_CGROUP_BPF` are the foundational pieces I need to nail down first. That's a given. Now, I have a hunch, and it's a good one, that network-related functionality is essential here. Specifically, I'm thinking I'll need `CONFIG_NET` and `CONFIG_INET`, too. Given that TCP is inherently tied to `CONFIG_INET`, that strengthens my intuition. I should probably dive into `net/ipv4/bpf_tcp_ops.c` to see if there are any other specific configurations referenced in that area. That file likely holds some crucial details on dependencies or supporting features. Time to dig in there. |
| 16/2 | 2026/09/26 03:06 | tool | read-file |
0mArgs:{
"File": "net/ipv4/bpf_tcp_ops.c",
"FirstLine": 1,
"LineCount": 40
}Results: {
"Contents": " 1:\t// SPDX-License-Identifier: GPL-2.0\n 2:\t/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */\n 3:\t\n 4:\t#include \u003clinux/bpf.h\u003e\n 5:\t#include \u003clinux/btf_ids.h\u003e\n 6:\t#include \u003clinux/bpf_verifier.h\u003e\n 7:\t#include \u003clinux/filter.h\u003e\n 8:\t#include \u003cnet/bpf_sk_storage.h\u003e\n 9:\t#include \u003cnet/tcp.h\u003e\n 10:\t\n 11:\tstatic int timeout_init_stub(struct sock *sk, struct request_sock *req__nullable)\n 12:\t{\n 13:\t\tstruct bpf_tramp_run_ctx *ctx =\n 14:\t\t\tcontainer_of(current-\u003ebpf_ctx, struct bpf_tramp_run_ctx, run_ctx);\n 15:\t\n 16:\t\treturn ctx-\u003eretval;\n 17:\t}\n 18:\t\n 19:\tstatic int rwnd_init_stub(struct sock *sk, struct request_sock *req__nullable)\n 20:\t{\n 21:\t\tstruct bpf_tramp_run_ctx *ctx =\n 22:\t\t\tcontainer_of(current-\u003ebpf_ctx, struct bpf_tramp_run_ctx, run_ctx);\n 23:\t\n 24:\t\treturn ctx-\u003eretval;\n 25:\t}\n 26:\t\n 27:\tstatic void active_established_stub(struct sock *sk, struct sk_buff *skb__nullable)\n 28:\t{\n 29:\t}\n 30:\t\n 31:\tstatic void passive_established_stub(struct sock *sk, struct sk_buff *skb)\n 32:\t{\n 33:\t}\n 34:\t\n 35:\tstatic void rto_stub(struct sock *sk)\n 36:\t{\n 37:\t}\n 38:\t\n 39:\tstatic void rtt_stub(struct sock *sk, long mrtt, u32 srtt)\n 40:\t{\n"
} |
| 17/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34614 output: 21 thoughts: 2407 Thoughts: **Focusing on TCP BPF Changes** Okay, let's break this down. My primary concern is to identify the key functions that have been added or modified to support this new TCP BPF functionality. I need to avoid listing overly general functions that are called everywhere, as that won't help the fuzzer. First, the core of the change seems to revolve around controlling socket operations via BPF programs. I saw that `tcp_set_sock_ops_cb_flags` is now MPTCP aware and it's called through `bpf_sol_tcp_setsockopt` and `bpf_sock_ops_cb_flags_set`. The `BPF_SOCK_OPS_RCVQ_CB_FLAG` seems crucial there. Then, I also saw the addition of `bpf_tcp_ops_cb_flags_set`, so let me keep that. Next, the `rcvlowat` settings are interesting. I noticed the addition of `bpf_tcp_ops_set_rcvlowat`, which is a kfunc, alongside `__tcp_set_rcvlowat` and `tcp_set_rcvlowat`. I'm especially interested in this kfunc because it's a new entrypoint for BPF programs to interact with receive low water mark settings. The `wakeup` flag that it uses is another important signal. The `bpf_tcp_ops_rcvlowat_kfunc_filter` could also be considered for inclusion. I have to carefully evaluate the calls to `bpf_tcp_ops_enqueue_rcvq` and `bpf_tcp_ops_dequeue_rcvq` which are used inside of the `BPF_SOCK_OPS_RCVQ_CB_FLAG`. The former are used inside `tcp_fastopen_add_skb`, `tcp_ofo_queue`, and `tcp_queue_rcv`. The latter are used inside `tcp_cleanup_rbuf`. I should remember that the `enqueue_rcvq` and `dequeue_rcvq` stubs in `net/ipv4/bpf_tcp_ops.c` are not relevant as they are static. `tcp_cleanup_rbuf` seems like a likely candidate for fuzzing as it calls the `dequeue_rcvq` callback, but it's important to figure out if it's too ubiquitous. Because it's called in every TCP read, and if it's too ubiquitous, it's not useful. Maybe the new `bpf_tcp_ops_set_rcvlowat` and `bpf_tcp_ops_cb_flags_set` are better as they are more specific. Also, `bpf_sock_ops_cb_flags_set` is a BPF helper and `bpf_sol_tcp_setsockopt` is interesting because it calls into the BPF subsystem. Let's check if there are other new symbols: The `is_sockopt_supported` helper function seems relevant since it was introduced to handle the `setsockopt` and `getsockopt` BPF functions. Finally, `bpf_tcp_ops_set_rcvlowat` is a distinct symbol, just like `__tcp_set_rcvlowat` and `tcp_set_rcvlowat`. So I can target those. Also `tcp_fastopen_add_skb` is interesting because it's specific to fastopen data enqueue. Therefore, the key functions to focus on are: 1. `__tcp_set_rcvlowat` 2. `tcp_set_rcvlowat` 3. `bpf_tcp_ops_set_rcvlowat` 4. `bpf_tcp_ops_cb_flags_set` 5. `bpf_sock_ops_cb_flags_set` 6. `bpf_sol_tcp_setsockopt` 7. `tcp_fastopen_add_skb` 8. `is_sockopt_supported` |
| 18/2 | 2026/09/26 03:06 | tool | grepper |
0mArgs:{
"Expression": "define __bpf_kfunc"
}Results: {
"Output": "include/linux/btf.h-89- */\ninclude/linux/btf.h:90:#define __bpf_kfunc __used __retain __noclone noinline\ninclude/linux/btf.h-91-\ninclude/linux/btf.h:92:#define __bpf_kfunc_start_defs()\t\t\t\t\t \\\ninclude/linux/btf.h-93-\t__diag_push();\t\t\t\t\t\t\t \\\n--\ninclude/linux/btf.h-98-\ninclude/linux/btf.h:99:#define __bpf_kfunc_end_defs() __diag_pop()\ninclude/linux/btf.h-100-#define __bpf_hook_start() __bpf_kfunc_start_defs()\n"
} |
| 19/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38125 output: 22 thoughts: 115 Thoughts: Okay, let me think this through. **Analyzing Kernel Symbol Visibility and Inlining** Alright, so `__bpf_kfunc` is tagged with `__used __retain __noclone noinline`. That pretty much guarantees that any function using it, like `bpf_tcp_ops_set_rcvlowat`, is going to be exported and retained as a non-inlined symbol within the vmlinux kernel image. That's good; we can rely on its presence. Now, I see this `BPF_CALL_2(bpf_tcp_ops_cb_flags_set, ...)` macro being used, which creates `bpf_tcp_ops_cb_flags_set`. I need to confirm the exact symbol name it generates. Let's dig into the definition of `BPF_CALL_2`. I need to understand how that macro is structured to fully grasp the resulting symbol's implications and how it interacts with the BPF subsystem. I want to see how that function is created. |
| 20/2 | 2026/09/26 03:06 | tool | grepper |
0mArgs:{
"Expression": "#define BPF_CALL_2"
}Results: {
"Output": "include/linux/filter.h=424=static inline int bpf_atomic_load_reg(const struct bpf_insn *insn)\n--\ninclude/linux/filter.h-680-#define BPF_CALL_1(name, ...)\tBPF_CALL_x(1, __NOATTR, name, __VA_ARGS__)\ninclude/linux/filter.h:681:#define BPF_CALL_2(name, ...)\tBPF_CALL_x(2, __NOATTR, name, __VA_ARGS__)\ninclude/linux/filter.h-682-#define BPF_CALL_3(name, ...)\tBPF_CALL_x(3, __NOATTR, name, __VA_ARGS__)\n"
} |
| 21/2 | 2026/09/26 03:06 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38666 output: 35 thoughts: 15 Thoughts: Okay, let's dive into this. Here's my take on those initial thoughts: **Dissecting BPF_CALL_x** Alright, time to get my hands dirty. I need to understand what `BPF_CALL_x` is actually up to. It's a fundamental part of the eBPF framework, so a deep understanding is crucial. I need to break down the `BPF_CALL_x` macro and work out its purpose. I'm going to start by getting a handle on what the `x` represents, and how it is implemented in the BPF runtime. I need to understand the function as a whole to see how it might be leveraged. |
| 22/2 | 2026/09/26 03:07 | tool | read-file |
0mArgs:{
"File": "include/linux/filter.h",
"FirstLine": 660,
"LineCount": 25
}Results: {
"Contents": " 660:\t#define __BPF_DECL_REGS(t, a) u64 a\n 661:\t\n 662:\t#define __BPF_PAD(n)\t\t\t\t\t\t\t \\\n 663:\t\t__BPF_MAP(n, __BPF_DECL_ARGS, __BPF_N, u64, __ur_1, u64, __ur_2, \\\n 664:\t\t\t u64, __ur_3, u64, __ur_4, u64, __ur_5)\n 665:\t\n 666:\t#define BPF_CALL_x(x, attr, name, ...)\t\t\t\t\t \\\n 667:\t\tstatic __always_inline\t\t\t\t\t\t \\\n 668:\t\tu64 ____##name(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__)); \\\n 669:\t\ttypedef u64 (*btf_##name)(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__)); \\\n 670:\t\tattr u64 name(__BPF_REG(x, __BPF_DECL_REGS, __BPF_N, __VA_ARGS__)); \\\n 671:\t\tattr u64 name(__BPF_REG(x, __BPF_DECL_REGS, __BPF_N, __VA_ARGS__)) \\\n 672:\t\t{\t\t\t\t\t\t\t\t \\\n 673:\t\t\treturn ((btf_##name)____##name)(__BPF_MAP(x,__BPF_CAST,__BPF_N,__VA_ARGS__));\\\n 674:\t\t}\t\t\t\t\t\t\t\t \\\n 675:\t\tstatic __always_inline\t\t\t\t\t\t \\\n 676:\t\tu64 ____##name(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__))\n 677:\t\n 678:\t#define __NOATTR\n 679:\t#define BPF_CALL_0(name, ...)\tBPF_CALL_x(0, __NOATTR, name, __VA_ARGS__)\n 680:\t#define BPF_CALL_1(name, ...)\tBPF_CALL_x(1, __NOATTR, name, __VA_ARGS__)\n 681:\t#define BPF_CALL_2(name, ...)\tBPF_CALL_x(2, __NOATTR, name, __VA_ARGS__)\n 682:\t#define BPF_CALL_3(name, ...)\tBPF_CALL_x(3, __NOATTR, name, __VA_ARGS__)\n 683:\t#define BPF_CALL_4(name, ...)\tBPF_CALL_x(4, __NOATTR, name, __VA_ARGS__)\n 684:\t#define BPF_CALL_5(name, ...)\tBPF_CALL_x(5, __NOATTR, name, __VA_ARGS__)\n"
} |
| 23/2 | 2026/09/26 03:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39615 output: 22 thoughts: 272 Thoughts: **My Analysis of Kernel Configuration Dependencies** Okay, so I see that `u64 name(...)` is indeed defined. That means the functions `bpf_tcp_ops_cb_flags_set` and `bpf_sock_ops_cb_flags_set` are definitely symbols present within vmlinux. Good, good. Now, time to drill down on the required kernel configurations. Let's look at `bpf_tcp_ops.o`. The build rules tell us: ```make ifeq ($(CONFIG_BPF_JIT),y) obj-$(CONFIG_BPF_SYSCALL) += bpf_tcp_ca.o obj-$(CONFIG_CGROUP_BPF) += bpf_tcp_ops.o endif ``` Right, that boils down to needing `CONFIG_BPF_JIT`, `CONFIG_BPF_SYSCALL`, and `CONFIG_CGROUP_BPF`. A quick check reveals that `CGROUP_BPF` is *dependent* on `BPF_SYSCALL`. That makes sense; it's a hierarchy. Since we're dealing with TCP operations, I should note that the relevant networking code under `net/ipv4/` is, as expected, under `CONFIG_INET`. Now, the crucial question: do we need `CONFIG_DEBUG_INFO_BTF` for kfuncs or struct_ops? That's the next critical piece. I need to review the dependencies of `BTF_KFUNCS_START` and `bpf_struct_ops` specifically related to BTF. I'll need to check how it's used and see if it is used. |
| 24/2 | 2026/09/26 03:07 | tool | grepper |
0mArgs:{
"Expression": "BTF_KFUNCS_START"
}Results: {
"Output": "Documentation/bpf/kfuncs.rst=369=flags on a set of kfuncs as follows::\nDocumentation/bpf/kfuncs.rst-370-\nDocumentation/bpf/kfuncs.rst:371: BTF_KFUNCS_START(bpf_task_set)\nDocumentation/bpf/kfuncs.rst-372- BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE | KF_RET_NULL)\n--\nDocumentation/bpf/kfuncs.rst=530=type. An example is shown below::\nDocumentation/bpf/kfuncs.rst-531-\nDocumentation/bpf/kfuncs.rst:532: BTF_KFUNCS_START(bpf_task_set)\nDocumentation/bpf/kfuncs.rst-533- BTF_ID_FLAGS(func, bpf_get_task_pid, KF_ACQUIRE | KF_RET_NULL)\n--\nDocumentation/bpf/kfuncs.rst=548=At kernel build time the ``resolve_btfids`` tool finds all kfuncs declared with\nDocumentation/bpf/kfuncs.rst:549:``BTF_KFUNCS_START()`` and emits their BTF annotations into the kernel's BTF.\nDocumentation/bpf/kfuncs.rst-550-For each kfunc it emits a ``bpf_kfunc`` BTF decl tag, a ``bpf_fastcall`` decl\n--\ndrivers/base/power/wakeup.c=1215=__bpf_kfunc_end_defs();\ndrivers/base/power/wakeup.c-1216-\ndrivers/base/power/wakeup.c:1217:BTF_KFUNCS_START(wakeup_source_kfunc_ids)\ndrivers/base/power/wakeup.c-1218-BTF_ID_FLAGS(func, bpf_wakeup_sources_read_lock, KF_ACQUIRE)\n--\ndrivers/hid/bpf/hid_bpf_dispatch.c=570=__bpf_kfunc_end_defs();\n--\ndrivers/hid/bpf/hid_bpf_dispatch.c-575- */\ndrivers/hid/bpf/hid_bpf_dispatch.c:576:BTF_KFUNCS_START(hid_bpf_kfunc_ids)\ndrivers/hid/bpf/hid_bpf_dispatch.c-577-BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL)\n--\ndrivers/hid/bpf/hid_bpf_dispatch.c=586=static const struct btf_kfunc_id_set hid_bpf_kfunc_set = {\n--\ndrivers/hid/bpf/hid_bpf_dispatch.c-591-/* for syscall HID-BPF */\ndrivers/hid/bpf/hid_bpf_dispatch.c:592:BTF_KFUNCS_START(hid_bpf_syscall_kfunc_ids)\ndrivers/hid/bpf/hid_bpf_dispatch.c-593-BTF_ID_FLAGS(func, hid_bpf_allocate_context, KF_ACQUIRE | KF_RET_NULL | KF_SLEEPABLE)\n--\nfs/binfmt_misc_bpf.c=275=__bpf_kfunc_end_defs();\nfs/binfmt_misc_bpf.c-276-\nfs/binfmt_misc_bpf.c:277:BTF_KFUNCS_START(bm_bpf_kfunc_ids)\nfs/binfmt_misc_bpf.c-278-BTF_ID_FLAGS(func, bpf_binprm_set_interp, KF_SLEEPABLE)\n--\nfs/bpf_fs_kfuncs.c=501=__bpf_kfunc_end_defs();\nfs/bpf_fs_kfuncs.c-502-\nfs/bpf_fs_kfuncs.c:503:BTF_KFUNCS_START(bpf_fs_kfunc_set_ids)\nfs/bpf_fs_kfuncs.c-504-BTF_ID_FLAGS(func, bpf_get_task_exe_file, KF_ACQUIRE | KF_RET_NULL)\n--\nfs/verity/measure.c=165=__bpf_kfunc_end_defs();\nfs/verity/measure.c-166-\nfs/verity/measure.c:167:BTF_KFUNCS_START(fsverity_set_ids)\nfs/verity/measure.c-168-BTF_ID_FLAGS(func, bpf_get_fsverity_digest)\n--\ninclude/linux/btf_ids.h=210=extern struct btf_id_set8 name;\ninclude/linux/btf_ids.h-211-\ninclude/linux/btf_ids.h:212:#define BTF_KFUNCS_START(name)\t\t\t\t\\\ninclude/linux/btf_ids.h-213-__BTF_SET8_START(name, local, BTF_SET8_KFUNCS)\n--\ninclude/linux/btf_ids.h=216=BTF_SET8_END(name)\n--\ninclude/linux/btf_ids.h-231-#define BTF_SET8_END(name)\ninclude/linux/btf_ids.h:232:#define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };\ninclude/linux/btf_ids.h-233-#define BTF_KFUNCS_END(name)\n--\nio_uring/bpf-ops.c=52=__bpf_kfunc_end_defs();\nio_uring/bpf-ops.c-53-\nio_uring/bpf-ops.c:54:BTF_KFUNCS_START(io_uring_kfunc_set)\nio_uring/bpf-ops.c-55-BTF_ID_FLAGS(func, bpf_io_uring_submit_sqes, KF_SLEEPABLE);\n--\nkernel/bpf/arena.c=1118=__bpf_kfunc_end_defs();\nkernel/bpf/arena.c-1119-\nkernel/bpf/arena.c:1120:BTF_KFUNCS_START(arena_kfuncs)\nkernel/bpf/arena.c-1121-BTF_ID_FLAGS(func, bpf_arena_alloc_pages, KF_ARENA_RET | KF_ARENA_ARG2 | KF_SPINLOCK_SAFE)\n--\nkernel/bpf/cpumask.c=475=__bpf_kfunc_end_defs();\nkernel/bpf/cpumask.c-476-\nkernel/bpf/cpumask.c:477:BTF_KFUNCS_START(cpumask_kfunc_btf_ids)\nkernel/bpf/cpumask.c-478-BTF_ID_FLAGS(func, bpf_cpumask_create, KF_ACQUIRE | KF_RET_NULL)\n--\nkernel/bpf/crypto.c=352=__bpf_kfunc_end_defs();\nkernel/bpf/crypto.c-353-\nkernel/bpf/crypto.c:354:BTF_KFUNCS_START(crypt_init_kfunc_btf_ids)\nkernel/bpf/crypto.c-355-BTF_ID_FLAGS(func, bpf_crypto_ctx_create, KF_ACQUIRE | KF_RET_NULL | KF_SLEEPABLE)\n--\nkernel/bpf/crypto.c=360=static const struct btf_kfunc_id_set crypt_init_kfunc_set = {\n--\nkernel/bpf/crypto.c-364-\nkernel/bpf/crypto.c:365:BTF_KFUNCS_START(crypt_kfunc_btf_ids)\nkernel/bpf/crypto.c-366-BTF_ID_FLAGS(func, bpf_crypto_decrypt, KF_RCU)\n--\nkernel/bpf/helpers.c=4913=void bpf_task_work_cancel_and_free(void *val)\n--\nkernel/bpf/helpers.c-4933-\nkernel/bpf/helpers.c:4934:BTF_KFUNCS_START(generic_btf_ids)\nkernel/bpf/helpers.c-4935-#ifdef CONFIG_CRASH_DUMP\n--\nkernel/bpf/helpers.c=5010=BTF_ID(func, bpf_cgroup_release_dtor)\n--\nkernel/bpf/helpers.c-5012-\nkernel/bpf/helpers.c:5013:BTF_KFUNCS_START(common_btf_ids)\nkernel/bpf/helpers.c-5014-BTF_ID_FLAGS(func, bpf_cast_to_kern_ctx, KF_FASTCALL)\n--\nkernel/bpf/map_iter.c=219=__bpf_kfunc_end_defs();\nkernel/bpf/map_iter.c-220-\nkernel/bpf/map_iter.c:221:BTF_KFUNCS_START(bpf_map_iter_kfunc_ids)\nkernel/bpf/map_iter.c-222-BTF_ID_FLAGS(func, bpf_map_sum_elem_count)\n--\nkernel/bpf/rqspinlock.c=745=__bpf_kfunc_end_defs();\nkernel/bpf/rqspinlock.c-746-\nkernel/bpf/rqspinlock.c:747:BTF_KFUNCS_START(rqspinlock_kfunc_ids)\nkernel/bpf/rqspinlock.c-748-BTF_ID_FLAGS(func, bpf_res_spin_lock, KF_RET_NULL | KF_SPINLOCK_SAFE)\n--\nkernel/cgroup/rstat.c=722=void cgroup_base_stat_cputime_show(struct seq_file *seq)\n--\nkernel/cgroup/rstat.c-755-/* Add bpf kfuncs for css_rstat_updated() and css_rstat_flush() */\nkernel/cgroup/rstat.c:756:BTF_KFUNCS_START(bpf_rstat_kfunc_ids)\nkernel/cgroup/rstat.c-757-BTF_ID_FLAGS(func, css_rstat_updated)\n--\nkernel/sched/ext/cid.c=941=__bpf_kfunc_end_defs();\nkernel/sched/ext/cid.c-942-\nkernel/sched/ext/cid.c:943:BTF_KFUNCS_START(scx_kfunc_ids_init_cids)\nkernel/sched/ext/cid.c-944-BTF_ID_FLAGS(func, scx_bpf_cid_override, KF_IMPLICIT_ARGS | KF_SLEEPABLE)\n--\nkernel/sched/ext/cid.c=947=static const struct btf_kfunc_id_set scx_kfunc_set_init_cids = {\n--\nkernel/sched/ext/cid.c-952-\nkernel/sched/ext/cid.c:953:BTF_KFUNCS_START(scx_kfunc_ids_cid)\nkernel/sched/ext/cid.c-954-BTF_ID_FLAGS(func, scx_bpf_cid_to_cpu, KF_IMPLICIT_ARGS)\n--\nkernel/sched/ext/ext.c=8960=__bpf_kfunc_end_defs();\nkernel/sched/ext/ext.c-8961-\nkernel/sched/ext/ext.c:8962:BTF_KFUNCS_START(scx_kfunc_ids_enqueue_dispatch)\nkernel/sched/ext/ext.c-8963-BTF_ID_FLAGS(func, scx_bpf_dsq_insert, KF_IMPLICIT_ARGS | KF_RCU)\n--\nkernel/sched/ext/ext.c=9296=__bpf_kfunc_end_defs();\nkernel/sched/ext/ext.c-9297-\nkernel/sched/ext/ext.c:9298:BTF_KFUNCS_START(scx_kfunc_ids_dispatch)\nkernel/sched/ext/ext.c-9299-BTF_ID_FLAGS(func, scx_bpf_dispatch_nr_slots, KF_IMPLICIT_ARGS)\n--\nkernel/sched/ext/ext.c=9345=__bpf_kfunc_end_defs();\nkernel/sched/ext/ext.c-9346-\nkernel/sched/ext/ext.c:9347:BTF_KFUNCS_START(scx_kfunc_ids_cpu_release)\nkernel/sched/ext/ext.c-9348-BTF_ID_FLAGS(func, scx_bpf_reenqueue_local, KF_IMPLICIT_ARGS)\n--\nkernel/sched/ext/ext.c=9414=__bpf_kfunc_end_defs();\nkernel/sched/ext/ext.c-9415-\nkernel/sched/ext/ext.c:9416:BTF_KFUNCS_START(scx_kfunc_ids_unlocked)\nkernel/sched/ext/ext.c-9417-BTF_ID_FLAGS(func, scx_bpf_create_dsq, KF_IMPLICIT_ARGS | KF_SLEEPABLE)\n--\nkernel/sched/ext/ext.c=10666=__bpf_kfunc_end_defs();\nkernel/sched/ext/ext.c-10667-\nkernel/sched/ext/ext.c:10668:BTF_KFUNCS_START(scx_kfunc_ids_any)\nkernel/sched/ext/ext.c-10669-BTF_ID_FLAGS(func, scx_bpf_task_set_slice, KF_IMPLICIT_ARGS | KF_RCU);\n--\nkernel/sched/ext/ext.c=10716=static const struct btf_kfunc_id_set scx_kfunc_set_any = {\n--\nkernel/sched/ext/ext.c-10735- */\nkernel/sched/ext/ext.c:10736:BTF_KFUNCS_START(scx_kfunc_ids_cpu_only)\nkernel/sched/ext/ext.c-10737-BTF_ID_FLAGS(func, scx_bpf_kick_cpu, KF_IMPLICIT_ARGS)\n--\nkernel/sched/ext/idle.c=1509=__bpf_kfunc_end_defs();\nkernel/sched/ext/idle.c-1510-\nkernel/sched/ext/idle.c:1511:BTF_KFUNCS_START(scx_kfunc_ids_idle)\nkernel/sched/ext/idle.c-1512-BTF_ID_FLAGS(func, scx_bpf_cpu_node, KF_IMPLICIT_ARGS)\n--\nkernel/sched/ext/idle.c=1525=static const struct btf_kfunc_id_set scx_kfunc_set_idle = {\n--\nkernel/sched/ext/idle.c-1541- */\nkernel/sched/ext/idle.c:1542:BTF_KFUNCS_START(scx_kfunc_ids_select_cpu)\nkernel/sched/ext/idle.c-1543-BTF_ID_FLAGS(func, __scx_bpf_select_cpu_and, KF_IMPLICIT_ARGS | KF_RCU)\n--\nkernel/trace/bpf_trace.c=3435=__bpf_kfunc_end_defs();\nkernel/trace/bpf_trace.c-3436-\nkernel/trace/bpf_trace.c:3437:BTF_KFUNCS_START(session_kfunc_set_ids)\nkernel/trace/bpf_trace.c-3438-BTF_ID_FLAGS(func, bpf_session_is_return)\n--\nmm/bpf_memcontrol.c=209=__bpf_kfunc_end_defs();\nmm/bpf_memcontrol.c-210-\nmm/bpf_memcontrol.c:211:BTF_KFUNCS_START(bpf_memcontrol_kfuncs)\nmm/bpf_memcontrol.c-212-BTF_ID_FLAGS(func, bpf_get_root_mem_cgroup, KF_ACQUIRE | KF_RET_NULL)\n--\nmm/bpf_memcontrol.c=222=BTF_KFUNCS_END(bpf_memcontrol_kfuncs)\nmm/bpf_memcontrol.c-223-\nmm/bpf_memcontrol.c:224:BTF_KFUNCS_START(bpf_memcontrol_reclaim_kfuncs)\nmm/bpf_memcontrol.c-225-BTF_ID_FLAGS(func, bpf_proactive_reclaim, KF_SLEEPABLE)\n--\nnet/bpf/test_run.c=644=__bpf_kfunc_end_defs();\nnet/bpf/test_run.c-645-\nnet/bpf/test_run.c:646:BTF_KFUNCS_START(bpf_test_modify_return_ids)\nnet/bpf/test_run.c-647-BTF_ID_FLAGS(func, bpf_modify_return_test)\n--\nnet/bpf/test_run.c=653=static const struct btf_kfunc_id_set bpf_test_modify_return_set = {\n--\nnet/bpf/test_run.c-657-\nnet/bpf/test_run.c:658:BTF_KFUNCS_START(test_sk_check_kfunc_ids)\nnet/bpf/test_run.c-659-BTF_ID_FLAGS(func, bpf_kfunc_call_test_release, KF_RELEASE)\n--\nnet/core/bpf_ksock.c=258=__bpf_kfunc_end_defs();\nnet/core/bpf_ksock.c-259-\nnet/core/bpf_ksock.c:260:BTF_KFUNCS_START(ksock_init_kfunc_btf_ids)\nnet/core/bpf_ksock.c-261-BTF_ID_FLAGS(func, bpf_ksock_create, KF_ACQUIRE | KF_RET_NULL | KF_SLEEPABLE)\n--\nnet/core/bpf_ksock.c=265=static const struct btf_kfunc_id_set ksock_init_kfunc_set = {\n--\nnet/core/bpf_ksock.c-269-\nnet/core/bpf_ksock.c:270:BTF_KFUNCS_START(ksock_kfunc_btf_ids)\nnet/core/bpf_ksock.c-271-BTF_ID_FLAGS(func, bpf_ksock_release, KF_RELEASE)\n--\nnet/core/filter.c=12810=int bpf_dynptr_from_skb_rdonly(struct __sk_buff *skb, u64 flags,\n--\nnet/core/filter.c-12824-\nnet/core/filter.c:12825:BTF_KFUNCS_START(bpf_kfunc_check_set_skb)\nnet/core/filter.c-12826-BTF_ID_FLAGS(func, bpf_dynptr_from_skb)\nnet/core/filter.c=12827=BTF_KFUNCS_END(bpf_kfunc_check_set_skb)\nnet/core/filter.c-12828-\nnet/core/filter.c:12829:BTF_KFUNCS_START(bpf_kfunc_check_set_skb_meta)\nnet/core/filter.c-12830-BTF_ID_FLAGS(func, bpf_dynptr_from_skb_meta)\nnet/core/filter.c=12831=BTF_KFUNCS_END(bpf_kfunc_check_set_skb_meta)\nnet/core/filter.c-12832-\nnet/core/filter.c:12833:BTF_KFUNCS_START(bpf_kfunc_check_set_xdp)\nnet/core/filter.c-12834-BTF_ID_FLAGS(func, bpf_dynptr_from_xdp)\n--\nnet/core/filter.c=12836=BTF_KFUNCS_END(bpf_kfunc_check_set_xdp)\nnet/core/filter.c-12837-\nnet/core/filter.c:12838:BTF_KFUNCS_START(bpf_kfunc_check_set_sock_addr)\nnet/core/filter.c-12839-BTF_ID_FLAGS(func, bpf_sock_addr_set_sun_path)\nnet/core/filter.c=12840=BTF_KFUNCS_END(bpf_kfunc_check_set_sock_addr)\nnet/core/filter.c-12841-\nnet/core/filter.c:12842:BTF_KFUNCS_START(bpf_kfunc_check_set_tcp_reqsk)\nnet/core/filter.c-12843-BTF_ID_FLAGS(func, bpf_sk_assign_tcp_reqsk)\nnet/core/filter.c=12844=BTF_KFUNCS_END(bpf_kfunc_check_set_tcp_reqsk)\nnet/core/filter.c-12845-\nnet/core/filter.c:12846:BTF_KFUNCS_START(bpf_kfunc_check_set_sock_ops)\nnet/core/filter.c-12847-BTF_ID_FLAGS(func, bpf_sock_ops_enable_tx_tstamp)\nnet/core/filter.c=12848=BTF_KFUNCS_END(bpf_kfunc_check_set_sock_ops)\nnet/core/filter.c-12849-\nnet/core/filter.c:12850:BTF_KFUNCS_START(bpf_kfunc_check_set_icmp_send)\nnet/core/filter.c-12851-BTF_ID_FLAGS(func, bpf_icmp_send)\n--\nnet/core/filter.c=12950=__bpf_kfunc_end_defs();\nnet/core/filter.c-12951-\nnet/core/filter.c:12952:BTF_KFUNCS_START(bpf_sk_iter_kfunc_ids)\nnet/core/filter.c-12953-BTF_ID_FLAGS(func, bpf_sock_destroy)\n--\nnet/core/xdp.c=964=__bpf_kfunc_end_defs();\nnet/core/xdp.c-965-\nnet/core/xdp.c:966:BTF_KFUNCS_START(xdp_metadata_kfunc_ids)\nnet/core/xdp.c-967-#define XDP_METADATA_KFUNC(_, __, name, ___) BTF_ID_FLAGS(func, name)\n--\nnet/ipv4/bpf_tcp_ca.c=152=bpf_tcp_ca_get_func_proto(enum bpf_func_id func_id,\n--\nnet/ipv4/bpf_tcp_ca.c-190-\nnet/ipv4/bpf_tcp_ca.c:191:BTF_KFUNCS_START(bpf_tcp_ca_check_kfunc_ids)\nnet/ipv4/bpf_tcp_ca.c-192-BTF_ID_FLAGS(func, tcp_reno_ssthresh)\n--\nnet/ipv4/bpf_tcp_ops.c=388=__bpf_kfunc_end_defs();\nnet/ipv4/bpf_tcp_ops.c-389-\nnet/ipv4/bpf_tcp_ops.c:390:BTF_KFUNCS_START(bpf_tcp_ops_rcvlowat_kfunc_set)\nnet/ipv4/bpf_tcp_ops.c-391-BTF_ID_FLAGS(func, bpf_tcp_ops_set_rcvlowat, KF_IMPLICIT_ARGS)\n--\nnet/ipv4/fou_bpf.c=101=__bpf_kfunc_end_defs();\nnet/ipv4/fou_bpf.c-102-\nnet/ipv4/fou_bpf.c:103:BTF_KFUNCS_START(fou_kfunc_set)\nnet/ipv4/fou_bpf.c-104-BTF_ID_FLAGS(func, bpf_skb_set_fou_encap)\n--\nnet/ipv4/tcp_bbr.c=1144=static struct tcp_congestion_ops tcp_bbr_cong_ops __read_mostly = {\n--\nnet/ipv4/tcp_bbr.c-1158-\nnet/ipv4/tcp_bbr.c:1159:BTF_KFUNCS_START(tcp_bbr_check_kfunc_ids)\nnet/ipv4/tcp_bbr.c-1160-BTF_ID_FLAGS(func, bbr_init)\n--\nnet/ipv4/tcp_cubic.c=475=static struct tcp_congestion_ops cubictcp __read_mostly = {\n--\nnet/ipv4/tcp_cubic.c-486-\nnet/ipv4/tcp_cubic.c:487:BTF_KFUNCS_START(tcp_cubic_check_kfunc_ids)\nnet/ipv4/tcp_cubic.c-488-BTF_ID_FLAGS(func, cubictcp_init)\n--\nnet/ipv4/tcp_dctcp.c=270=static struct tcp_congestion_ops dctcp_reno __read_mostly = {\n--\nnet/ipv4/tcp_dctcp.c-278-\nnet/ipv4/tcp_dctcp.c:279:BTF_KFUNCS_START(tcp_dctcp_check_kfunc_ids)\nnet/ipv4/tcp_dctcp.c-280-BTF_ID_FLAGS(func, dctcp_init)\n--\nnet/netfilter/nf_conntrack_bpf.c=520=__bpf_kfunc_end_defs();\nnet/netfilter/nf_conntrack_bpf.c-521-\nnet/netfilter/nf_conntrack_bpf.c:522:BTF_KFUNCS_START(nf_ct_kfunc_set)\nnet/netfilter/nf_conntrack_bpf.c-523-BTF_ID_FLAGS(func, bpf_xdp_ct_alloc, KF_ACQUIRE | KF_RET_NULL)\n--\nnet/netfilter/nf_flow_table_bpf.c=105=__bpf_kfunc_end_defs();\nnet/netfilter/nf_flow_table_bpf.c-106-\nnet/netfilter/nf_flow_table_bpf.c:107:BTF_KFUNCS_START(nf_ft_kfunc_set)\nnet/netfilter/nf_flow_table_bpf.c-108-BTF_ID_FLAGS(func, bpf_xdp_flow_lookup, KF_RET_NULL)\n--\nnet/netfilter/nf_nat_bpf.c=55=__bpf_kfunc_end_defs();\nnet/netfilter/nf_nat_bpf.c-56-\nnet/netfilter/nf_nat_bpf.c:57:BTF_KFUNCS_START(nf_nat_kfunc_set)\nnet/netfilter/nf_nat_bpf.c-58-BTF_ID_FLAGS(func, bpf_ct_set_nat_info)\n--\nnet/sched/bpf_qdisc.c=277=__bpf_kfunc_end_defs();\nnet/sched/bpf_qdisc.c-278-\nnet/sched/bpf_qdisc.c:279:BTF_KFUNCS_START(qdisc_kfunc_ids)\nnet/sched/bpf_qdisc.c-280-BTF_ID_FLAGS(func, bpf_skb_get_hash)\n--\nnet/xfrm/xfrm_interface_bpf.c=94=__bpf_kfunc_end_defs();\nnet/xfrm/xfrm_interface_bpf.c-95-\nnet/xfrm/xfrm_interface_bpf.c:96:BTF_KFUNCS_START(xfrm_ifc_kfunc_set)\nnet/xfrm/xfrm_interface_bpf.c-97-BTF_ID_FLAGS(func, bpf_skb_get_xfrm_info)\n--\nnet/xfrm/xfrm_state_bpf.c=118=__bpf_kfunc_end_defs();\nnet/xfrm/xfrm_state_bpf.c-119-\nnet/xfrm/xfrm_state_bpf.c:120:BTF_KFUNCS_START(xfrm_state_kfunc_set)\nnet/xfrm/xfrm_state_bpf.c-121-BTF_ID_FLAGS(func, bpf_xdp_get_xfrm_state, KF_RET_NULL | KF_ACQUIRE)\n--\ntools/include/linux/btf_ids.h=209=extern struct btf_id_set8 name;\ntools/include/linux/btf_ids.h-210-\ntools/include/linux/btf_ids.h:211:#define BTF_KFUNCS_START(name)\t\t\t\t\\\ntools/include/linux/btf_ids.h-212-__BTF_SET8_START(name, local, BTF_SET8_KFUNCS)\n--\ntools/include/linux/btf_ids.h=215=BTF_SET8_END(name)\n--\ntools/include/linux/btf_ids.h-230-#define BTF_SET8_END(name)\ntools/include/linux/btf_ids.h:231:#define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };\ntools/include/linux/btf_ids.h-232-#define BTF_KFUNCS_END(name)\n--\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c=109=BTF_SET_END(test_set)\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c-110-\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c:111:BTF_KFUNCS_START(test_kfunc_set)\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c-112-BTF_ID_FLAGS(func, kfunc_a)\n--\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c=119=BTF_KFUNCS_END(test_kfunc_set)\n--\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c-124- */\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c:125:BTF_KFUNCS_START(test_kfunc_set_rev)\ntools/testing/selftests/bpf/prog_tests/resolve_btfids.c-126-BTF_ID_FLAGS(func, kfunc_g, KF_ARENA_RET)\n--\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_x.c=14=__bpf_kfunc_end_defs();\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_x.c-15-\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_x.c:16:BTF_KFUNCS_START(bpf_test_modorder_kfunc_x_ids)\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_x.c-17-BTF_ID_FLAGS(func, bpf_test_modorder_retx);\n--\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_y.c=14=__bpf_kfunc_end_defs();\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_y.c-15-\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_y.c:16:BTF_KFUNCS_START(bpf_test_modorder_kfunc_y_ids)\ntools/testing/selftests/bpf/test_kmods/bpf_test_modorder_y.c-17-BTF_ID_FLAGS(func, bpf_test_modorder_rety);\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c=888=static void unregister_bpf_testmod_uprobe(void) { }\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-890-\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:891:BTF_KFUNCS_START(bpf_testmod_common_kfunc_ids)\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-892-BTF_ID_FLAGS(func, bpf_iter_testmod_seq_new, KF_ITER_NEW)\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c=1737=__bpf_kfunc void bpf_kfunc_trigger_ctx_check(void)\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-1741-\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:1742:BTF_KFUNCS_START(bpf_testmod_check_kfunc_ids)\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-1743-BTF_ID_FLAGS(func, bpf_testmod_test_mod_kfunc, KF_SPINLOCK_SAFE)\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c=2419=extern int bpf_fentry_test1(int a);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-2420-\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:2421:BTF_KFUNCS_START(bpf_testmod_trampoline_count_ids)\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-2422-BTF_ID_FLAGS(func, bpf_testmod_trampoline_count_test)\n"
} |
| 25/2 | 2026/09/26 03:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49405 output: 38 thoughts: 69 Thoughts: Okay, let's dive into this. **Investigating the `DEBUG_INFO_BTF` Configuration** Right, my first instinct is to confirm the `DEBUG_INFO_BTF` flag. I need to make sure this is actually enabled. Let me quickly scan `include/linux/btf_ids.h`, specifically looking for the relevant conditional compilation. Ah, there it is: `#ifdef CONFIG_DEBUG_INFO_BTF`. Now I need to see what's *inside* that block. Time to home in on lines 205-235 of `include/linux/btf_ids.h`. That's where the real meat of this will likely be. That'll be where the core logic or declarations tied to the flag are defined. Let's see what's being conditionally compiled in there. I'm expecting to find the key pieces of metadata. |
| 26/2 | 2026/09/26 03:07 | tool | read-file |
0mArgs:{
"File": "include/linux/btf_ids.h",
"FirstLine": 205,
"LineCount": 35
}Results: {
"Contents": " 205:\t#define BTF_SET8_END(name)\t\t\t\t\\\n 206:\tasm(\t\t\t\t\t\t\t\\\n 207:\t\".pushsection \" BTF_IDS_SECTION \",\\\"a\\\"; \\n\"\t\\\n 208:\t\".size __BTF_ID__set8__\" #name \", .-\" #name \" \\n\"\t\\\n 209:\t\".popsection; \\n\");\t\\\n 210:\textern struct btf_id_set8 name;\n 211:\t\n 212:\t#define BTF_KFUNCS_START(name)\t\t\t\t\\\n 213:\t__BTF_SET8_START(name, local, BTF_SET8_KFUNCS)\n 214:\t\n 215:\t#define BTF_KFUNCS_END(name)\t\t\t\t\\\n 216:\tBTF_SET8_END(name)\n 217:\t\n 218:\t#else\n 219:\t\n 220:\t#define BTF_ID_LIST(name) static u32 __maybe_unused name[128];\n 221:\t#define BTF_ID(prefix, name)\n 222:\t#define BTF_ID_FLAGS(prefix, name, ...)\n 223:\t#define BTF_ID_UNUSED\n 224:\t#define BTF_ID_LIST_GLOBAL(name, n) u32 __maybe_unused name[n];\n 225:\t#define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 __maybe_unused name[1];\n 226:\t#define BTF_ID_LIST_GLOBAL_SINGLE(name, prefix, typename) u32 __maybe_unused name[1];\n 227:\t#define BTF_SET_START(name) static struct btf_id_set __maybe_unused name = { 0 };\n 228:\t#define BTF_SET_START_GLOBAL(name) static struct btf_id_set __maybe_unused name = { 0 };\n 229:\t#define BTF_SET_END(name)\n 230:\t#define BTF_SET8_START(name) static struct btf_id_set8 __maybe_unused name = { 0 };\n 231:\t#define BTF_SET8_END(name)\n 232:\t#define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };\n 233:\t#define BTF_KFUNCS_END(name)\n 234:\t\n 235:\t#endif /* CONFIG_DEBUG_INFO_BTF */\n 236:\t\n 237:\t#ifdef CONFIG_NET\n 238:\t/* Define a list of socket types which can be the argument for\n 239:\t * skc_to_*_sock() helpers. All these sockets should have\n"
} |
| 27/2 | 2026/09/26 03:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 50471 output: 25 thoughts: 41 Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue: **BTF Dependency Deep Dive** Right, so, working with BTF kfuncs and struct_ops, it's pretty clear they *absolutely* depend on `CONFIG_DEBUG_INFO_BTF`. It's just baked in, you know? The very nature of how these things work – inspecting data structures, using the type information – it all relies on having that BTF data available. There's no way around it. Now, let's just make sure I haven't missed some edge case or subtle nuance in the kernel code. Specifically, let's double-check the handling around `BPF_PROG_TYPE_STRUCT_OPS`. That's the one that seems most directly tied to using these kfuncs. Let's dig into the code and verify the expected dependencies are in place. Gotta be thorough, especially when dealing with this level of kernel interaction. |
| 28/2 | 2026/09/26 03:07 | tool | grepper |
0mArgs:{
"Expression": "BPF_PROG_TYPE_STRUCT_OPS"
}Results: {
"Output": "Documentation/bpf/bpf_prog_run.rst=26=following types:\n--\nDocumentation/bpf/bpf_prog_run.rst-37-- ``BPF_PROG_TYPE_FLOW_DISSECTOR``\nDocumentation/bpf/bpf_prog_run.rst:38:- ``BPF_PROG_TYPE_STRUCT_OPS``\nDocumentation/bpf/bpf_prog_run.rst-39-- ``BPF_PROG_TYPE_RAW_TRACEPOINT``\n--\nDocumentation/bpf/libbpf/program_types.rst=18=described in more detail in the footnotes.\n--\nDocumentation/bpf/libbpf/program_types.rst-187-+-------------------------------------------+----------------------------------------+----------------------------------+-----------+\nDocumentation/bpf/libbpf/program_types.rst:188:| ``BPF_PROG_TYPE_STRUCT_OPS`` | | ``struct_ops+`` [#struct_ops]_ | |\nDocumentation/bpf/libbpf/program_types.rst-189-+ + +----------------------------------+-----------+\n--\narch/x86/net/bpf_jit_comp.c=3490=static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog,\n--\narch/x86/net/bpf_jit_comp.c-3553-\t * BPF_TRAMP_FENTRY trampoline may need to return the return\narch/x86/net/bpf_jit_comp.c:3554:\t * value of BPF_PROG_TYPE_STRUCT_OPS prog.\narch/x86/net/bpf_jit_comp.c-3555-\t */\n--\ndrivers/hid/bpf/hid_bpf_dispatch.c=658=static int __init hid_bpf_init(void)\n--\ndrivers/hid/bpf/hid_bpf_dispatch.c-667-\ndrivers/hid/bpf/hid_bpf_dispatch.c:668:\terr = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026hid_bpf_kfunc_set);\ndrivers/hid/bpf/hid_bpf_dispatch.c-669-\tif (err) {\n--\nfs/binfmt_misc_bpf.c=96=bool bpf_prog_is_binfmt_misc_ops(const struct bpf_prog *prog)\nfs/binfmt_misc_bpf.c-97-{\nfs/binfmt_misc_bpf.c:98:\treturn prog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS \u0026\u0026\nfs/binfmt_misc_bpf.c-99-\t prog-\u003eaux-\u003est_ops == \u0026bpf_binfmt_misc_ops;\n--\nfs/binfmt_misc_bpf.c=284=static int bm_bpf_kfunc_filter(const struct bpf_prog *prog, u32 kfunc_id)\n--\nfs/binfmt_misc_bpf.c-287-\t\treturn 0;\nfs/binfmt_misc_bpf.c:288:\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS)\nfs/binfmt_misc_bpf.c-289-\t\treturn -EACCES;\n--\nfs/binfmt_misc_bpf.c=321=static int bm_bpf_init(struct btf *btf)\nfs/binfmt_misc_bpf.c-322-{\nfs/binfmt_misc_bpf.c:323:\treturn register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nfs/binfmt_misc_bpf.c-324-\t\t\t\t\t \u0026bm_bpf_kfunc_set);\n--\nfs/bpf_fs_kfuncs.c=530=static int bpf_fs_kfuncs_filter(const struct bpf_prog *prog, u32 kfunc_id)\n--\nfs/bpf_fs_kfuncs.c-543-\t\treturn 0;\nfs/bpf_fs_kfuncs.c:544:\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS)\nfs/bpf_fs_kfuncs.c-545-\t\treturn -EACCES;\n--\nfs/bpf_fs_kfuncs.c=591=static int __init bpf_fs_kfuncs_init(void)\n--\nfs/bpf_fs_kfuncs.c-597-\t\treturn ret;\nfs/bpf_fs_kfuncs.c:598:\treturn register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nfs/bpf_fs_kfuncs.c-599-\t\t\t\t\t \u0026bpf_fs_kfunc_set);\n--\ninclude/linux/bpf.h=2090=struct btf_member;\n--\ninclude/linux/bpf.h-2095- *\t\t\t define a BPF_MAP_TYPE_STRUCT_OPS map type composed\ninclude/linux/bpf.h:2096: *\t\t\t of BPF_PROG_TYPE_STRUCT_OPS progs.\ninclude/linux/bpf.h-2097- * @verifier_ops: A structure of callbacks that are invoked by the verifier\n--\ninclude/linux/bpf_types.h=67=BPF_PROG_TYPE(BPF_PROG_TYPE_SK_LOOKUP, sk_lookup,\n--\ninclude/linux/bpf_types.h-70-#if defined(CONFIG_BPF_JIT)\ninclude/linux/bpf_types.h:71:BPF_PROG_TYPE(BPF_PROG_TYPE_STRUCT_OPS, bpf_struct_ops,\ninclude/linux/bpf_types.h-72-\t void *, void *)\n--\ninclude/linux/bpf_verifier.h=1368=static inline bool bpf_prog_check_recur(const struct bpf_prog *prog)\n--\ninclude/linux/bpf_verifier.h-1372-\t\treturn prog-\u003eexpected_attach_type != BPF_TRACE_ITER;\ninclude/linux/bpf_verifier.h:1373:\tcase BPF_PROG_TYPE_STRUCT_OPS:\ninclude/linux/bpf_verifier.h-1374-\t\treturn prog-\u003eaux-\u003ejits_use_priv_stack;\n--\ninclude/uapi/linux/bpf.h=1062=enum bpf_prog_type {\n--\ninclude/uapi/linux/bpf.h-1089-\tBPF_PROG_TYPE_TRACING,\ninclude/uapi/linux/bpf.h:1090:\tBPF_PROG_TYPE_STRUCT_OPS,\ninclude/uapi/linux/bpf.h-1091-\tBPF_PROG_TYPE_EXT,\n--\nio_uring/bpf-ops.c=120=static int bpf_io_init(struct btf *btf)\n--\nio_uring/bpf-ops.c-129-\nio_uring/bpf-ops.c:130:\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nio_uring/bpf-ops.c-131-\t\t\t\t\t\u0026bpf_io_uring_kfunc_set);\n--\nkernel/bpf/bpf_struct_ops.c=727=static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,\n--\nkernel/bpf/bpf_struct_ops.c-846-\nkernel/bpf/bpf_struct_ops.c:847:\t\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS ||\nkernel/bpf/bpf_struct_ops.c-848-\t\t prog-\u003eaux-\u003eattach_btf_id != st_ops_desc-\u003etype_id ||\n--\nkernel/bpf/bpf_struct_ops.c=1540=int bpf_prog_assoc_struct_ops(struct bpf_prog *prog, struct bpf_map *map)\n--\nkernel/bpf/bpf_struct_ops.c-1551-\tif (st_ops_assoc) {\nkernel/bpf/bpf_struct_ops.c:1552:\t\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS)\nkernel/bpf/bpf_struct_ops.c-1553-\t\t\treturn -EBUSY;\n--\nkernel/bpf/bpf_struct_ops.c-1560-\t\t */\nkernel/bpf/bpf_struct_ops.c:1561:\t\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS)\nkernel/bpf/bpf_struct_ops.c-1562-\t\t\tbpf_map_inc(map);\n--\nkernel/bpf/bpf_struct_ops.c=1570=void bpf_prog_disassoc_struct_ops(struct bpf_prog *prog)\n--\nkernel/bpf/bpf_struct_ops.c-1580-\nkernel/bpf/bpf_struct_ops.c:1581:\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS)\nkernel/bpf/bpf_struct_ops.c-1582-\t\tbpf_map_put(st_ops_assoc);\n--\nkernel/bpf/btf.c=6249=static int btf_validate_prog_ctx_type(struct bpf_verifier_log *log, const struct btf *btf,\n--\nkernel/bpf/btf.c-6341-\tcase BPF_PROG_TYPE_LSM:\nkernel/bpf/btf.c:6342:\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/btf.c-6343-\t\t/* allow u64* as ctx */\n--\nkernel/bpf/btf.c=6648=static bool prog_args_trusted(const struct bpf_prog *prog)\n--\nkernel/bpf/btf.c-6656-\t\treturn bpf_lsm_is_trusted(prog);\nkernel/bpf/btf.c:6657:\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/btf.c-6658-\t\treturn true;\n--\nkernel/bpf/btf.c=9160=static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type)\n--\nkernel/bpf/btf.c-9168-\t\treturn BTF_KFUNC_HOOK_TC;\nkernel/bpf/btf.c:9169:\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/btf.c-9170-\t\treturn BTF_KFUNC_HOOK_STRUCT_OPS;\n--\nkernel/bpf/core.c=2503=static bool __bpf_prog_map_compatible(struct bpf_map *map,\n--\nkernel/bpf/core.c-2555-\t\t\tcase BPF_PROG_TYPE_EXT:\nkernel/bpf/core.c:2556:\t\t\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/core.c-2557-\t\t\t\tret = false;\n--\nkernel/bpf/cpumask.c=515=static int __init cpumask_kfunc_init(void)\n--\nkernel/bpf/cpumask.c-526-\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, \u0026cpumask_kfunc_set);\nkernel/bpf/cpumask.c:527:\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026cpumask_kfunc_set);\nkernel/bpf/cpumask.c-528-\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, \u0026cpumask_kfunc_set);\n--\nkernel/bpf/helpers.c=5113=static int __init kfunc_init(void)\n--\nkernel/bpf/helpers.c-5131-\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, \u0026generic_kfunc_set);\nkernel/bpf/helpers.c:5132:\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026generic_kfunc_set);\nkernel/bpf/helpers.c-5133-\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, \u0026generic_kfunc_set);\n--\nkernel/bpf/syscall.c=2731=bpf_prog_load_check_attach(enum bpf_prog_type prog_type,\n--\nkernel/bpf/syscall.c-2746-\t\tcase BPF_PROG_TYPE_LSM:\nkernel/bpf/syscall.c:2747:\t\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/syscall.c-2748-\t\tcase BPF_PROG_TYPE_EXT:\n--\nkernel/bpf/syscall.c=2877=static bool is_perfmon_prog_type(enum bpf_prog_type prog_type)\n--\nkernel/bpf/syscall.c-2886-\tcase BPF_PROG_TYPE_LSM:\nkernel/bpf/syscall.c:2887:\tcase BPF_PROG_TYPE_STRUCT_OPS: /* has access to struct sock */\nkernel/bpf/syscall.c-2888-\tcase BPF_PROG_TYPE_EXT: /* extends any prog */\n--\nkernel/bpf/syscall.c=6266=static int prog_assoc_struct_ops(union bpf_attr *attr)\n--\nkernel/bpf/syscall.c-6281-\nkernel/bpf/syscall.c:6282:\tif (prog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS) {\nkernel/bpf/syscall.c-6283-\t\tret = -EINVAL;\n--\nkernel/bpf/verifier.c=5326=static enum priv_stack_mode bpf_enable_priv_stack(struct bpf_prog *prog)\n--\nkernel/bpf/verifier.c-5342-\tcase BPF_PROG_TYPE_LSM:\nkernel/bpf/verifier.c:5343:\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/verifier.c-5344-\t\tif (prog-\u003eaux-\u003epriv_stack_requested || bpf_prog_check_recur(prog))\n--\nkernel/bpf/verifier.c=11274=static int check_reference_leak(struct bpf_verifier_env *env, bool exception_exit)\n--\nkernel/bpf/verifier.c-11290-\t\t */\nkernel/bpf/verifier.c:11291:\t\tif (type == BPF_PROG_TYPE_STRUCT_OPS \u0026\u0026 !exception_exit \u0026\u0026\nkernel/bpf/verifier.c-11292-\t\t reg-\u003eid == state-\u003erefs[i].id)\n--\nkernel/bpf/verifier.c=17793=static bool return_retval_range(struct bpf_verifier_env *env, struct bpf_retval_range *range)\n--\nkernel/bpf/verifier.c-17887-\t\tbreak;\nkernel/bpf/verifier.c:17888:\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/verifier.c-17889-\t\t*range = retval_range(0, 0);\n--\nkernel/bpf/verifier.c=17904=static bool program_returns_void(struct bpf_verifier_env *env)\n--\nkernel/bpf/verifier.c-17915-\t\tbreak;\nkernel/bpf/verifier.c:17916:\tcase BPF_PROG_TYPE_STRUCT_OPS:\nkernel/bpf/verifier.c-17917-\t\tif (!prog-\u003eaux-\u003eattach_func_proto-\u003etype)\n--\nkernel/bpf/verifier.c=17936=static int check_return_code(struct bpf_verifier_env *env, int regno, const char *reg_name)\n--\nkernel/bpf/verifier.c-17951-\nkernel/bpf/verifier.c:17952:\tif (prog_type == BPF_PROG_TYPE_STRUCT_OPS) {\nkernel/bpf/verifier.c-17953-\t\t/* Allow a struct_ops program to return a referenced kptr if it\n--\nkernel/bpf/verifier.c-17985-\nkernel/bpf/verifier.c:17986:\tif (prog_type == BPF_PROG_TYPE_STRUCT_OPS \u0026\u0026 !ret_type)\nkernel/bpf/verifier.c-17987-\t\treturn 0;\n--\nkernel/bpf/verifier.c=19857=static int do_check_common(struct bpf_verifier_env *env, int subprog)\n--\nkernel/bpf/verifier.c-19993-\t/* Acquire references for struct_ops program arguments tagged with \"__ref\" */\nkernel/bpf/verifier.c:19994:\tif (!subprog \u0026\u0026 env-\u003eprog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS) {\nkernel/bpf/verifier.c-19995-\t\tfor (i = 0; i \u003c aux-\u003ectx_arg_info_size; i++) {\n--\nkernel/bpf/verifier.c=20869=static bool can_be_sleepable(struct bpf_prog *prog)\n--\nkernel/bpf/verifier.c-20890-\treturn prog-\u003etype == BPF_PROG_TYPE_KPROBE /* only for uprobes */ ||\nkernel/bpf/verifier.c:20891:\t prog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS ||\nkernel/bpf/verifier.c-20892-\t prog-\u003etype == BPF_PROG_TYPE_RAW_TRACEPOINT ||\n--\nkernel/bpf/verifier.c=20896=static int check_attach_btf_id(struct bpf_verifier_env *env)\n--\nkernel/bpf/verifier.c-20918-\nkernel/bpf/verifier.c:20919:\tif (prog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS)\nkernel/bpf/verifier.c-20920-\t\treturn check_struct_ops_btf_id(env);\n--\nkernel/sched/ext/cid.c=1160=int scx_cid_kfunc_init(void)\nkernel/sched/ext/cid.c-1161-{\nkernel/sched/ext/cid.c:1162:\treturn register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026scx_kfunc_set_init_cids) ?:\nkernel/sched/ext/cid.c:1163:\t\tregister_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026scx_kfunc_set_cid) ?:\nkernel/sched/ext/cid.c-1164-\t\tregister_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, \u0026scx_kfunc_set_cid) ?:\n--\nkernel/sched/ext/ext.c=10783=static const u32 scx_kf_allow_flags[] = {\n--\nkernel/sched/ext/ext.c-10811- * each per-group btf_kfunc_id_set. The BPF core invokes this for every kfunc\nkernel/sched/ext/ext.c:10812: * call in the registered hook (BPF_PROG_TYPE_STRUCT_OPS or\nkernel/sched/ext/ext.c-10813- * BPF_PROG_TYPE_SYSCALL), regardless of which set originally introduced the\n--\nkernel/sched/ext/ext.c=10817=int scx_kfunc_context_filter(const struct bpf_prog *prog, u32 kfunc_id)\n--\nkernel/sched/ext/ext.c-10839-\nkernel/sched/ext/ext.c:10840:\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS)\nkernel/sched/ext/ext.c-10841-\t\treturn (in_any || in_idle || in_cid) ? 0 : -EACCES;\n--\nkernel/sched/ext/ext.c=10898=static int __init scx_init(void)\n--\nkernel/sched/ext/ext.c-10986-\t */\nkernel/sched/ext/ext.c:10987:\tif ((ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nkernel/sched/ext/ext.c-10988-\t\t\t\t\t \u0026scx_kfunc_set_enqueue_dispatch)) ||\nkernel/sched/ext/ext.c:10989:\t (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nkernel/sched/ext/ext.c-10990-\t\t\t\t\t \u0026scx_kfunc_set_dispatch)) ||\nkernel/sched/ext/ext.c:10991:\t (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nkernel/sched/ext/ext.c-10992-\t\t\t\t\t \u0026scx_kfunc_set_cpu_release)) ||\nkernel/sched/ext/ext.c:10993:\t (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nkernel/sched/ext/ext.c-10994-\t\t\t\t\t \u0026scx_kfunc_set_unlocked)) ||\n--\nkernel/sched/ext/ext.c-10996-\t\t\t\t\t \u0026scx_kfunc_set_unlocked)) ||\nkernel/sched/ext/ext.c:10997:\t (ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nkernel/sched/ext/ext.c-10998-\t\t\t\t\t \u0026scx_kfunc_set_any)) ||\n--\nkernel/sched/ext/idle.c=1554=int scx_idle_init(void)\nkernel/sched/ext/idle.c-1555-{\nkernel/sched/ext/idle.c:1556:\treturn register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026scx_kfunc_set_idle) ?:\nkernel/sched/ext/idle.c-1557-\t register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, \u0026scx_kfunc_set_idle) ?:\nkernel/sched/ext/idle.c-1558-\t register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, \u0026scx_kfunc_set_idle) ?:\nkernel/sched/ext/idle.c:1559:\t register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026scx_kfunc_set_select_cpu) ?:\nkernel/sched/ext/idle.c-1560-\t register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, \u0026scx_kfunc_set_select_cpu);\n--\nnet/core/filter.c=12889=static int __init bpf_kfunc_init(void)\n--\nnet/core/filter.c-12903-\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, \u0026bpf_kfunc_set_skb);\nnet/core/filter.c:12904:\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026bpf_kfunc_set_skb);\nnet/core/filter.c-12905-\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, \u0026bpf_kfunc_set_skb_meta);\n--\nnet/ipv4/bpf_tcp_ca.c=361=static int __init bpf_tcp_ca_kfunc_init(void)\n--\nnet/ipv4/bpf_tcp_ca.c-364-\nnet/ipv4/bpf_tcp_ca.c:365:\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026bpf_tcp_ca_kfunc_set);\nnet/ipv4/bpf_tcp_ca.c-366-\tret = ret ?: register_bpf_struct_ops(\u0026bpf_tcp_congestion_ops, tcp_congestion_ops);\n--\nnet/ipv4/bpf_tcp_ops.c=419=static int __init __bpf_tcp_ops_init(void)\n--\nnet/ipv4/bpf_tcp_ops.c-422-\nnet/ipv4/bpf_tcp_ops.c:423:\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,\nnet/ipv4/bpf_tcp_ops.c-424-\t\t\t\t\t\u0026bpf_tcp_ops_rcvlowat_kfunc_id_set);\n--\nnet/ipv4/tcp_bbr.c=1175=static int __init bbr_register(void)\n--\nnet/ipv4/tcp_bbr.c-1180-\nnet/ipv4/tcp_bbr.c:1181:\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026tcp_bbr_kfunc_set);\nnet/ipv4/tcp_bbr.c-1182-\tif (ret \u003c 0)\n--\nnet/ipv4/tcp_cubic.c=501=static int __init cubictcp_register(void)\n--\nnet/ipv4/tcp_cubic.c-534-\nnet/ipv4/tcp_cubic.c:535:\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026tcp_cubic_kfunc_set);\nnet/ipv4/tcp_cubic.c-536-\tif (ret \u003c 0)\n--\nnet/ipv4/tcp_dctcp.c=294=static int __init dctcp_register(void)\n--\nnet/ipv4/tcp_dctcp.c-299-\nnet/ipv4/tcp_dctcp.c:300:\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026tcp_dctcp_kfunc_set);\nnet/ipv4/tcp_dctcp.c-301-\tif (ret \u003c 0)\n--\nnet/sched/bpf_qdisc.c=458=static int __init bpf_qdisc_kfunc_init(void)\n--\nnet/sched/bpf_qdisc.c-467-\nnet/sched/bpf_qdisc.c:468:\tret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026bpf_qdisc_kfunc_set);\nnet/sched/bpf_qdisc.c-469-\tret = ret ?: register_btf_id_dtor_kfuncs(skb_kfunc_dtors,\n--\ntools/include/uapi/linux/bpf.h=1062=enum bpf_prog_type {\n--\ntools/include/uapi/linux/bpf.h-1089-\tBPF_PROG_TYPE_TRACING,\ntools/include/uapi/linux/bpf.h:1090:\tBPF_PROG_TYPE_STRUCT_OPS,\ntools/include/uapi/linux/bpf.h-1091-\tBPF_PROG_TYPE_EXT,\n--\ntools/lib/bpf/libbpf.c=202=static const char * const prog_type_name[] = {\n--\ntools/lib/bpf/libbpf.c-229-\t[BPF_PROG_TYPE_TRACING]\t\t\t= \"tracing\",\ntools/lib/bpf/libbpf.c:230:\t[BPF_PROG_TYPE_STRUCT_OPS]\t\t= \"struct_ops\",\ntools/lib/bpf/libbpf.c-231-\t[BPF_PROG_TYPE_EXT]\t\t\t= \"ext\",\n--\ntools/lib/bpf/libbpf.c=1116=static bool is_valid_st_ops_program(struct bpf_object *obj,\n--\ntools/lib/bpf/libbpf.c-1122-\t\tif (\u0026obj-\u003eprograms[i] == prog)\ntools/lib/bpf/libbpf.c:1123:\t\t\treturn prog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS;\ntools/lib/bpf/libbpf.c-1124-\t}\n--\ntools/lib/bpf/libbpf.c=1134=static int bpf_object_adjust_struct_ops_autoload(struct bpf_object *obj)\n--\ntools/lib/bpf/libbpf.c-1144-\t\tprog = \u0026obj-\u003eprograms[i];\ntools/lib/bpf/libbpf.c:1145:\t\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS)\ntools/lib/bpf/libbpf.c-1146-\t\t\tcontinue;\n--\ntools/lib/bpf/libbpf.c=3555=static bool prog_needs_vmlinux_btf(struct bpf_program *prog)\ntools/lib/bpf/libbpf.c-3556-{\ntools/lib/bpf/libbpf.c:3557:\tif (prog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS ||\ntools/lib/bpf/libbpf.c-3558-\t prog-\u003etype == BPF_PROG_TYPE_LSM)\n--\ntools/lib/bpf/libbpf.c=7997=static int bpf_object_load_prog(struct bpf_object *obj, struct bpf_program *prog,\n--\ntools/lib/bpf/libbpf.c-8020-\t\treturn -EINVAL;\ntools/lib/bpf/libbpf.c:8021:\tcase BPF_PROG_TYPE_STRUCT_OPS:\ntools/lib/bpf/libbpf.c-8022-\t\tif (prog-\u003eattach_btf_id == 0) {\n--\ntools/lib/bpf/libbpf.c=10586=static int bpf_object__collect_st_ops_relos(struct bpf_object *obj,\n--\ntools/lib/bpf/libbpf.c-10672-\t\t/* prevent the use of BPF prog with invalid type */\ntools/lib/bpf/libbpf.c:10673:\t\tif (prog-\u003etype != BPF_PROG_TYPE_STRUCT_OPS) {\ntools/lib/bpf/libbpf.c-10674-\t\t\tpr_warn(\"struct_ops reloc %s: prog %s is not struct_ops BPF program\\n\",\n--\ntools/lib/bpf/libbpf.c=14953=int bpf_program__assoc_struct_ops(struct bpf_program *prog, struct bpf_map *map,\n--\ntools/lib/bpf/libbpf.c-14964-\ntools/lib/bpf/libbpf.c:14965:\tif (prog-\u003etype == BPF_PROG_TYPE_STRUCT_OPS) {\ntools/lib/bpf/libbpf.c-14966-\t\tpr_warn(\"prog '%s': can't associate struct_ops program\\n\", prog-\u003ename);\n--\ntools/lib/bpf/libbpf_probes.c=106=static int probe_prog_load(enum bpf_prog_type prog_type,\n--\ntools/lib/bpf/libbpf_probes.c-160-\t\tbreak;\ntools/lib/bpf/libbpf_probes.c:161:\tcase BPF_PROG_TYPE_STRUCT_OPS:\ntools/lib/bpf/libbpf_probes.c-162-\t\texp_err = -524; /* -ENOTSUPP */\n--\ntools/lib/bpf/libbpf_probes.c=436=int libbpf_probe_bpf_helper(enum bpf_prog_type prog_type, enum bpf_func_id helper_id,\n--\ntools/lib/bpf/libbpf_probes.c-456-\tcase BPF_PROG_TYPE_LSM:\ntools/lib/bpf/libbpf_probes.c:457:\tcase BPF_PROG_TYPE_STRUCT_OPS:\ntools/lib/bpf/libbpf_probes.c-458-\t\treturn -EOPNOTSUPP;\n--\ntools/sched_ext/include/scx/compat.h=357=static inline void __scx_ops_assoc_prog(struct bpf_program *prog,\n--\ntools/sched_ext/include/scx/compat.h-369-\tbpf_object__for_each_program(__prog, (__skel)-\u003eobj) {\t\t\t\\\ntools/sched_ext/include/scx/compat.h:370:\t\tif (bpf_program__type(__prog) == BPF_PROG_TYPE_STRUCT_OPS)\t\\\ntools/sched_ext/include/scx/compat.h-371-\t\t\tcontinue;\t\t\t\t\t\t\\\n--\ntools/testing/selftests/bpf/prog_tests/token.c=1143=void serial_test_token(void)\n--\ntools/testing/selftests/bpf/prog_tests/token.c-1206-\t\t\t.maps = bit(BPF_MAP_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c:1207:\t\t\t.progs = bit(BPF_PROG_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c-1208-\t\t\t.attachs = ~0ULL,\n--\ntools/testing/selftests/bpf/prog_tests/token.c-1217-\t\t\t.maps = bit(BPF_MAP_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c:1218:\t\t\t.progs = bit(BPF_PROG_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c-1219-\t\t\t.attachs = ~0ULL,\n--\ntools/testing/selftests/bpf/prog_tests/token.c-1228-\t\t\t.maps = bit(BPF_MAP_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c:1229:\t\t\t.progs = bit(BPF_PROG_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c-1230-\t\t\t.attachs = ~0ULL,\n--\ntools/testing/selftests/bpf/prog_tests/token.c-1239-\t\t\t.maps = bit(BPF_MAP_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c:1240:\t\t\t.progs = bit(BPF_PROG_TYPE_STRUCT_OPS),\ntools/testing/selftests/bpf/prog_tests/token.c-1241-\t\t\t.attachs = ~0ULL,\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c=2431=static int bpf_testmod_init(void)\n--\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-2445-\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SYSCALL, \u0026bpf_testmod_kfunc_set);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c:2446:\tret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS, \u0026bpf_testmod_kfunc_set);\ntools/testing/selftests/bpf/test_kmods/bpf_testmod.c-2447-\tret = ret ?: register_btf_fmodret_id_set(\u0026bpf_testmod_trampoline_count_fmodret_set);\n"
} |
| 29/2 | 2026/09/26 03:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 60277 output: 32 thoughts: 121 Thoughts: Okay, let's see. My first thought is to dig into the BPF code. I need to understand how `BPF_PROG_TYPE_STRUCT_OPS` works, so I'll start by checking the definition in `include/linux/bpf_types.h`. Specifically, I'm looking for the macro `BPF_PROG_TYPE(BPF_PROG_TYPE_STRUCT_OPS, ...)`. Ah, here it is: **Examining BPF_PROG_TYPE and Struct Ops** ```c #if defined(CONFIG_BPF_JIT) BPF_PROG_TYPE(BPF_PROG_TYPE_STRUCT_OPS, bpf_struct_ops, void *, void *) ``` Good, I see it's conditionally compiled based on `CONFIG_BPF_JIT`. Now, I need to figure out which code actually uses and builds the associated `bpf_struct_ops.c`. I will now shift my attention to `kernel/bpf/Makefile` to see how it's linked into the build process. From there, I should be able to trace how this particular program type is defined and built. |
| 30/2 | 2026/09/26 03:07 | tool | grepper |
0mArgs:{
"Expression": "bpf_struct_ops\\.o",
"PathPrefix": "kernel/bpf"
}Results: {
"Output": "kernel/bpf/Makefile=46=ifeq ($(CONFIG_BPF_JIT),y)\nkernel/bpf/Makefile:47:obj-$(CONFIG_BPF_SYSCALL) += bpf_struct_ops.o\nkernel/bpf/Makefile-48-obj-$(CONFIG_BPF_SYSCALL) += cpumask.o\n"
} |
| 31/2 | 2026/09/26 03:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 60787 output: 29 thoughts: 918 Thoughts: **Analyzing the bpf_tcp_ops Integration** Okay, so I'm digging into this `bpf_tcp_ops.o` module. I see it's built conditionally on `CONFIG_BPF_JIT` and `CONFIG_BPF_SYSCALL`. Looking at the makefile logic, it's clear we also need `CONFIG_CGROUP_BPF` to enable `bpf_tcp_ops.o`, and, since it involves TCP, naturally `CONFIG_INET`. Also, the dependencies imply `DEBUG_INFO_BTF`. Therefore, the necessary base configuration should involve `INET`, `BPF_SYSCALL`, `BPF_JIT`, `CGROUP_BPF`, and `DEBUG_INFO_BTF`. I need to check for dependencies, naturally `CGROUP_BPF` depends on `CGROUPS`, and `DEBUG_INFO_BTF` depends on `DEBUG_INFO`. Now, let's trace the symbol modifications and additions to understand the impact: * I've got a new kfunc `bpf_tcp_ops_set_rcvlowat` in `net/ipv4/bpf_tcp_ops.c`, which is the core functionality. * Then a new BPF helper `bpf_tcp_ops_cb_flags_set`, in the same file. * I'm seeing `__tcp_set_rcvlowat` and a modified `tcp_set_rcvlowat` in `net/ipv4/tcp.c` - so this new helper is going to be core to any modification of `rcvlowat` . * `tcp_set_sock_ops_cb_flags` is an inline helper, which means I won't have a distinct symbol in `vmlinux`. * A modified BPF helper `bpf_sock_ops_cb_flags_set` which makes a call to that inline helper. * And a modified `bpf_sol_tcp_setsockopt`, also calling that inline helper. * Lastly a filter function, `bpf_tcp_ops_rcvlowat_kfunc_filter`, also in `net/ipv4/bpf_tcp_ops.c`. Okay, but what about the hook points? Specifically, the `bpf_tcp_ops_enqueue_rcvq` and `bpf_tcp_ops_dequeue_rcvq` calls. These are static inlines in `include/net/tcp.h` - I'll need to figure out where those inline functions are actually *used*. They are called from: * `tcp_cleanup_rbuf` in `net/ipv4/tcp.c` (dequeue) * `tcp_fastopen_add_skb` in `net/ipv4/tcp_fastopen.c` (enqueue) * `tcp_ofo_queue` in `net/ipv4/tcp_input.c` (enqueue) * `tcp_queue_rcv` in `net/ipv4/tcp_input.c` (enqueue) Now, I need to verify whether `tcp_ofo_queue` is static or exported, since it's going to be essential for BPF hooks. I need to check `net/ipv4/tcp_input.c`. |
| 32/2 | 2026/09/26 03:07 | tool | grepper |
0mArgs:{
"Expression": "tcp_ofo_queue",
"PathPrefix": "net/ipv4"
}Results: {
"Output": "net/ipv4/tcp_input.c=5309=tcp_drop_reason(struct sock *sk, struct sk_buff *skb, enum skb_drop_reason reason)\n--\nnet/ipv4/tcp_input.c-5317- */\nnet/ipv4/tcp_input.c:5318:static void tcp_ofo_queue(struct sock *sk)\nnet/ipv4/tcp_input.c-5319-{\n--\nnet/ipv4/tcp_input.c=5623=static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/tcp_input.c-5692-\t\tif (!RB_EMPTY_ROOT(\u0026tp-\u003eout_of_order_queue)) {\nnet/ipv4/tcp_input.c:5693:\t\t\ttcp_ofo_queue(sk);\nnet/ipv4/tcp_input.c-5694-\n"
} |
| 33/2 | 2026/09/26 03:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 62721 output: 24 thoughts: 1009 Thoughts: **Focus Symbol Decision for TCP Feature** Okay, let's break this down for the fuzzing focus symbols. I was initially concerned about including `tcp_cleanup_rbuf` because it's called by `tcp_recvmsg` and could make it too ubiquitous, as syzkaller hits it *a lot*. That would be a problem as per Section 4's guidelines: Avoid listing generic, ubiquitous functions. We want to avoid diluting the fuzzing effort. The text clearly states that we need to **TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS**. But, `tcp_cleanup_rbuf` is not specific enough. So, where's the actual feature logic? Focus on the relevant, specific parts, not the generic TCP stuff. I need to focus on the changes for this specific feature. Let's see... `bpf_tcp_ops_set_rcvlowat`, `bpf_tcp_ops_cb_flags_set`, `__tcp_set_rcvlowat`, `tcp_set_rcvlowat`, `bpf_sock_ops_cb_flags_set`, `bpf_sol_tcp_setsockopt`, `bpf_tcp_ops_rcvlowat_kfunc_filter`, and `tcp_fastopen_add_skb`. Now, is `tcp_set_rcvlowat` ubiquitous? No, it's only called when `setsockopt` with `SO_RCVLOWAT` is invoked, so it's fine. `__tcp_set_rcvlowat` is only called by `tcp_set_rcvlowat` and `bpf_tcp_ops_set_rcvlowat`. Those should be okay too. Now, which of these functions are accessible and not inlined? * `bpf_tcp_ops_set_rcvlowat` is the new kfunc. It is `__bpf_kfunc`, noinline, global! * `bpf_tcp_ops_cb_flags_set` is the new struct\_ops BPF helper, and its address is passed, so not inlined! * `bpf_sock_ops_cb_flags_set` is the BPF helper modified to use the new flag validation and support `BPF_SOCK_OPS_RCVQ_CB_FLAG`. This looks okay too. * `bpf_sol_tcp_setsockopt` is the helper in filter.c modified to handle `TCP_BPF_SOCK_OPS_CB_FLAGS` using `tcp_set_sock_ops_cb_flags`. Let me double-check. * `tcp_fastopen_add_skb` is fastopen specific. Also, okay. So, let's check `is_sockopt_supported`. It's static. Can static functions be FocusSymbols? Yes, if not inlined. `bpf_tcp_ops_rcvlowat_kfunc_filter` is static too, but its address is passed to `struct btf_kfunc_id_set`, so it won't be inlined. That's a strong indication. `bpf_tcp_ops_set_rcvlowat` is definitely good! Non-inlined, global. `bpf_tcp_ops_cb_flags_set` looks good too because the proto struct has `.func = bpf_tcp_ops_cb_flags_set`. `__tcp_set_rcvlowat` and `tcp_set_rcvlowat` are both non-static, declared in a header. `bpf_sock_ops_cb_flags_set` is not inlined, either, proto struct uses `.func = bpf_sock_ops_cb_flags_set`. All of those (but `tcp_cleanup_rbuf`) appear to be sound choices. No ubiquitous function to worry about! |
| 34/2 | 2026/09/26 03:07 | tool | grepper |
0mArgs:{
"Expression": "bpf_sol_tcp_setsockopt"
}Results: {
"Output": "net/core/filter.c=5517=static int bpf_sol_tcp_getsockopt(struct sock *sk, int optname,\n--\nnet/core/filter.c-5548-\nnet/core/filter.c:5549:static int bpf_sol_tcp_setsockopt(struct sock *sk, int optname,\nnet/core/filter.c-5550-\t\t\t\t char *optval, int optlen)\n--\nnet/core/filter.c=5652=static int sol_tcp_sockopt(struct sock *sk, int optname,\n--\nnet/core/filter.c-5683-\t\t\treturn bpf_sol_tcp_getsockopt(sk, optname, optval, *optlen);\nnet/core/filter.c:5684:\t\treturn bpf_sol_tcp_setsockopt(sk, optname, optval, *optlen);\nnet/core/filter.c-5685-\t}\n"
} |
| 35/2 | 2026/09/26 03:07 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 64868 output: 332 thoughts: 835 Thoughts: **Analysis of Recent TCP and BPF Enhancements** Okay, so `bpf_sol_tcp_setsockopt` is static, which means it doesn't have a direct symbol. Let's see... what about `tcp_set_sock_ops_cb_flags`? That's defined inline in `include/net/tcp.h`, so no distinct symbol there either. Alright, now to confirm the fuzzability. `WorthFuzzing` is definitely `true`, no question about it. This is interesting: we've got new BPF `struct_ops` hooks for TCP receive queue operations (`enqueue_rcvq`, `dequeue_rcvq`), and a new BPF flag `BPF_SOCK_OPS_RCVQ_CB_FLAG`. Plus, a new kfunc, `bpf_tcp_ops_set_rcvlowat`, and a helper, `bpf_tcp_ops_cb_flags_set`. The setsockopt handling and lowat wakeup logic in TCP has also been modified. Given that this affects both core networking and BPF, and both are accessible via standard syscalls and BPF programs in a VM, this is definitely a good target. Let's double-check the required kernel configs. We need `INET` for the TCP protocol, `BPF_SYSCALL` for the eBPF syscall interface, `CGROUP_BPF` for `bpf_tcp_ops.c` (that's the `obj-$(CONFIG_CGROUP_BPF) += bpf_tcp_ops.o` part), and `BPF_JIT` for both struct_ops and bpf_tcp_ops.o based on the `ifeq ($(CONFIG_BPF_JIT),y)` dependency. And, of course, `DEBUG_INFO_BTF` is essential for BTF IDs, kfuncs, and struct_ops registration. Looking at `net/ipv4/Makefile`, `CONFIG_INET` is the parent for `net/ipv4/`, and the JIT is definitely a dependency. Specifically, `CONFIG_CGROUP_BPF` relies on `CONFIG_BPF_SYSCALL` and `CONFIG_CGROUPS`. `DEBUG_INFO_BTF` is needed for kfunc and struct_ops BTF registration, and `CONFIG_BPF_JIT` is definitely needed for struct_ops. Now, let's review the critical symbols. I have: - `bpf_tcp_ops_set_rcvlowat`: A new kfunc in `net/ipv4/bpf_tcp_ops.c`. - `bpf_tcp_ops_cb_flags_set`: A new BPF helper in `net/ipv4/bpf_tcp_ops.c`. - `bpf_tcp_ops_rcvlowat_kfunc_filter`: A Kfunc filter in `net/ipv4/bpf_tcp_ops.c` - `__tcp_set_rcvlowat`: The core function modified in `net/ipv4/tcp.c` - `tcp_set_rcvlowat`: A wrapper in `net/ipv4/tcp.c`. - `bpf_sock_ops_cb_flags_set`: A helper modified in `net/core/filter.c` - `bpf_sol_tcp_setsockopt`: A setsockopt handler modified in `net/core/filter.c`. - `tcp_fastopen_add_skb`: A TCP FastOpen enqueue hook modified in `net/ipv4/tcp_fastopen.c`. It looks like everything is in order based on the source code. Let's get the tool call ready to `set-results`. |
| 36/2 | 2026/09/26 03:07 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"INET",
"BPF_SYSCALL",
"BPF_JIT",
"CGROUP_BPF",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"bpf_tcp_ops_set_rcvlowat",
"bpf_tcp_ops_cb_flags_set",
"bpf_tcp_ops_rcvlowat_kfunc_filter",
"__tcp_set_rcvlowat",
"tcp_set_rcvlowat",
"bpf_sock_ops_cb_flags_set",
"bpf_sol_tcp_setsockopt",
"tcp_fastopen_add_skb"
],
"Reasoning": "The patch modifies core TCP stack and BPF logic by introducing new BPF struct_ops callbacks (enqueue_rcvq, dequeue_rcvq) triggered during TCP receive queue enqueue and dequeue events, a new BPF callback flag (BPF_SOCK_OPS_RCVQ_CB_FLAG), a new BPF helper (bpf_tcp_ops_cb_flags_set), a new kfunc (bpf_tcp_ops_set_rcvlowat), and refactoring TCP rcvlowat handling (__tcp_set_rcvlowat) with selective wakeup suppression. These changes are in reachable core networking/BPF paths and warrant fuzzing to identify potential races, lockdep violations, or assertion failures.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"INET",
"BPF_SYSCALL",
"BPF_JIT",
"CGROUP_BPF",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"bpf_tcp_ops_set_rcvlowat",
"bpf_tcp_ops_cb_flags_set",
"bpf_tcp_ops_rcvlowat_kfunc_filter",
"__tcp_set_rcvlowat",
"tcp_set_rcvlowat",
"bpf_sock_ops_cb_flags_set",
"bpf_sol_tcp_setsockopt",
"tcp_fastopen_add_skb"
],
"Reasoning": "The patch modifies core TCP stack and BPF logic by introducing new BPF struct_ops callbacks (enqueue_rcvq, dequeue_rcvq) triggered during TCP receive queue enqueue and dequeue events, a new BPF callback flag (BPF_SOCK_OPS_RCVQ_CB_FLAG), a new BPF helper (bpf_tcp_ops_cb_flags_set), a new kfunc (bpf_tcp_ops_set_rcvlowat), and refactoring TCP rcvlowat handling (__tcp_set_rcvlowat) with selective wakeup suppression. These changes are in reachable core networking/BPF paths and warrant fuzzing to identify potential races, lockdep violations, or assertion failures.",
"WorthFuzzing": true
} |
| 37/1 | 2026/09/26 03:07 | action | If |
1mArgs:{
"WorthFuzzing": true
}Results: null |
| 38/2 | 2026/09/26 03:07 | agent | kmsan-evaluator |
1mModel:core Args: null Results: {
"KMSANReasoning": "The patch series introduces two new callbacks to `struct bpf_tcp_ops` (`enqueue_rcvq` and `dequeue_rcvq`), adds a new callback flag `BPF_SOCK_OPS_RCVQ_CB_FLAG`, refactors `tcp_set_rcvlowat()` into `__tcp_set_rcvlowat()` with a `wakeup` parameter, exposes the `bpf_tcp_ops_set_rcvlowat` kfunc and `bpf_tcp_ops_cb_flags_set` helper, and adds corresponding selftests.\n\nAnalysis regarding KMSAN applicability:\n1. No uninitialized memory or info-leak risks:\n - No new heap/stack allocations or structures are copied to user space.\n - All local variables in newly added and modified functions (`val`, `err`, `moff`, `wakeup`) are explicitly and deterministically initialized before use.\n - The changes do not manipulate buffer sizes, data lengths, or padding in ways that could expose uninitialized data to reads or user space.\n2. Failure modes:\n - The primary risks introduced by this change involve socket locking assumptions, re-entrancy, or object lifetime/reference counting when executing BPF callbacks in TCP receive/cleanup paths (`tcp_fastopen_add_skb`, `tcp_ofo_queue`, `tcp_queue_rcv`, `tcp_cleanup_rbuf`).\n - These risks (use-after-free, null pointer dereference, locking/deadlock issues) are properly covered by KASAN and LOCKDEP.\n - KMSAN would provide no additional bug-finding value here over standard KASAN/LOCKDEP builds.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
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 aae1221aa43202109cc11e718b161f41f4587711
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Sep 26 03:06:07 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/net/tcp.h b/include/net/tcp.h
index d61ee00052e33..d3cf655da9ecd 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -512,6 +512,7 @@ void tcp_set_keepalive(struct sock *sk, int val);
void tcp_syn_ack_timeout(const struct request_sock *req);
int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int flags);
+int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup);
int tcp_set_rcvlowat(struct sock *sk, int val);
void tcp_set_rcvbuf(struct sock *sk, int val);
int tcp_set_window_clamp(struct sock *sk, int val);
@@ -2931,6 +2932,16 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2,
return tcp_call_bpf(sk, op, 3, args);
}
+static inline int tcp_set_sock_ops_cb_flags(struct sock *sk, int val)
+{
+ if (sk_is_mptcp(sk) &&
+ (val & BPF_SOCK_OPS_RCVQ_CB_FLAG))
+ return -EOPNOTSUPP;
+
+ tcp_sk(sk)->bpf_sock_ops_cb_flags = val;
+ return 0;
+}
+
static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk)
{
tcp_sk(sk)->bpf_sock_ops_cb_flags = 0;
@@ -2953,6 +2964,11 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2,
return -EPERM;
}
+static inline int tcp_set_sock_ops_cb_flags(struct sock *sk, int val)
+{
+ return -EOPNOTSUPP;
+}
+
static inline void tcp_clear_sock_ops_cb_flags(struct sock *sk)
{
}
@@ -3053,6 +3069,12 @@ struct bpf_tcp_ops {
struct request_sock *req, struct sk_buff *syn_skb,
enum tcp_synack_type synack_type,
u32 opt_off);
+
+ /* Called when an incoming skb is enqueued to sk->sk_receive_queue. */
+ void (*enqueue_rcvq)(struct sock *sk, struct sk_buff *skb);
+
+ /* Called after data is dequeued from sk->sk_receive_queue. */
+ void (*dequeue_rcvq)(struct sock *sk);
};
#define bpf_tcp_ops_call(op, sk, ...) \
@@ -3144,6 +3166,18 @@ static inline void tcp_bpf_rtt(struct sock *sk, long mrtt, u32 srtt)
bpf_tcp_ops_call(rtt, sk, mrtt, srtt);
}
+static inline void bpf_tcp_ops_enqueue_rcvq(struct sock *sk, struct sk_buff *skb)
+{
+ if (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RCVQ_CB_FLAG))
+ bpf_tcp_ops_call(enqueue_rcvq, sk, skb);
+}
+
+static inline void bpf_tcp_ops_dequeue_rcvq(struct sock *sk)
+{
+ if (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_RCVQ_CB_FLAG))
+ bpf_tcp_ops_call(dequeue_rcvq, sk);
+}
+
#if IS_ENABLED(CONFIG_SMC)
extern struct static_key_false tcp_have_smc;
#endif
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 6330b7d745c57..8cdf22667775f 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -3264,7 +3264,7 @@ union bpf_attr {
* Return
* 0
*
- * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)
+ * long bpf_sock_ops_cb_flags_set(void *bpf_sock, int argval)
* Description
* Attempt to set the value of the **bpf_sock_ops_cb_flags** field
* for the full TCP socket associated to *bpf_sock_ops* to
@@ -7148,8 +7148,17 @@ enum {
* options first before the BPF program does.
*/
BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1<<6),
+ /* Call bpf when the TCP stack enqueues/dequeues payload
+ * to/from sk->sk_receive_queue.
+ *
+ * Only bpf_tcp_ops is supported.
+ *
+ * It can be used to adjust sk->sk_rcvlowat and suppress
+ * unnecessary wakeups before sufficient data is available.
+ */
+ BPF_SOCK_OPS_RCVQ_CB_FLAG = (1<<7),
/* Mask of all currently supported cb flags */
- BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
+ BPF_SOCK_OPS_ALL_CB_FLAGS = 0xFF,
};
enum {
diff --git a/net/core/filter.c b/net/core/filter.c
index 5feb998846825..f29c061bb0664 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5588,8 +5588,7 @@ static int bpf_sol_tcp_setsockopt(struct sock *sk, int optname,
case TCP_BPF_SOCK_OPS_CB_FLAGS:
if (val & ~(BPF_SOCK_OPS_ALL_CB_FLAGS))
return -EINVAL;
- tp->bpf_sock_ops_cb_flags = val;
- break;
+ return tcp_set_sock_ops_cb_flags(sk, val);
default:
return -EINVAL;
}
@@ -6178,8 +6177,9 @@ static const struct bpf_func_proto bpf_sock_ops_getsockopt_proto = {
BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock,
int, argval)
{
- struct sock *sk = bpf_sock->sk;
int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS;
+ struct sock *sk = bpf_sock->sk;
+ int err;
if (!is_locked_tcp_sock_ops(bpf_sock))
return -EOPNOTSUPP;
@@ -6187,7 +6187,9 @@ BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock,
if (!IS_ENABLED(CONFIG_INET) || !sk_fullsock(sk))
return -EINVAL;
- tcp_sk(sk)->bpf_sock_ops_cb_flags = val;
+ err = tcp_set_sock_ops_cb_flags(sk, val);
+ if (err)
+ return err;
return argval & (~BPF_SOCK_OPS_ALL_CB_FLAGS);
}
diff --git a/net/ipv4/bpf_tcp_ops.c b/net/ipv4/bpf_tcp_ops.c
index 681fed6429999..e93c8d13684ef 100644
--- a/net/ipv4/bpf_tcp_ops.c
+++ b/net/ipv4/bpf_tcp_ops.c
@@ -76,6 +76,14 @@ static void write_hdr_opt_stub(struct sock *sk, struct sk_buff *skb,
{
}
+static void enqueue_rcvq_stub(struct sock *sk, struct sk_buff *skb)
+{
+}
+
+static void dequeue_rcvq_stub(struct sock *sk)
+{
+}
+
static struct bpf_tcp_ops __bpf_tcp_ops = {
.timeout_init = timeout_init_stub,
.rwnd_init = rwnd_init_stub,
@@ -90,6 +98,8 @@ static struct bpf_tcp_ops __bpf_tcp_ops = {
.parse_hdr = parse_hdr_stub,
.hdr_opt_len = hdr_opt_len_stub,
.write_hdr_opt = write_hdr_opt_stub,
+ .enqueue_rcvq = enqueue_rcvq_stub,
+ .dequeue_rcvq = dequeue_rcvq_stub,
};
BPF_CALL_4(bpf_tcp_ops_store_hdr_opt, void *, ctx, const void *, from,
@@ -210,6 +220,45 @@ const struct bpf_func_proto bpf_tcp_ops_get_retval_proto = {
.ret_type = RET_INTEGER,
};
+BPF_CALL_2(bpf_tcp_ops_cb_flags_set, struct sock *, sk, int, argval)
+{
+ int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS;
+ int err;
+
+ err = tcp_set_sock_ops_cb_flags(sk, val);
+ if (err)
+ return err;
+
+ return argval & ~BPF_SOCK_OPS_ALL_CB_FLAGS;
+}
+
+static const struct bpf_func_proto bpf_tcp_ops_cb_flags_set_proto = {
+ .func = bpf_tcp_ops_cb_flags_set,
+ .gpl_only = false,
+ .ret_type = RET_INTEGER,
+ .arg1_type = ARG_PTR_TO_BTF_ID,
+ .arg1_btf_id = &btf_sock_ids[BTF_SOCK_TYPE_TCP],
+ .arg2_type = ARG_ANYTHING,
+};
+
+static bool is_sockopt_supported(u32 moff)
+{
+ switch (moff) {
+ case offsetof(struct bpf_tcp_ops, active_established):
+ case offsetof(struct bpf_tcp_ops, passive_established):
+ case offsetof(struct bpf_tcp_ops, rto):
+ case offsetof(struct bpf_tcp_ops, rtt):
+ case offsetof(struct bpf_tcp_ops, set_state):
+ case offsetof(struct bpf_tcp_ops, retrans):
+ case offsetof(struct bpf_tcp_ops, connect):
+ case offsetof(struct bpf_tcp_ops, listen):
+ case offsetof(struct bpf_tcp_ops, parse_hdr):
+ return true;
+ }
+
+ return false;
+}
+
static const struct bpf_func_proto *
get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
{
@@ -221,22 +270,13 @@ get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
case BPF_FUNC_sk_storage_delete:
return &bpf_sk_storage_delete_proto;
case BPF_FUNC_setsockopt:
- /* The sk may be an unlocked listener (synack path) or NULL
- * fullsock; disable for members that can run unlocked.
- */
- if (moff == offsetof(struct bpf_tcp_ops, rwnd_init) ||
- moff == offsetof(struct bpf_tcp_ops, timeout_init) ||
- moff == offsetof(struct bpf_tcp_ops, hdr_opt_len) ||
- moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))
- return NULL;
- return &bpf_sk_setsockopt_proto;
+ if (is_sockopt_supported(moff))
+ return &bpf_sk_setsockopt_proto;
+ return NULL;
case BPF_FUNC_getsockopt:
- if (moff == offsetof(struct bpf_tcp_ops, rwnd_init) ||
- moff == offsetof(struct bpf_tcp_ops, timeout_init) ||
- moff == offsetof(struct bpf_tcp_ops, hdr_opt_len) ||
- moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))
- return NULL;
- return &bpf_sk_getsockopt_proto;
+ if (is_sockopt_supported(moff))
+ return &bpf_sk_getsockopt_proto;
+ return NULL;
case BPF_FUNC_get_retval:
if (moff == offsetof(struct bpf_tcp_ops, timeout_init) ||
moff == offsetof(struct bpf_tcp_ops, rwnd_init))
@@ -255,6 +295,15 @@ get_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
if (moff == offsetof(struct bpf_tcp_ops, write_hdr_opt))
return &bpf_tcp_ops_store_hdr_opt_proto;
return NULL;
+ case BPF_FUNC_sock_ops_cb_flags_set:
+ if (moff == offsetof(struct bpf_tcp_ops, connect) ||
+ moff == offsetof(struct bpf_tcp_ops, listen) ||
+ moff == offsetof(struct bpf_tcp_ops, active_established) ||
+ moff == offsetof(struct bpf_tcp_ops, passive_established) ||
+ moff == offsetof(struct bpf_tcp_ops, enqueue_rcvq) ||
+ moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))
+ return &bpf_tcp_ops_cb_flags_set_proto;
+ return NULL;
default:
return bpf_base_func_proto(func_id, prog);
}
@@ -319,8 +368,62 @@ static struct bpf_struct_ops bpf_tcp_ops = {
.owner = THIS_MODULE,
};
+__bpf_kfunc_start_defs();
+
+__bpf_kfunc int bpf_tcp_ops_set_rcvlowat(struct sock *sk, int rcvlowat,
+ const struct bpf_prog_aux *aux)
+{
+ u32 moff = aux->attach_st_ops_member_off;
+ bool wakeup = false;
+
+ if (moff == offsetof(struct bpf_tcp_ops, dequeue_rcvq))
+ wakeup = true;
+
+ if (rcvlowat < 0)
+ rcvlowat = INT_MAX;
+
+ return __tcp_set_rcvlowat(sk, rcvlowat, wakeup);
+}
+
+__bpf_kfunc_end_defs();
+
+BTF_KFUNCS_START(bpf_tcp_ops_rcvlowat_kfunc_set)
+BTF_ID_FLAGS(func, bpf_tcp_ops_set_rcvlowat, KF_IMPLICIT_ARGS)
+BTF_KFUNCS_END(bpf_tcp_ops_rcvlowat_kfunc_set)
+
+static int bpf_tcp_ops_rcvlowat_kfunc_filter(const struct bpf_prog *prog,
+ u32 kfunc_id)
+{
+ u32 moff;
+
+ if (!btf_id_set8_contains(&bpf_tcp_ops_rcvlowat_kfunc_set, kfunc_id))
+ return 0;
+
+ if (prog->aux->st_ops != &bpf_tcp_ops)
+ return -EACCES;
+
+ moff = prog->aux->attach_st_ops_member_off;
+ if (moff != offsetof(struct bpf_tcp_ops, enqueue_rcvq) &&
+ moff != offsetof(struct bpf_tcp_ops, dequeue_rcvq))
+ return -EACCES;
+
+ return 0;
+}
+
+static const struct btf_kfunc_id_set bpf_tcp_ops_rcvlowat_kfunc_id_set = {
+ .owner = THIS_MODULE,
+ .set = &bpf_tcp_ops_rcvlowat_kfunc_set,
+ .filter = bpf_tcp_ops_rcvlowat_kfunc_filter,
+};
+
static int __init __bpf_tcp_ops_init(void)
{
- return register_bpf_struct_ops(&bpf_tcp_ops, bpf_tcp_ops);
+ int ret;
+
+ ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_STRUCT_OPS,
+ &bpf_tcp_ops_rcvlowat_kfunc_id_set);
+ ret = ret ?: register_bpf_struct_ops(&bpf_tcp_ops, bpf_tcp_ops);
+
+ return ret;
}
late_initcall(__bpf_tcp_ops_init);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index a4456b4194122..aa7593fc8334e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1610,6 +1610,8 @@ void tcp_cleanup_rbuf(struct sock *sk, int copied)
"cleanup rbuf bug: copied %X seq %X rcvnxt %X\n",
tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt);
__tcp_cleanup_rbuf(sk, copied);
+
+ bpf_tcp_ops_dequeue_rcvq(sk);
}
static void tcp_eat_recv_skb(struct sock *sk, struct sk_buff *skb)
@@ -1826,8 +1828,7 @@ int tcp_peek_len(struct socket *sock)
return tcp_inq(sock->sk);
}
-/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */
-int tcp_set_rcvlowat(struct sock *sk, int val)
+int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup)
{
struct tcp_sock *tp = tcp_sk(sk);
int space, cap;
@@ -1840,7 +1841,8 @@ int tcp_set_rcvlowat(struct sock *sk, int val)
WRITE_ONCE(sk->sk_rcvlowat, val ? : 1);
/* Check if we need to signal EPOLLIN right now */
- tcp_data_ready(sk);
+ if (wakeup)
+ tcp_data_ready(sk);
if (sk->sk_userlocks & SOCK_RCVBUF_LOCK)
return 0;
@@ -1855,6 +1857,12 @@ int tcp_set_rcvlowat(struct sock *sk, int val)
return 0;
}
+/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */
+int tcp_set_rcvlowat(struct sock *sk, int val)
+{
+ return __tcp_set_rcvlowat(sk, val, true);
+}
+
void tcp_set_rcvbuf(struct sock *sk, int val)
{
tcp_set_window_clamp(sk, tcp_win_from_space(sk, val));
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 471c78be55137..4939bcbc81d17 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -281,6 +281,8 @@ void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb)
TCP_SKB_CB(skb)->seq++;
TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_SYN;
+ bpf_tcp_ops_enqueue_rcvq(sk, skb);
+
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
tcp_add_receive_queue(sk, skb);
tp->syn_data_acked = 1;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 6ac6f9d5b6c38..c60c61bb0a715 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5344,6 +5344,8 @@ static void tcp_ofo_queue(struct sock *sk)
continue;
}
+ bpf_tcp_ops_enqueue_rcvq(sk, skb);
+
tail = skb_peek_tail(&sk->sk_receive_queue);
eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
@@ -5547,6 +5549,8 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb,
int eaten;
struct sk_buff *tail = skb_peek_tail(&sk->sk_receive_queue);
+ bpf_tcp_ops_enqueue_rcvq(sk, skb);
+
eaten = (tail &&
tcp_try_coalesce(sk, tail,
skb, fragstolen)) ? 1 : 0;
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 6330b7d745c57..8cdf22667775f 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -3264,7 +3264,7 @@ union bpf_attr {
* Return
* 0
*
- * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)
+ * long bpf_sock_ops_cb_flags_set(void *bpf_sock, int argval)
* Description
* Attempt to set the value of the **bpf_sock_ops_cb_flags** field
* for the full TCP socket associated to *bpf_sock_ops* to
@@ -7148,8 +7148,17 @@ enum {
* options first before the BPF program does.
*/
BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1<<6),
+ /* Call bpf when the TCP stack enqueues/dequeues payload
+ * to/from sk->sk_receive_queue.
+ *
+ * Only bpf_tcp_ops is supported.
+ *
+ * It can be used to adjust sk->sk_rcvlowat and suppress
+ * unnecessary wakeups before sufficient data is available.
+ */
+ BPF_SOCK_OPS_RCVQ_CB_FLAG = (1<<7),
/* Mask of all currently supported cb flags */
- BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
+ BPF_SOCK_OPS_ALL_CB_FLAGS = 0xFF,
};
enum {
diff --git a/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c b/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c
new file mode 100644
index 0000000000000..337f9d34a39c5
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/tcp_autolowat.c
@@ -0,0 +1,350 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright 2026 Google LLC */
+#include <sys/epoll.h>
+
+#include "test_progs.h"
+#include "cgroup_helpers.h"
+#include "network_helpers.h"
+
+#include "tcp_autolowat.skel.h"
+
+#define SOL_BPF 0xdeadbeef
+#define BPF_TCP_AUTOLOWAT 0x8badf00d
+
+struct rpc_descriptor {
+ u32 header_len;
+ u32 payload_len;
+};
+
+enum rpc_event_type {
+ RPC_EVENT_END,
+ RPC_EVENT_AUTOLOWAT,
+ RPC_EVENT_SEND,
+ RPC_EVENT_RECV,
+ RPC_EVENT_EPOLL,
+ RPC_EVENT_RCVLOWAT,
+};
+
+struct rpc_event {
+ enum rpc_event_type type;
+ union {
+ int len;
+ int nfds;
+ int val;
+ int rcvlowat;
+ };
+};
+
+#define RPC_DESC_SIZE (sizeof(struct rpc_descriptor))
+
+static struct rpc_test_case {
+ char data[4096];
+ struct rpc_descriptor desc[32];
+ struct rpc_event event[32];
+} rpc_test_cases[] = {
+ {
+ .desc = {
+ { .header_len = 100, .payload_len = 150 },
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* Single full RPC message in skb. */
+ { .type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE + 100 + 150},
+ { .type = RPC_EVENT_EPOLL, .nfds = 1},
+ { .type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 100 + 150},
+ },
+ },
+ {
+ .desc = {
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* Two full RPC messages in skb. */
+ {.type = RPC_EVENT_SEND, .len = (RPC_DESC_SIZE + 100 + 150) * 2},
+ {.type = RPC_EVENT_EPOLL, .nfds = 1},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},
+ /* Single full RPC message in skb. */
+ { .type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE + 100 + 150},
+ { .type = RPC_EVENT_EPOLL, .nfds = 1},
+ { .type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 3},
+ },
+ },
+ {
+ .desc = {
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 100, .payload_len = 150},
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* Two full RPC messages in skb. */
+ {.type = RPC_EVENT_SEND, .len = (RPC_DESC_SIZE + 100 + 150) * 2},
+ {.type = RPC_EVENT_EPOLL, .nfds = 1},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},
+ /* Only the next descriptor in skb. */
+ { .type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE},
+ { .type = RPC_EVENT_EPOLL, .nfds = 1},
+ { .type = RPC_EVENT_RCVLOWAT, .rcvlowat = (RPC_DESC_SIZE + 100 + 150) * 2},
+ },
+ },
+ {
+ .desc = {
+ {.header_len = 100, .payload_len = 150},
+ {.header_len = 200, .payload_len = 500},
+ },
+ .event = {
+ { .type = RPC_EVENT_AUTOLOWAT, .val = 1},
+ /* The first descriptor is partial. */
+ {.type = RPC_EVENT_SEND, .len = 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE},
+ /* The first descriptor is available. */
+ {.type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE - 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 150 + 100},
+ /* The first header is ready. */
+ {.type = RPC_EVENT_SEND, .len = 100},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 150 + 100},
+ /* skb has the first payload and 1 byte of the next descriptor. */
+ {.type = RPC_EVENT_SEND, .len = 150 + 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 1},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 150 + 100},
+ /* After reading the first RPC message, SO_RCVLOWAT should be RPC_DESC_SIZE. */
+ {.type = RPC_EVENT_RECV, .len = RPC_DESC_SIZE + 150 + 100},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE},
+ /* The second descriptor is available. */
+ {.type = RPC_EVENT_SEND, .len = RPC_DESC_SIZE - 1},
+ {.type = RPC_EVENT_EPOLL, .nfds = 0},
+ {.type = RPC_EVENT_RCVLOWAT, .rcvlowat = RPC_DESC_SIZE + 200 + 500},
+ },
+ },
+};
+
+struct tcp_autolowat_test_cb {
+ int saved_netns;
+ union {
+ int fd[4];
+ struct {
+ int server, client, child;
+ int epoll;
+ };
+ };
+};
+
+static void tcp_autolowat_teardown_cb(struct tcp_autolowat_test_cb *cb)
+{
+ int i, err;
+
+ for (i = 0; i < ARRAY_SIZE(cb->fd); i++) {
+ if (cb->fd[i] != -1)
+ close(cb->fd[i]);
+ }
+
+ if (cb->saved_netns != -1) {
+ err = setns(cb->saved_netns, CLONE_NEWNET);
+ ASSERT_OK(err, "restore netns");
+
+ close(cb->saved_netns);
+ }
+}
+
+static int tcp_autolowat_setup_cb(struct tcp_autolowat_test_cb *cb, int family)
+{
+ struct epoll_event ev = {};
+ int err;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(cb->fd); i++)
+ cb->fd[i] = -1;
+
+ cb->saved_netns = open("/proc/self/ns/net", O_RDONLY);
+ if (!ASSERT_OK_FD(cb->saved_netns, "save netns"))
+ goto err;
+
+ err = unshare(CLONE_NEWNET);
+ if (!ASSERT_OK(err, "unshare"))
+ goto err;
+
+ err = system("ip link set dev lo up");
+ if (!ASSERT_OK(err, "set up lo"))
+ goto err;
+
+ cb->server = start_server(family, SOCK_STREAM, NULL, 0, 0);
+ if (!ASSERT_OK_FD(cb->server, "start_server"))
+ goto err;
+
+ cb->client = connect_to_fd(cb->server, 0);
+ if (!ASSERT_OK_FD(cb->client, "connect_to_fd"))
+ goto err;
+
+ cb->child = accept(cb->server, NULL, NULL);
+ if (!ASSERT_OK_FD(cb->child, "accept"))
+ goto err;
+
+ cb->epoll = epoll_create1(0);
+ if (!ASSERT_OK_FD(cb->epoll, "epoll_create"))
+ goto err;
+
+ ev.events = EPOLLIN;
+ ev.data.fd = cb->child;
+
+ err = epoll_ctl(cb->epoll, EPOLL_CTL_ADD, cb->child, &ev);
+ if (!ASSERT_OK(err, "epoll_ctl"))
+ goto err;
+
+ return 0;
+
+err:
+ tcp_autolowat_teardown_cb(cb);
+ return -1;
+}
+
+static int tcp_autolowat_build_data(struct rpc_test_case *test_case)
+{
+ struct rpc_descriptor *desc = test_case->desc;
+ char *ptr = test_case->data;
+ int rpc_size;
+
+ memset(ptr, 0, sizeof(test_case->data));
+
+ while (desc->header_len + desc->payload_len) {
+ rpc_size = sizeof(*desc) + desc->header_len + desc->payload_len;
+
+ if (!ASSERT_LE(ptr + rpc_size - test_case->data,
+ sizeof(test_case->data), "data overflow"))
+ return 1;
+
+ memcpy(ptr, desc, sizeof(*desc));
+ ptr += rpc_size;
+ desc++;
+ }
+
+ if (!ASSERT_GT(ptr - test_case->data, 0, "no data"))
+ return 1;
+
+ return 0;
+}
+
+static void tcp_autolowat_run_rpc_test(struct tcp_autolowat_test_cb *cb,
+ struct rpc_test_case *test_case)
+{
+ struct rpc_event *event = test_case->event;
+ char *ptr = test_case->data;
+ struct epoll_event ev;
+ socklen_t optlen;
+ int err, optval;
+ char buf[4096];
+
+ if (tcp_autolowat_build_data(test_case))
+ return;
+
+ while (1) {
+ switch (event->type) {
+ case RPC_EVENT_END:
+ return;
+ case RPC_EVENT_AUTOLOWAT:
+ err = setsockopt(cb->child, SOL_BPF, BPF_TCP_AUTOLOWAT,
+ &event->val, sizeof(event->val));
+ if (!ASSERT_OK(err, "setsockopt"))
+ return;
+ break;
+ case RPC_EVENT_SEND:
+ err = send(cb->client, ptr, event->len, 0);
+ if (!ASSERT_EQ(err, event->len, "send"))
+ return;
+
+ ptr += event->len;
+ break;
+ case RPC_EVENT_RECV:
+ err = recv(cb->child, buf, event->len, 0);
+ if (!ASSERT_EQ(err, event->len, "recv"))
+ return;
+ break;
+ case RPC_EVENT_EPOLL:
+ err = epoll_wait(cb->epoll, &ev, 1, 100);
+ if (!ASSERT_EQ(err, event->nfds, "epoll_wait"))
+ return;
+ break;
+ case RPC_EVENT_RCVLOWAT:
+ optval = 0;
+ optlen = sizeof(optval);
+
+ err = getsockopt(cb->child, SOL_SOCKET, SO_RCVLOWAT, &optval, &optlen);
+ if (!ASSERT_OK(err, "getsockopt") ||
+ !ASSERT_EQ(optval, event->rcvlowat, "rcvlowat"))
+ return;
+ break;
+ }
+
+ event++;
+ }
+}
+
+static void tcp_autolowat_run_rpc_tests(struct tcp_autolowat *skel, int family)
+{
+ struct tcp_autolowat_test_cb cb;
+ int err;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(rpc_test_cases); i++) {
+ memset(skel->bss->test_name, 0, sizeof(skel->bss->test_name));
+
+ snprintf(skel->bss->test_name, sizeof(skel->bss->test_name),
+ "AF_INET%c rpc_test_cases[%d]",
+ family == AF_INET ? ' ' : '6', i);
+
+ if (!test__start_subtest(skel->bss->test_name))
+ continue;
+
+ err = tcp_autolowat_setup_cb(&cb, family);
+ if (err)
+ continue;
+
+ tcp_autolowat_run_rpc_test(&cb, &rpc_test_cases[i]);
+ tcp_autolowat_teardown_cb(&cb);
+ }
+}
+
+static void tcp_autolowat_run_tests(struct tcp_autolowat *skel)
+{
+ tcp_autolowat_run_rpc_tests(skel, AF_INET);
+ tcp_autolowat_run_rpc_tests(skel, AF_INET6);
+}
+
+void test_tcp_autolowat(void)
+{
+ struct tcp_autolowat *skel;
+ struct bpf_link *link[2];
+ int cgroup;
+
+ skel = tcp_autolowat__open_and_load();
+ if (!ASSERT_OK_PTR(skel, "open_and_load"))
+ return;
+
+ cgroup = test__join_cgroup("/tcp_autolowat");
+ if (!ASSERT_GE(cgroup, 0, "join_cgroup"))
+ goto destroy_skel;
+
+ link[0] = bpf_map__attach_cgroup_opts(skel->maps.tcp_autolowat_ops, cgroup, NULL);
+ if (!ASSERT_OK_PTR(link[0], "attach_cgroup(tcp_autolowat_ops)"))
+ goto close_cgroup;
+
+ link[1] = bpf_program__attach_cgroup(skel->progs.tcp_autolowat_setsockopt, cgroup);
+ if (!ASSERT_OK_PTR(link[1], "attach_cgroup(SETSOCKOPT)"))
+ goto destroy_sockops;
+
+ tcp_autolowat_run_tests(skel);
+
+ bpf_link__destroy(link[1]);
+destroy_sockops:
+ bpf_link__destroy(link[0]);
+close_cgroup:
+ close(cgroup);
+destroy_skel:
+ tcp_autolowat__destroy(skel);
+}
diff --git a/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c b/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c
index 7e8fe1bad03f5..e4849d2a2956f 100644
--- a/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c
+++ b/tools/testing/selftests/bpf/prog_tests/tcpbpf_user.c
@@ -26,7 +26,8 @@ static void verify_result(struct tcpbpf_globals *result)
ASSERT_EQ(result->bytes_acked, 1002, "bytes_acked");
ASSERT_EQ(result->data_segs_in, 1, "data_segs_in");
ASSERT_EQ(result->data_segs_out, 1, "data_segs_out");
- ASSERT_EQ(result->bad_cb_test_rv, 0x80, "bad_cb_test_rv");
+ ASSERT_EQ(result->bad_cb_test_rv, BPF_SOCK_OPS_ALL_CB_FLAGS + 1,
+ "bad_cb_test_rv");
ASSERT_EQ(result->good_cb_test_rv, 0, "good_cb_test_rv");
ASSERT_EQ(result->num_listen, 1, "num_listen");
diff --git a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
index 593b38f904174..4c999d59cbbce 100644
--- a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
+++ b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
@@ -79,6 +79,8 @@
#define NEXTHDR_TCP 6
+#define TCPHDR_FIN 0x01
+
#define TCPOPT_NOP 1
#define TCPOPT_EOL 0
#define TCPOPT_MSS 2
diff --git a/tools/testing/selftests/bpf/progs/tcp_autolowat.c b/tools/testing/selftests/bpf/progs/tcp_autolowat.c
new file mode 100644
index 0000000000000..4fe7bdc98e69f
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/tcp_autolowat.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright 2026 Google LLC */
+#include "vmlinux.h"
+
+#include <string.h>
+#include <limits.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+#include <bpf/bpf_core_read.h>
+
+#include "bpf_kfuncs.h"
+#include "bpf_tracing_net.h"
+
+#define SOL_BPF 0xdeadbeef
+#define BPF_TCP_AUTOLOWAT 0x8badf00d
+
+//#define DEBUG /* For verbose output. */
+
+struct rpc_descriptor {
+ u32 header_len;
+ u32 payload_len;
+};
+
+#define RPC_DESC_SIZE (sizeof(struct rpc_descriptor))
+#define MAX_RPC_DESC_PER_SKB 100
+
+struct tcp_autolowat_cb {
+ /* Don't put this field at the end; BPF verifier complains. */
+ char rpc_desc_buf[RPC_DESC_SIZE];
+ u32 rpc_desc_seq;
+ u32 rpc_end_seq;
+#ifdef DEBUG
+ u32 isn;
+#endif
+ u8 rpc_desc_buff_len;
+};
+
+struct {
+ __uint(type, BPF_MAP_TYPE_SK_STORAGE);
+ __uint(map_flags, BPF_F_NO_PREALLOC);
+ __type(key, int);
+ __type(value, struct tcp_autolowat_cb);
+} tcp_autolowat_map SEC(".maps");
+
+char test_name[64];
+
+#ifdef DEBUG
+#define LOG(str, ...) \
+ bpf_printk("%s: " str, test_name, ##__VA_ARGS__)
+#else
+#define LOG(...)
+#endif
+
+#define SEQ(val) \
+ (val - cb->isn)
+#define TP_SEQ(field) \
+ (tp->field - cb->isn)
+#define CB_SEQ(field) \
+ (cb->field - cb->isn)
+
+static int tcp_parse_descriptor(struct tcp_autolowat_cb *cb,
+ struct bpf_dynptr *dptr,
+ u32 seq, u32 end_seq)
+{
+ struct rpc_descriptor *rpc_desc;
+ u32 rpc_copied_seq;
+ u64 copy_len; /* u32 should work, but not for no_alu32 :/ */
+ u64 rpc_len;
+ int err;
+
+ rpc_copied_seq = cb->rpc_desc_seq + cb->rpc_desc_buff_len;
+
+ if (before(cb->rpc_desc_seq + RPC_DESC_SIZE, end_seq))
+ copy_len = RPC_DESC_SIZE - cb->rpc_desc_buff_len;
+ else
+ copy_len = end_seq - rpc_copied_seq;
+
+ if (copy_len == 0)
+ goto disable; /* FIN. */
+ if (copy_len > RPC_DESC_SIZE)
+ goto disable; /* always false, only for verifier. */
+ if (cb->rpc_desc_buff_len >= RPC_DESC_SIZE)
+ goto disable; /* always false, only for verifier. */
+
+ err = bpf_dynptr_read(cb->rpc_desc_buf + cb->rpc_desc_buff_len,
+ copy_len, dptr, rpc_copied_seq - seq, 0);
+ if (err)
+ goto disable;
+
+ cb->rpc_desc_buff_len += copy_len;
+
+ if (cb->rpc_desc_buff_len != RPC_DESC_SIZE) {
+ LOG("Copied %d bytes: rpc_desc_buff_len: %u", copy_len, cb->rpc_desc_buff_len);
+ goto partial;
+ }
+
+ rpc_desc = (struct rpc_descriptor *)cb->rpc_desc_buf;
+ rpc_len = RPC_DESC_SIZE + rpc_desc->header_len + rpc_desc->payload_len;
+
+ if (rpc_len > INT_MAX)
+ goto disable;
+
+ cb->rpc_end_seq = cb->rpc_desc_seq + rpc_len;
+
+ LOG("Copied full descriptor: rpc_desc_seq: %u, rpc_end_seq: %u, header_len: %u, payload_len: %u",
+ CB_SEQ(rpc_desc_seq), CB_SEQ(rpc_end_seq),
+ rpc_desc->header_len, rpc_desc->payload_len);
+
+ return 0;
+disable:
+ return -1;
+partial:
+ return 1;
+}
+
+static void tcp_set_autolowat(struct tcp_autolowat_cb *cb,
+ struct sock *sk)
+{
+ struct tcp_sock *tp = (struct tcp_sock *)sk;
+ u32 val; /* To handle wraparound. */
+
+ LOG("Setting rcvlowat: tp->copied_seq: %u, rpc_desc_seq: %u, rpc_end_seq: %u, rpc_desc_buff_len: %u",
+ TP_SEQ(copied_seq), CB_SEQ(rpc_desc_seq),
+ CB_SEQ(rpc_end_seq), cb->rpc_desc_buff_len);
+
+ if (before(tp->copied_seq, cb->rpc_desc_seq))
+ val = cb->rpc_desc_seq - tp->copied_seq;
+ else if (cb->rpc_desc_buff_len != RPC_DESC_SIZE)
+ val = RPC_DESC_SIZE;
+ else
+ val = cb->rpc_end_seq - tp->copied_seq;
+
+ if (val != tp->inet_conn.icsk_inet.sk.sk_rcvlowat) {
+ bpf_tcp_ops_set_rcvlowat(sk, val);
+
+ LOG("Set rcvlowat: expected: %u, actual: %d\n",
+ val, tp->inet_conn.icsk_inet.sk.sk_rcvlowat);
+ } else {
+ LOG("No need to set rcvlowat: %u\n", val);
+ }
+}
+
+static void tcp_disable_autolowat(struct sock *sk)
+{
+ struct tcp_sock *tp = (struct tcp_sock *)sk;
+ int flags;
+
+ flags = tp->bpf_sock_ops_cb_flags & ~BPF_SOCK_OPS_RCVQ_CB_FLAG;
+ bpf_sock_ops_cb_flags_set(sk, flags);
+
+ bpf_tcp_ops_set_rcvlowat(sk, 1);
+
+ LOG("Disabled autolowat");
+}
+
+static void tcp_do_autolowat(struct tcp_autolowat_cb *cb,
+ struct sock *sk, struct sk_buff *skb)
+{
+ struct bpf_dynptr dptr;
+ struct tcp_skb_cb *tcb;
+ u32 seq, end_seq;
+ int ret = 0, i;
+
+ if (bpf_dynptr_from_skb((struct __sk_buff *)skb, 0, &dptr)) {
+ ret = -1;
+ goto update;
+ }
+
+ tcb = bpf_core_cast(skb->cb, struct tcp_skb_cb);
+ seq = tcb->seq;
+ end_seq = tcb->end_seq - !!(tcb->tcp_flags & TCPHDR_FIN);
+
+ LOG("Start parsing skb: seq: %u, end_seq: %u, len: %u, rpc_desc_seq: %u, rpc_end_seq: %u, rpc_buff_len: %u",
+ SEQ(seq), SEQ(end_seq), end_seq - seq,
+ CB_SEQ(rpc_desc_seq), CB_SEQ(rpc_end_seq), cb->rpc_desc_buff_len);
+
+ if (cb->rpc_desc_buff_len != RPC_DESC_SIZE) {
+ ret = tcp_parse_descriptor(cb, &dptr, seq, end_seq);
+ if (ret)
+ goto update;
+ }
+
+ i = 0;
+
+ while (1) {
+ if (i++ > MAX_RPC_DESC_PER_SKB) {
+ ret = -1;
+ break;
+ }
+
+ if (after(cb->rpc_end_seq, end_seq)) {
+ LOG("No more descriptor: rpc_end_seq: %u, end_seq: %u",
+ CB_SEQ(rpc_end_seq), SEQ(end_seq));
+ break;
+ }
+
+ cb->rpc_desc_seq = cb->rpc_end_seq;
+ cb->rpc_desc_buff_len = 0;
+
+ if (cb->rpc_end_seq == end_seq)
+ break;
+
+ LOG("Found next descriptor: rpc_end_seq: %u, end_seq: %u, len: %u",
+ CB_SEQ(rpc_end_seq), SEQ(end_seq), end_seq - cb->rpc_end_seq);
+
+ ret = tcp_parse_descriptor(cb, &dptr, seq, end_seq);
+ if (ret)
+ break;
+ }
+
+update:
+ if (ret >= 0)
+ tcp_set_autolowat(cb, sk);
+ else
+ tcp_disable_autolowat(sk);
+}
+
+SEC("struct_ops")
+void BPF_PROG(tcp_autolowat_enqueue_rcvq, struct sock *sk, struct sk_buff *skb)
+{
+ struct tcp_autolowat_cb *cb;
+
+ cb = bpf_sk_storage_get(&tcp_autolowat_map, sk, 0, 0);
+ if (!cb)
+ return;
+
+ tcp_do_autolowat(cb, sk, skb);
+}
+
+SEC("struct_ops")
+void BPF_PROG(tcp_autolowat_dequeue_rcvq, struct sock *sk)
+{
+ struct tcp_autolowat_cb *cb;
+
+ cb = bpf_sk_storage_get(&tcp_autolowat_map, sk, 0, 0);
+ if (!cb)
+ return;
+
+ tcp_set_autolowat(cb, sk);
+}
+
+SEC(".struct_ops.link")
+struct bpf_tcp_ops tcp_autolowat_ops = {
+ .enqueue_rcvq = (void *)tcp_autolowat_enqueue_rcvq,
+ .dequeue_rcvq = (void *)tcp_autolowat_dequeue_rcvq,
+};
+
+static int tcp_init_autolowat_cb(struct bpf_sockopt *sockopt,
+ struct bpf_tcp_sock *btp)
+{
+ struct tcp_autolowat_cb *cb;
+ struct tcp_sock *tp;
+ int flags;
+
+ cb = bpf_sk_storage_get(&tcp_autolowat_map, btp, 0,
+ BPF_SK_STORAGE_GET_F_CREATE);
+ if (!cb)
+ return -1;
+
+ tp = bpf_core_cast(btp, struct tcp_sock);
+ if (!tp)
+ return -1;
+
+ cb->rpc_desc_seq = tp->copied_seq;
+ cb->rpc_end_seq = tp->copied_seq;
+#ifdef DEBUG
+ cb->isn = tp->copied_seq;
+#endif
+
+ if (bpf_getsockopt(sockopt->sk, SOL_TCP, TCP_BPF_SOCK_OPS_CB_FLAGS,
+ &flags, sizeof(flags)))
+ return -1;
+
+ flags |= BPF_SOCK_OPS_RCVQ_CB_FLAG;
+
+ if (bpf_setsockopt(sockopt->sk, SOL_TCP, TCP_BPF_SOCK_OPS_CB_FLAGS,
+ &flags, sizeof(flags)))
+ return -1;
+
+ return 0;
+}
+
+SEC("cgroup/setsockopt")
+int tcp_autolowat_setsockopt(struct bpf_sockopt *ctx)
+{
+ void *optval_end = ctx->optval_end;
+ int *optval = ctx->optval;
+ struct bpf_tcp_sock *btp;
+
+ if (ctx->level != SOL_BPF || ctx->optname != BPF_TCP_AUTOLOWAT)
+ goto out;
+
+ if (optval + 1 > optval_end)
+ return 0; /* -EPERM */
+
+ btp = bpf_tcp_sock(ctx->sk);
+ if (!btp)
+ goto out;
+
+ if (*optval && tcp_init_autolowat_cb(ctx, btp))
+ return 0; /* -EPERM */
+
+ /*
+ * BPF has consumed this option, don't call kernel
+ * setsockopt handler.
+ */
+ ctx->optlen = -1;
+out:
+ return 1;
+}
+
+char _license[] SEC("license") = "GPL";
diff --git a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
index 6935f32eeb8fd..e30cb1fab0790 100644
--- a/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
+++ b/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
@@ -92,7 +92,8 @@ int bpf_testcb(struct bpf_sock_ops *skops)
break;
case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
/* Test failure to set largest cb flag (assumes not defined) */
- global.bad_cb_test_rv = bpf_sock_ops_cb_flags_set(skops, 0x80);
+ global.bad_cb_test_rv = bpf_sock_ops_cb_flags_set(skops,
+ BPF_SOCK_OPS_ALL_CB_FLAGS + 1);
/* Set callback */
global.good_cb_test_rv = bpf_sock_ops_cb_flags_set(skops,
BPF_SOCK_OPS_STATE_CB_FLAG);
|
| 39/3 | 2026/09/26 03:07 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17440 output: 24 thoughts: 2498 Thoughts: **KMSAN Needs Assessment for BPF TCP Operations Patch Series** Okay, let's break this down. My goal is to determine if this patch series necessitates a dedicated KMSAN fuzzing session. I need to justify the resource expenditure. I'm looking for *specific* uninitialized memory access issues that would *only* be caught by KMSAN, meaning KASAN, LockDep, and other standard detectors won't do the trick. First, I see several key areas of change. There are additions to `tcp.h` with new inline functions and function pointers related to BPF sock ops, specifically for queue callbacks (enqueue/dequeue rcvq). New flags are being defined in `bpf.h` (`BPF_SOCK_OPS_RCVQ_CB_FLAG`). The `filter.c` file is being updated to use `tcp_set_sock_ops_cb_flags` within the `setsockopt` and BPF call paths. The `bpf_tcp_ops.c` file has the most substantial changes: it introduces stubs for enqueue/dequeue functions, a helper function for setting callback flags, a refactoring for getting function prototypes, and new kfuncs to set `rcvlowat`. It also permits specific BPF function calls, and registers BTF kfunc IDs. Core TCP files, like `tcp.c`, `tcp_fastopen.c`, and `tcp_input.c` are updated to call these new BPF enqueue/dequeue functions in various TCP states and operations. Finally, selftests have been added for `tcp_autolowat`. Now, let's meticulously examine the code, looking for potential uninitialized memory issues. The `bpf_tcp_ops_cb_flags_set` function seems safe. All variables, `val` and `err`, are initialized before use, and only return an integer. Likewise, within `bpf_tcp_ops_set_rcvlowat`, all variables like `moff`, `wakeup`, and `rcvlowat` are initialized as well. The related `__tcp_set_rcvlowat` changes are also safe. No new uninitialized memory is being introduced. The change here is only conditional, not uninitialized. The `bpf_sock_ops_cb_flags_set` in `filter.c` is also fine, using initialized `val`, `sk`, and `err` variables. And the `tcp_set_sock_ops_cb_flags` inline function just assigns to a struct member. No problems here. I need to confirm that `bpf_tcp_ops_call` is not the source of uninitialized reads. Grepping reveals that it is a macro that calls the registered `enqueue_rcvq` or `dequeue_rcvq` function pointers. Since these function pointers are registered by the BPF program, they should be well initialized. However, the BPF program *could* pass uninitialized memory into the callbacks. Therefore, this patch series *could* introduce uninitialized memory read risks. However, I am not seeing it directly within the kernel code. If I am to justify a KMSAN session, I *must* ensure it is not covered by the existing bug detection infrastructure. The best approach is to examine how the BPF programs that use the new sock ops functionality work. Does it *expose* a kernel structure, as described in the criteria for running KMSAN? Based on my analysis, at this stage I don't see any obvious violations of the criteria that would mandate the use of KMSAN. While BPF is a complex environment, there's nothing in *this* patch that screams KMSAN. This is a bit of a tricky judgment call, and I need to do more analysis. |
| 40/3 | 2026/09/26 03:07 | tool | grepper |
0mArgs:{
"Expression": "#define bpf_tcp_ops_call"
}Results: {
"Output": "include/net/tcp.h=2980=struct bpf_tcp_ops {\n--\ninclude/net/tcp.h-3079-\ninclude/net/tcp.h:3080:#define bpf_tcp_ops_call(op, sk, ...)\t\t\t\t\t\\\ninclude/net/tcp.h-3081-do {\t\t\t\t\t\t\t\t\t\\\n--\ninclude/net/tcp.h-3097-\ninclude/net/tcp.h:3098:#define bpf_tcp_ops_call_int(op, init_retval, sk, ...)\t\t\t\\\ninclude/net/tcp.h-3099-({\t\t\t\t\t\t\t\t\t\\\n--\ninclude/net/tcp.h-3130-#else\ninclude/net/tcp.h:3131:#define bpf_tcp_ops_call(op, sk, ...)\t\tdo { } while (0)\ninclude/net/tcp.h:3132:#define bpf_tcp_ops_call_int(op, init_retval, sk, ...)\t(init_retval)\ninclude/net/tcp.h-3133-#endif\n"
} |
| 41/3 | 2026/09/26 03:07 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21038 output: 36 thoughts: 30 Thoughts: Okay, here's my take on those lines from `include/net/tcp.h`, keeping in mind my own deep understanding of the networking stack: **Delving into TCP Header Territory** Alright, let's zero in on lines 3080-3096 of `include/net/tcp.h` using my trusty `read-file` command. I need to refresh my memory on the specifics of this section. I'm guessing this area deals with some critical TCP data structures or macros related to connection management, maybe something to do with the socket options I've been researching. Or perhaps it addresses some low-level detail of the TCP header format itself. I'm keen to see if there's any novel optimization or change I might be able to incorporate into my own current project. The exact structure of this code is always evolving, so I need to maintain awareness of the current standards. |
| 42/3 | 2026/09/26 03:08 | tool | read-file |
0mArgs:{
"File": "include/net/tcp.h",
"FirstLine": 3075,
"LineCount": 35
}Results: {
"Contents": "3075:\t\n3076:\t\t/* Called after data is dequeued from sk-\u003esk_receive_queue. */\n3077:\t\tvoid (*dequeue_rcvq)(struct sock *sk);\n3078:\t};\n3079:\t\n3080:\t#define bpf_tcp_ops_call(op, sk, ...)\t\t\t\t\t\\\n3081:\tdo {\t\t\t\t\t\t\t\t\t\\\n3082:\t\tif (cgroup_bpf_enabled(CGROUP_TCP_SOCK_OPS)) {\t\t\t\\\n3083:\t\t\tconst struct bpf_prog_array_item *item;\t\t\t\\\n3084:\t\t\tconst struct bpf_tcp_ops *tcp_ops;\t\t\t\\\n3085:\t\t\tstruct cgroup *cgrp;\t\t\t\t\t\\\n3086:\t\t\t\t\t\t\t\t\t\t\\\n3087:\t\t\tcgrp = sock_cgroup_ptr(\u0026sk-\u003esk_cgrp_data);\t\t\\\n3088:\t\t\trcu_read_lock_dont_migrate();\t\t\t\t\\\n3089:\t\t\tbpf_cgroup_struct_ops_foreach(tcp_ops, item, cgrp,\t\\\n3090:\t\t\t\t\t\t CGROUP_TCP_SOCK_OPS) {\t\\\n3091:\t\t\t\tif (tcp_ops-\u003eop)\t\t\t\t\\\n3092:\t\t\t\t\ttcp_ops-\u003eop(sk, ##__VA_ARGS__);\t\t\\\n3093:\t\t\t}\t\t\t\t\t\t\t\\\n3094:\t\t\trcu_read_unlock_migrate();\t\t\t\t\\\n3095:\t\t}\t\t\t\t\t\t\t\t\\\n3096:\t} while (0)\n3097:\t\n3098:\t#define bpf_tcp_ops_call_int(op, init_retval, sk, ...)\t\t\t\\\n3099:\t({\t\t\t\t\t\t\t\t\t\\\n3100:\t\tint __retval = (init_retval);\t\t\t\t\t\\\n3101:\t\tif (cgroup_bpf_enabled(CGROUP_TCP_SOCK_OPS)) {\t\t\t\\\n3102:\t\t\tconst struct bpf_prog_array_item *item;\t\t\t\\\n3103:\t\t\tconst struct bpf_tcp_ops *tcp_ops;\t\t\t\\\n3104:\t\t\tstruct bpf_tramp_run_ctx run_ctx;\t\t\t\\\n3105:\t\t\tstruct bpf_run_ctx *old_run_ctx;\t\t\t\\\n3106:\t\t\tstruct sock *__sk = sk_to_full_sk(sk); \\\n3107:\t\t\tstruct request_sock *req = NULL;\t\t\t\\\n3108:\t\t\tstruct cgroup *cgrp;\t\t\t\t\t\\\n3109:\t\t\t\t\t\t\t\t\t\t\\\n"
} |
| 43/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21951 output: 22 thoughts: 1119 Thoughts: **Analyzing Socket Option Security and Control** Okay, let's break this down. First, I see they're explicitly whitelisting sockopt functionality using `is_sockopt_supported`. The previous implementation was a bit less restrictive, but now, only specific members of `struct bpf_tcp_ops` are allowed to interact with `setsockopt` and `getsockopt` via helper functions. This is a crucial security measure. It's cleaner and reduces the attack surface. Now, I'm noting the explicit list within `is_sockopt_supported`. The implication is that we're trying to prevent potentially dangerous or unlocked operations on sockets within the BPF context. The previous check, before the introduction of `is_sockopt_supported`, was allowing more options, which is no longer the case. Specifically, `enqueue_rcvq` and `dequeue_rcvq` are *not* on that whitelist, which means they can't directly call `setsockopt` or `getsockopt`. Instead, a dedicated kfunc, `bpf_tcp_ops_set_rcvlowat`, has been introduced, which is a much better, more secure approach. This is the preferred way to interact with rcvlowat from within these BPF programs. Next, I need to look at `bpf_tcp_ops_rcvlowat_kfunc_filter`. This confirms that only BPF programs attached to `enqueue_rcvq` or `dequeue_rcvq` can use this specific kfunc. The filter checks the program's attachment point and verifies it's what's expected for this kfunc. This prevents the kfunc from being misused, which is good. Finally, looking at `__tcp_set_rcvlowat`, I see how the `rcvlowat` value is actually set. It's a fairly standard pattern of clamping the input value, writing the new value, and then potentially waking up the socket (for EPOLLIN). It handles the `SOCK_RCVBUF_LOCK` case, which is expected. The clamping behavior is a good defensive measure, preventing the sockopt from being misused. The handling of `window_clamp` after the low watermark is set is interesting, too. I should probably track down all the call sites to `tcp_set_rcvlowat` across the kernel to fully appreciate how it's used. This overall looks like a well-thought-out improvement in security and control of socket options within BPF. |
| 44/3 | 2026/09/26 03:08 | tool | grepper |
0mArgs:{
"Expression": "tcp_set_rcvlowat"
}Results: {
"Output": "include/net/tcp.h=513=int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,\ninclude/net/tcp.h-514-\t\tint flags);\ninclude/net/tcp.h:515:int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup);\ninclude/net/tcp.h:516:int tcp_set_rcvlowat(struct sock *sk, int val);\ninclude/net/tcp.h-517-void tcp_set_rcvbuf(struct sock *sk, int val);\n--\nnet/ipv4/af_inet.c=1061=const struct proto_ops inet_stream_ops = {\n--\nnet/ipv4/af_inet.c-1091-#endif\nnet/ipv4/af_inet.c:1092:\t.set_rcvlowat\t = tcp_set_rcvlowat,\nnet/ipv4/af_inet.c-1093-\t.set_rcvbuf\t = tcp_set_rcvbuf,\n--\nnet/ipv4/bpf_tcp_ops.c=373=__bpf_kfunc int bpf_tcp_ops_set_rcvlowat(struct sock *sk, int rcvlowat,\n--\nnet/ipv4/bpf_tcp_ops.c-384-\nnet/ipv4/bpf_tcp_ops.c:385:\treturn __tcp_set_rcvlowat(sk, rcvlowat, wakeup);\nnet/ipv4/bpf_tcp_ops.c-386-}\n--\nnet/ipv4/tcp.c=1826=int tcp_peek_len(struct socket *sock)\n--\nnet/ipv4/tcp.c-1830-\nnet/ipv4/tcp.c:1831:int __tcp_set_rcvlowat(struct sock *sk, int val, bool wakeup)\nnet/ipv4/tcp.c-1832-{\n--\nnet/ipv4/tcp.c-1860-/* Make sure sk_rcvbuf is big enough to satisfy SO_RCVLOWAT hint */\nnet/ipv4/tcp.c:1861:int tcp_set_rcvlowat(struct sock *sk, int val)\nnet/ipv4/tcp.c-1862-{\nnet/ipv4/tcp.c:1863:\treturn __tcp_set_rcvlowat(sk, val, true);\nnet/ipv4/tcp.c-1864-}\n--\nnet/ipv6/af_inet6.c=660=const struct proto_ops inet6_stream_ops = {\n--\nnet/ipv6/af_inet6.c-690-#endif\nnet/ipv6/af_inet6.c:691:\t.set_rcvlowat\t = tcp_set_rcvlowat,\nnet/ipv6/af_inet6.c-692-\t.set_rcvbuf\t = tcp_set_rcvbuf,\n--\nnet/mptcp/protocol.c=4711=static const struct proto_ops mptcp_stream_ops = {\n--\nnet/mptcp/protocol.c-4729-\t.mmap\t\t = sock_no_mmap,\nnet/mptcp/protocol.c:4730:\t.set_rcvlowat\t = mptcp_set_rcvlowat,\nnet/mptcp/protocol.c-4731-\t.read_sock\t = mptcp_read_sock,\n--\nnet/mptcp/protocol.c=4820=static const struct proto_ops mptcp_v6_stream_ops = {\n--\nnet/mptcp/protocol.c-4841-#endif\nnet/mptcp/protocol.c:4842:\t.set_rcvlowat\t = mptcp_set_rcvlowat,\nnet/mptcp/protocol.c-4843-\t.read_sock\t = mptcp_read_sock,\n--\nnet/mptcp/protocol.h=869=static inline bool mptcp_epollin_ready(const struct sock *sk)\n--\nnet/mptcp/protocol.h-882-\nnet/mptcp/protocol.h:883:int mptcp_set_rcvlowat(struct sock *sk, int val);\nnet/mptcp/protocol.h-884-\n--\nnet/mptcp/sockopt.c=1606=void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk)\n--\nnet/mptcp/sockopt.c-1629- */\nnet/mptcp/sockopt.c:1630:int mptcp_set_rcvlowat(struct sock *sk, int val)\nnet/mptcp/sockopt.c-1631-{\n"
} |
| 45/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24881 output: 37 thoughts: 22 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Diving into `tcp_cleanup_rbuf`** Okay, so I need to refresh my memory on the TCP receive buffer cleanup process. My immediate thought is to head straight for the source – `net/ipv4/tcp.c`, specifically the `tcp_cleanup_rbuf` function. I want to quickly re-evaluate how the kernel handles those lingering receive buffers, particularly in edge cases or after connection teardown. I'm keen to examine the logic flow here: what triggers this function, what are its specific responsibilities (releasing skb's, managing memory), and are there any potential areas for optimization or vulnerabilities in the current implementation I can spot? Gotta remember to look for any potential for memory leaks, especially when connections are closed abruptly. And of course, I'll be keeping an eye out for any potential race conditions involving concurrent access to the receive buffer. Let's see what we can find. |
| 46/3 | 2026/09/26 03:08 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp.c",
"FirstLine": 1595,
"LineCount": 35
}Results: {
"Contents": "1595:\t\t\t\t\ttime_to_ack = true;\n1596:\t\t\t}\n1597:\t\t}\n1598:\t\tif (time_to_ack) {\n1599:\t\t\ttcp_mstamp_refresh(tp);\n1600:\t\t\ttcp_send_ack(sk);\n1601:\t\t}\n1602:\t}\n1603:\t\n1604:\tvoid tcp_cleanup_rbuf(struct sock *sk, int copied)\n1605:\t{\n1606:\t\tstruct sk_buff *skb = skb_peek(\u0026sk-\u003esk_receive_queue);\n1607:\t\tstruct tcp_sock *tp = tcp_sk(sk);\n1608:\t\n1609:\t\tWARN(skb \u0026\u0026 !before(tp-\u003ecopied_seq, TCP_SKB_CB(skb)-\u003eend_seq),\n1610:\t\t \"cleanup rbuf bug: copied %X seq %X rcvnxt %X\\n\",\n1611:\t\t tp-\u003ecopied_seq, TCP_SKB_CB(skb)-\u003eend_seq, tp-\u003ercv_nxt);\n1612:\t\t__tcp_cleanup_rbuf(sk, copied);\n1613:\t\n1614:\t\tbpf_tcp_ops_dequeue_rcvq(sk);\n1615:\t}\n1616:\t\n1617:\tstatic void tcp_eat_recv_skb(struct sock *sk, struct sk_buff *skb)\n1618:\t{\n1619:\t\t__skb_unlink(skb, \u0026sk-\u003esk_receive_queue);\n1620:\t\tif (likely(skb-\u003edestructor == sock_rfree)) {\n1621:\t\t\tsock_rfree(skb);\n1622:\t\t\tskb-\u003edestructor = NULL;\n1623:\t\t\tskb-\u003esk = NULL;\n1624:\t\t\treturn skb_attempt_defer_free(skb);\n1625:\t\t}\n1626:\t\t__kfree_skb(skb);\n1627:\t}\n1628:\t\n1629:\tstruct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off)\n"
} |
| 47/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25731 output: 39 thoughts: 29 Thoughts: Here's a summary of my thought process, as requested: **Diving into `tcp_fastopen_add_skb`** Okay, time to get my hands dirty. I'm going to jump into the `net/ipv4/tcp_fastopen.c` file and specifically examine the `tcp_fastopen_add_skb` function. I need to understand exactly how the kernel is handling the addition of an `skb` (socket buffer) within the context of TCP Fast Open. I'm particularly interested in the nuances of how it's integrated and what the potential implications are. I'm expecting to find details related to security, connection state management, and perhaps optimizations specific to the Fast Open mechanism itself. Let's see what's what. |
| 48/3 | 2026/09/26 03:08 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp_fastopen.c",
"FirstLine": 275,
"LineCount": 25
}Results: {
"Contents": " 275:\t\ttp-\u003esegs_in = 0;\n 276:\t\ttcp_segs_in(tp, skb);\n 277:\t\t__skb_pull(skb, tcp_hdrlen(skb));\n 278:\t\tsk_forced_mem_schedule(sk, skb-\u003etruesize);\n 279:\t\tskb_set_owner_r(skb, sk);\n 280:\t\n 281:\t\tTCP_SKB_CB(skb)-\u003eseq++;\n 282:\t\tTCP_SKB_CB(skb)-\u003etcp_flags \u0026= ~TCPHDR_SYN;\n 283:\t\n 284:\t\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\n 285:\t\n 286:\t\ttp-\u003ercv_nxt = TCP_SKB_CB(skb)-\u003eend_seq;\n 287:\t\ttcp_add_receive_queue(sk, skb);\n 288:\t\ttp-\u003esyn_data_acked = 1;\n 289:\t\n 290:\t\t/* u64_stats_update_begin(\u0026tp-\u003esyncp) not needed here,\n 291:\t\t * as we certainly are not changing upper 32bit value (0)\n 292:\t\t */\n 293:\t\ttp-\u003ebytes_received = skb-\u003elen;\n 294:\t\n 295:\t\tif (TCP_SKB_CB(skb)-\u003etcp_flags \u0026 TCPHDR_FIN)\n 296:\t\t\ttcp_fin(sk);\n 297:\t}\n 298:\t\n 299:\t/* returns 0 - no key match, 1 for primary, 2 for backup */\n"
} |
| 49/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26412 output: 39 thoughts: 33 Thoughts: Okay, let's dive into this. Here's how I'd approach that kernel code: **Diving into TCP Receive Queues** Alright, time to get my hands dirty with `net/ipv4/tcp_input.c`. Specifically, I need to take a close look at how TCP handles out-of-order packets and its receiving queues. My primary focus is on `tcp_ofo_queue` and `tcp_queue_rcv`. I want to understand exactly how the kernel manages these buffers, especially in scenarios with packet reordering, loss, and congestion. I'm thinking about the implications for performance and how the design impacts things like latency and throughput. I'll be looking for potential bottlenecks or areas for optimization within these routines, considering various TCP options and network conditions. What are the mutexes/locks used? How does it interact with the retransmission queue? Let's get to it. |
| 50/3 | 2026/09/26 03:08 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp_input.c",
"FirstLine": 5335,
"LineCount": 35
}Results: {
"Contents": "5335:\t\t\t\tif (before(TCP_SKB_CB(skb)-\u003eend_seq, dsack_high))\n5336:\t\t\t\t\tdsack = TCP_SKB_CB(skb)-\u003eend_seq;\n5337:\t\t\t\ttcp_dsack_extend(sk, TCP_SKB_CB(skb)-\u003eseq, dsack);\n5338:\t\t\t}\n5339:\t\t\tp = rb_next(p);\n5340:\t\t\trb_erase(\u0026skb-\u003erbnode, \u0026tp-\u003eout_of_order_queue);\n5341:\t\n5342:\t\t\tif (unlikely(!after(TCP_SKB_CB(skb)-\u003eend_seq, tp-\u003ercv_nxt))) {\n5343:\t\t\t\ttcp_drop_reason(sk, skb, SKB_DROP_REASON_TCP_OFO_DROP);\n5344:\t\t\t\tcontinue;\n5345:\t\t\t}\n5346:\t\n5347:\t\t\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\n5348:\t\n5349:\t\t\ttail = skb_peek_tail(\u0026sk-\u003esk_receive_queue);\n5350:\t\t\teaten = tail \u0026\u0026 tcp_try_coalesce(sk, tail, skb, \u0026fragstolen);\n5351:\t\t\ttcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)-\u003eend_seq);\n5352:\t\t\tfin = TCP_SKB_CB(skb)-\u003etcp_flags \u0026 TCPHDR_FIN;\n5353:\t\t\tif (!eaten)\n5354:\t\t\t\ttcp_add_receive_queue(sk, skb);\n5355:\t\t\telse\n5356:\t\t\t\tkfree_skb_partial(skb, fragstolen);\n5357:\t\n5358:\t\t\tif (unlikely(fin)) {\n5359:\t\t\t\ttcp_fin(sk);\n5360:\t\t\t\t/* tcp_fin() purges tp-\u003eout_of_order_queue,\n5361:\t\t\t\t * so we must end this loop right now.\n5362:\t\t\t\t */\n5363:\t\t\t\tbreak;\n5364:\t\t\t}\n5365:\t\t}\n5366:\t}\n5367:\t\n5368:\tstatic bool tcp_prune_ofo_queue(struct sock *sk, const struct sk_buff *in_skb);\n5369:\tstatic int tcp_prune_queue(struct sock *sk, const struct sk_buff *in_skb);\n"
} |
| 51/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27326 output: 39 thoughts: 12 Thoughts: Here's a first-person summary, keeping in mind the audience is an expert: **Diving into `tcp_queue_rcv`** Okay, let's get down to brass tacks and dissect `tcp_queue_rcv`. This is where the magic happens, or at least, where a lot of the critical TCP reception logic is handled. I need to refresh my memory on the current state of its role in the receive path. I'm primarily interested in how it interacts with the socket buffer, congestion control, and acknowledgment handling. Specifically, I'm thinking about the implications of pacing and the interactions with hardware offload features, if any. I'll need to double check how it handles various edge cases, particularly around window updates and retransmissions. I'm going to pay close attention to the lock interactions and any potential for contention; I know that's a common area of performance bottlenecks. I need to map out the data flow and identify any potential opportunities for optimization, or at least identify any obvious problem areas. Time to get my hands dirty. |
| 52/3 | 2026/09/26 03:08 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp_input.c",
"FirstLine": 5540,
"LineCount": 35
}Results: {
"Contents": "5540:\t\t}\n5541:\t\t/* do not grow rcvbuf for not-yet-accepted or orphaned sockets. */\n5542:\t\tif (sk-\u003esk_socket)\n5543:\t\t\ttcp_rcvbuf_grow(sk, tp-\u003ercvq_space.space);\n5544:\t}\n5545:\t\n5546:\tstatic int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb,\n5547:\t\t\t\t\t bool *fragstolen)\n5548:\t{\n5549:\t\tint eaten;\n5550:\t\tstruct sk_buff *tail = skb_peek_tail(\u0026sk-\u003esk_receive_queue);\n5551:\t\n5552:\t\tbpf_tcp_ops_enqueue_rcvq(sk, skb);\n5553:\t\n5554:\t\teaten = (tail \u0026\u0026\n5555:\t\t\t tcp_try_coalesce(sk, tail,\n5556:\t\t\t\t\t skb, fragstolen)) ? 1 : 0;\n5557:\t\ttcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)-\u003eend_seq);\n5558:\t\tif (!eaten) {\n5559:\t\t\ttcp_add_receive_queue(sk, skb);\n5560:\t\t\tskb_set_owner_r(skb, sk);\n5561:\t\t}\n5562:\t\treturn eaten;\n5563:\t}\n5564:\t\n5565:\tint tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)\n5566:\t{\n5567:\t\tstruct sk_buff *skb;\n5568:\t\tint err = -ENOMEM;\n5569:\t\tint data_len = 0;\n5570:\t\tbool fragstolen;\n5571:\t\n5572:\t\tif (size == 0)\n5573:\t\t\treturn 0;\n5574:\t\n"
} |
| 53/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28149 output: 39 thoughts: 341 Thoughts: **Analyzing `bpf_tcp_ops_cb_flags_set` for Potential Issues** Okay, let's take a look at `bpf_tcp_ops_cb_flags_set`. I see it's defined in `net/ipv4/bpf_tcp_ops.c`. The function itself looks straightforward: it takes a socket (`sk`) and an integer argument (`argval`), masks `argval` with `BPF_SOCK_OPS_ALL_CB_FLAGS`, calls `tcp_set_sock_ops_cb_flags`, and then returns a bitwise operation. The core is the function `tcp_set_sock_ops_cb_flags`. My immediate concern, though, is the use of `btf_sock_ids[BTF_SOCK_TYPE_TCP]` within the `bpf_tcp_ops_cb_flags_set_proto` structure. I need to verify its safety and suitability within this context, especially given my understanding of the intricacies of BTF and BPF type information. It seems like it's used to identify the type of socket passed to the function, but I need to make sure the indexing and usage are sound. To fully understand this, I'm going to scan the other `bpf_tcp_ops` helpers defined in the same file. Examining those definitions will likely reveal any consistent pattern or potential gotchas related to this BTF ID usage. This seems like the most logical next step to assess the overall code's robustness. |
| 54/3 | 2026/09/26 03:08 | tool | grepper |
0mArgs:{
"Expression": "btf_sock_ids",
"PathPrefix": "net/ipv4/bpf_tcp_ops.c"
}Results: {
"Output": "net/ipv4/bpf_tcp_ops.c=235=static const struct bpf_func_proto bpf_tcp_ops_cb_flags_set_proto = {\n--\nnet/ipv4/bpf_tcp_ops.c-239-\t.arg1_type\t= ARG_PTR_TO_BTF_ID,\nnet/ipv4/bpf_tcp_ops.c:240:\t.arg1_btf_id\t= \u0026btf_sock_ids[BTF_SOCK_TYPE_TCP],\nnet/ipv4/bpf_tcp_ops.c-241-\t.arg2_type\t= ARG_ANYTHING,\n--\nnet/ipv4/bpf_tcp_ops.c=312=static bool is_valid_access(int off, int size, enum bpf_access_type type,\n--\nnet/ipv4/bpf_tcp_ops.c-319-\t !bpf_type_has_unsafe_modifiers(info-\u003ereg_type) \u0026\u0026\nnet/ipv4/bpf_tcp_ops.c:320:\t info-\u003ebtf_id == btf_sock_ids[BTF_SOCK_TYPE_SOCK])\nnet/ipv4/bpf_tcp_ops.c-321-\t\t/* promote it to tcp_sock */\nnet/ipv4/bpf_tcp_ops.c:322:\t\tinfo-\u003ebtf_id = btf_sock_ids[BTF_SOCK_TYPE_TCP];\nnet/ipv4/bpf_tcp_ops.c-323-\n"
} |
| 55/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29246 output: 41 thoughts: 18 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the Access Control Logic** Alright, let's zero in on `is_valid_access` around line 312. I need to refresh my memory on the access control flow for this section of the code. This is where the core logic resides, so this could be the source of my problem. I will check exactly how the permission checking is implemented. I should also see what context is being used around this call, so I can see what inputs are being provided and the expected outputs. Does it depend on roles? Are there any caching mechanisms at play, and if so, how reliable are they? Also, it's worth seeing if this logic is complex, if it uses multiple rules, and if it is easily understood. Finally, there's always the possibility that some environment variable or configuration setting is being ignored or overwritten, so I'll check that. |
| 56/3 | 2026/09/26 03:08 | tool | read-file |
0mArgs:{
"File": "net/ipv4/bpf_tcp_ops.c",
"FirstLine": 310,
"LineCount": 40
}Results: {
"Contents": " 310:\t}\n 311:\t\n 312:\tstatic bool is_valid_access(int off, int size, enum bpf_access_type type,\n 313:\t\t\t\t const struct bpf_prog *prog, struct bpf_insn_access_aux *info)\n 314:\t{\n 315:\t\tif (!bpf_tracing_btf_ctx_access(off, size, type, prog, info))\n 316:\t\t\treturn false;\n 317:\t\n 318:\t\tif (base_type(info-\u003ereg_type) == PTR_TO_BTF_ID \u0026\u0026\n 319:\t\t !bpf_type_has_unsafe_modifiers(info-\u003ereg_type) \u0026\u0026\n 320:\t\t info-\u003ebtf_id == btf_sock_ids[BTF_SOCK_TYPE_SOCK])\n 321:\t\t\t/* promote it to tcp_sock */\n 322:\t\t\tinfo-\u003ebtf_id = btf_sock_ids[BTF_SOCK_TYPE_TCP];\n 323:\t\n 324:\t\treturn true;\n 325:\t}\n 326:\t\n 327:\tstatic int bpf_tcp_ops_init_member(const struct btf_type *t,\n 328:\t\t\t\t\t const struct btf_member *member,\n 329:\t\t\t\t\t void *kdata, const void *udata)\n 330:\t{\n 331:\t\treturn 0;\n 332:\t}\n 333:\t\n 334:\tstatic int bpf_tcp_ops_check_member(const struct btf_type *t,\n 335:\t\t\t\t\t const struct btf_member *member,\n 336:\t\t\t\t\t const struct bpf_prog *prog)\n 337:\t{\n 338:\t\tif (prog-\u003esleepable)\n 339:\t\t\treturn -EINVAL;\n 340:\t\n 341:\t\treturn 0;\n 342:\t}\n 343:\t\n 344:\tstatic int bpf_tcp_ops_init(struct btf *btf)\n 345:\t{\n 346:\t\treturn 0;\n 347:\t}\n 348:\t\n 349:\tstatic int bpf_tcp_ops_validate(void *kdata)\n"
} |
| 57/3 | 2026/09/26 03:08 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30124 output: 385 thoughts: 1612 Thoughts: **KMSAN Assessment: No Uninitialized Memory Issues Detected** Alright, let's break this down. My analysis focuses on whether this patch introduces any uninitialized memory vulnerabilities, and whether KMSAN is necessary to detect anything beyond what KASAN and LOCKDEP would catch. First, I examine the code. This patch introduces two new callbacks, `enqueue_rcvq` and `dequeue_rcvq`, within `bpf_tcp_ops`, triggered on the TCP receive queue. It refactors `tcp_set_rcvlowat`, introducing `__tcp_set_rcvlowat`, and adds a helper function `bpf_tcp_ops_set_rcvlowat` alongside some selftests. Now, the crucial question: are we potentially leaking uninitialized data or reading it? Based on my analysis: 1. **No Data Leaks:** I find no instances of new kernel structures being sent to user space via the usual suspects (copy\_to\_user, etc.). The `setsockopt`/`getsockopt` handling is checked for `BPF_SOCK_OPS_ALL_CB_FLAGS` changes, but this does not lead to information leakage. The `__tcp_set_rcvlowat` is straightforward memory manipulation. 2. **No Uninitialized Variables or Fields:** I'm not seeing any use of uninitialized variables or struct fields within the new or modified code paths. I'm carefully reviewing the conditional logic and branching, checking that variables like `val`, `err`, `wakeup`, and `moff` are appropriately initialized. Conditions depend on flags like `sk_is_mptcp(sk)` and `BPF_SOCK_OPS_RCVQ_CB_FLAG`, which are safely checked. 3. **No New Allocations:** No new allocations of heap or stack memory are introduced, which means we avoid the risk of uninitialized fields being read later in reachable code paths. The only additions are the static `__bpf_tcp_ops` stubs and kfunc definitions. 4. **No Buffer Access Issues:** I'm also ensuring that there aren't any bounds checks or length modifications that could allow access to uninitialized portions of existing buffers. The `skb` is pre-validated network data. The BPF program accesses the packet via established safe means (dynptr or direct access, verified by verifier and the network stack). The patch doesn't handle uninitialized data. The selftests, which run in user space, are irrelevant in the context of kernel memory sanitization, but I have reviewed them and everything is initialized. Now, KMSAN vs. KASAN and LOCKDEP. If there *were* bugs, they would likely be in one of the following areas: * **Locking:** Calling `tcp_set_rcvlowat`, `tcp_data_ready`, or `bpf_tcp_ops_call` under incorrect locks, or reentrancy issues. LOCKDEP handles this. * **Callback Timing:** Calling BPF callbacks at unexpected times, or potential use-after-free or NULL dereferences of `sk` or `skb` or cgroup. KASAN/standard detectors catch these. * **Logic Bugs:** Logic bugs in `autolowat` or `cb_flags` validation: functional bugs. Critically, **there are no uninitialized memory accesses, leaks to userspace, or uninitialized stack/heap variables**. Therefore, since this patch doesn't introduce any uninitialized memory pathways, KMSAN's capabilities are not necessary for this patch. I'll invoke `set-results` with `NeedsKMSAN=false`. |
| 58/3 | 2026/09/26 03:08 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series introduces two new callbacks to `struct bpf_tcp_ops` (`enqueue_rcvq` and `dequeue_rcvq`), adds a new callback flag `BPF_SOCK_OPS_RCVQ_CB_FLAG`, refactors `tcp_set_rcvlowat()` into `__tcp_set_rcvlowat()` with a `wakeup` parameter, exposes the `bpf_tcp_ops_set_rcvlowat` kfunc and `bpf_tcp_ops_cb_flags_set` helper, and adds corresponding selftests.\n\nAnalysis regarding KMSAN applicability:\n1. No uninitialized memory or info-leak risks:\n - No new heap/stack allocations or structures are copied to user space.\n - All local variables in newly added and modified functions (`val`, `err`, `moff`, `wakeup`) are explicitly and deterministically initialized before use.\n - The changes do not manipulate buffer sizes, data lengths, or padding in ways that could expose uninitialized data to reads or user space.\n2. Failure modes:\n - The primary risks introduced by this change involve socket locking assumptions, re-entrancy, or object lifetime/reference counting when executing BPF callbacks in TCP receive/cleanup paths (`tcp_fastopen_add_skb`, `tcp_ofo_queue`, `tcp_queue_rcv`, `tcp_cleanup_rbuf`).\n - These risks (use-after-free, null pointer dereference, locking/deadlock issues) are properly covered by KASAN and LOCKDEP.\n - KMSAN would provide no additional bug-finding value here over standard KASAN/LOCKDEP builds.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series introduces two new callbacks to `struct bpf_tcp_ops` (`enqueue_rcvq` and `dequeue_rcvq`), adds a new callback flag `BPF_SOCK_OPS_RCVQ_CB_FLAG`, refactors `tcp_set_rcvlowat()` into `__tcp_set_rcvlowat()` with a `wakeup` parameter, exposes the `bpf_tcp_ops_set_rcvlowat` kfunc and `bpf_tcp_ops_cb_flags_set` helper, and adds corresponding selftests.\n\nAnalysis regarding KMSAN applicability:\n1. No uninitialized memory or info-leak risks:\n - No new heap/stack allocations or structures are copied to user space.\n - All local variables in newly added and modified functions (`val`, `err`, `moff`, `wakeup`) are explicitly and deterministically initialized before use.\n - The changes do not manipulate buffer sizes, data lengths, or padding in ways that could expose uninitialized data to reads or user space.\n2. Failure modes:\n - The primary risks introduced by this change involve socket locking assumptions, re-entrancy, or object lifetime/reference counting when executing BPF callbacks in TCP receive/cleanup paths (`tcp_fastopen_add_skb`, `tcp_ofo_queue`, `tcp_queue_rcv`, `tcp_cleanup_rbuf`).\n - These risks (use-after-free, null pointer dereference, locking/deadlock issues) are properly covered by KASAN and LOCKDEP.\n - KMSAN would provide no additional bug-finding value here over standard KASAN/LOCKDEP builds.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|