| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/17 16:44 | flow | patch-triage |
3mArgs:null Results: {
"EnableConfigs": [
"BPF_SYSCALL",
"BPF_STREAM_PARSER"
],
"FocusSymbols": [
"sock_map_update_elem_sys",
"sock_map_get_from_fd",
"tcp_bpf_update_proto",
"tcp_bpf_strp_read_sock"
],
"KMSANReasoning": "The patch addresses an issue with socket memory accounting (`sk_forward_alloc`) when an skb is passed to the same socket via BPF stream parser/verdict. It introduces `sk_psock_skb_ingress_self_assign` to properly handle `sk_rmem_schedule` and `skb_set_owner_r`. The changes involve memory accounting, locking, and saving/restoring `skb-\u003e_sk_redir`. There are no new data structures allocated without initialization, no changes to bounds checking that would expose uninitialized memory, and no data copied to user space that could contain uninitialized fields. Any potential bugs related to these changes would be logic errors, memory leaks, or use-after-free, which are adequately covered by standard KASAN and memory leak detectors. Therefore, a dedicated KMSAN fuzzing session is not required.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies the BPF sockmap infrastructure, specifically how `sk_forward_alloc` memory accounting is handled when a stream parser (strparser) program returns `SK_PASS` and the skb is delivered to the same socket's ingress queue. It introduces `sk_psock_skb_ingress_self_assign` to settle any existing `sk_forward_alloc` deficit before assigning receive ownership to the skb. This is a functional change in reachable core kernel logic (BPF sockmap and stream parser) and is worth fuzzing to ensure memory accounting remains correct under various network conditions and BPF program behaviors.",
"WorthFuzzing": true
} |
| 1/1 | 2026/08/17 16:44 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 0b0e8cf8b321df88c026daea576491fca5c736e2\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Mon Aug 17 16:44:14 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/net/core/skmsg.c b/net/core/skmsg.c\nindex 2521b643fa05d..347cb168f7491 100644\n--- a/net/core/skmsg.c\n+++ b/net/core/skmsg.c\n@@ -586,21 +586,24 @@ static int sk_psock_skb_ingress_enqueue(struct sk_buff *skb,\n }\n \n static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,\n-\t\t\t\t u32 off, u32 len, bool take_ref);\n+\t\t\t\t u32 off, u32 len, bool take_ref,\n+\t\t\t\t bool settle_fwd_alloc);\n+static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,\n+\t\t\t\t\t struct sk_buff *skb,\n+\t\t\t\t\t u32 off, u32 len, bool take_ref,\n+\t\t\t\t\t bool settle_fwd_alloc);\n \n static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,\n-\t\t\t\tu32 off, u32 len)\n+\t\t\t\tu32 off, u32 len, bool settle_fwd_alloc)\n {\n \tstruct sock *sk = psock-\u003esk;\n \tstruct sk_msg *msg;\n \tint err;\n \n-\t/* If we are receiving on the same sock skb-\u003esk is already assigned,\n-\t * skip memory accounting and owner transition seeing it already set\n-\t * correctly.\n-\t */\n \tif (unlikely(skb-\u003esk == sk))\n-\t\treturn sk_psock_skb_ingress_self(psock, skb, off, len, true);\n+\t\treturn sk_psock_skb_ingress_self_backlog(psock, skb, off,\n+\t\t\t\t\t\t\t len, true,\n+\t\t\t\t\t\t\t settle_fwd_alloc);\n \tmsg = sk_psock_create_ingress_msg(sk, skb);\n \tif (!msg)\n \t\treturn -EAGAIN;\n@@ -618,34 +621,100 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,\n \treturn err;\n }\n \n-/* Puts an skb on the ingress queue of the socket already assigned to the\n- * skb. In this case we do not need to check memory limits or skb_set_owner_r\n- * because the skb is already accounted for here.\n+static int sk_psock_skb_ingress_self_assign(struct sock *sk,\n+\t\t\t\t\t struct sk_buff *skb,\n+\t\t\t\t\t bool settle_fwd_alloc)\n+{\n+\t/* Leave skbs already receive-accounted to sk untouched. */\n+\tif (skb-\u003esk == sk \u0026\u0026 skb-\u003edestructor == sock_rfree)\n+\t\treturn 0;\n+\n+\tif (settle_fwd_alloc) {\n+\t\tsock_owned_by_me(sk);\n+\n+\t\tif (!sk_rmem_schedule(sk, skb, 0))\n+\t\t\treturn -EAGAIN;\n+\t}\n+\n+\tskb_set_owner_r(skb, sk);\n+\treturn 0;\n+}\n+\n+/* Puts an skb on the ingress queue for psock-\u003esk.\n+ *\n+ * If the skb already has receive ownership for this socket, leave socket\n+ * memory accounting untouched. Otherwise, before assigning receive ownership\n+ * to an unowned strparser SK_PASS skb, settle any existing sk_forward_alloc\n+ * deficit from earlier clone charges.\n */\n static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,\n-\t\t\t\t u32 off, u32 len, bool take_ref)\n+\t\t\t\t u32 off, u32 len, bool take_ref,\n+\t\t\t\t bool settle_fwd_alloc)\n {\n+\tstruct sock *sk = psock-\u003esk;\n \tstruct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);\n+\tint err;\n+\n+\tif (unlikely(!msg))\n+\t\treturn -EAGAIN;\n+\n+\terr = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);\n+\tif (err)\n+\t\tgoto free;\n+\n+\t/* This is used in tcp_bpf_recvmsg_parser() to determine whether the\n+\t * data originates from the socket's own protocol stack. No need to\n+\t * refcount sk because msg's lifetime is bound to sk via the ingress_msg.\n+\t */\n+\tmsg-\u003esk = sk;\n+\terr = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,\n+\t\t\t\t\t take_ref);\n+\tif (err \u003c 0)\n+\t\tgoto free;\n+\n+\treturn err;\n+free:\n+\tkfree(msg);\n+\treturn err;\n+}\n+\n+static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,\n+\t\t\t\t\t struct sk_buff *skb,\n+\t\t\t\t\t u32 off, u32 len, bool take_ref,\n+\t\t\t\t\t bool settle_fwd_alloc)\n+{\n \tstruct sock *sk = psock-\u003esk;\n+\tstruct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);\n \tint err;\n \n \tif (unlikely(!msg))\n \t\treturn -EAGAIN;\n-\tskb_set_owner_r(skb, sk);\n+\n+\tlock_sock(sk);\n+\terr = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);\n+\trelease_sock(sk);\n+\tif (err)\n+\t\tgoto free;\n \n \t/* This is used in tcp_bpf_recvmsg_parser() to determine whether the\n \t * data originates from the socket's own protocol stack. No need to\n \t * refcount sk because msg's lifetime is bound to sk via the ingress_msg.\n \t */\n \tmsg-\u003esk = sk;\n-\terr = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg, take_ref);\n+\terr = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,\n+\t\t\t\t\t take_ref);\n \tif (err \u003c 0)\n-\t\tkfree(msg);\n+\t\tgoto free;\n+\n+\treturn err;\n+free:\n+\tkfree(msg);\n \treturn err;\n }\n \n static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb,\n-\t\t\t u32 off, u32 len, bool ingress)\n+\t\t\t u32 off, u32 len, bool ingress,\n+\t\t\t bool self_pass, bool strparser)\n {\n \tif (!ingress) {\n \t\tif (!sock_writeable(psock-\u003esk))\n@@ -653,7 +722,11 @@ static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb,\n \t\treturn skb_send_sock(psock-\u003esk, skb, off, len);\n \t}\n \n-\treturn sk_psock_skb_ingress(psock, skb, off, len);\n+\tif (self_pass)\n+\t\treturn sk_psock_skb_ingress_self_backlog(psock, skb, off,\n+\t\t\t\t\t\t\t len, true, strparser);\n+\n+\treturn sk_psock_skb_ingress(psock, skb, off, len, strparser);\n }\n \n static void sk_psock_skb_state(struct sk_psock *psock,\n@@ -694,9 +767,14 @@ static void sk_psock_backlog(struct work_struct *work)\n \t\treturn;\n \tmutex_lock(\u0026psock-\u003ework_mutex);\n \twhile ((skb = skb_peek(\u0026psock-\u003eingress_skb))) {\n+\t\tunsigned long saved_redir;\n+\t\tbool strparser;\n+\t\tbool self_pass;\n+\n \t\tlen = skb-\u003elen;\n \t\toff = 0;\n-\t\tif (skb_bpf_strparser(skb)) {\n+\t\tstrparser = skb_bpf_strparser(skb);\n+\t\tif (strparser) {\n \t\t\tstruct strp_msg *stm = strp_msg(skb);\n \n \t\t\toff = stm-\u003eoffset;\n@@ -710,17 +788,20 @@ static void sk_psock_backlog(struct work_struct *work)\n \t\t}\n \n \t\tingress = skb_bpf_ingress(skb);\n+\t\tself_pass = ingress \u0026\u0026 !skb_bpf_redirect_fetch(skb);\n+\t\tsaved_redir = skb-\u003e_sk_redir;\n \t\tskb_bpf_redirect_clear(skb);\n \t\tdo {\n \t\t\tret = -EIO;\n \t\t\tif (!sock_flag(psock-\u003esk, SOCK_DEAD))\n \t\t\t\tret = sk_psock_handle_skb(psock, skb, off,\n-\t\t\t\t\t\t\t len, ingress);\n+\t\t\t\t\t\t\t len, ingress,\n+\t\t\t\t\t\t\t self_pass, strparser);\n \t\t\tif (ret \u003c= 0) {\n \t\t\t\tif (ret == -EAGAIN) {\n \t\t\t\t\tsk_psock_skb_state(psock, state, len, off);\n \t\t\t\t\t/* Restore redir info we cleared before */\n-\t\t\t\t\tskb_bpf_set_redir(skb, psock-\u003esk, ingress);\n+\t\t\t\t\tskb-\u003e_sk_redir = saved_redir;\n \t\t\t\t\t/* Delay slightly to prioritize any\n \t\t\t\t\t * other work that might be here.\n \t\t\t\t\t */\n@@ -1017,6 +1098,8 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,\n \t\t * retrying later from workqueue.\n \t\t */\n \t\tif (skb_queue_empty(\u0026psock-\u003eingress_skb)) {\n+\t\t\tbool settle_fwd_alloc = false;\n+\n \t\t\tlen = skb-\u003elen;\n \t\t\toff = 0;\n \t\t\tif (skb_bpf_strparser(skb)) {\n@@ -1024,8 +1107,10 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,\n \n \t\t\t\toff = stm-\u003eoffset;\n \t\t\t\tlen = stm-\u003efull_len;\n+\t\t\t\tsettle_fwd_alloc = true;\n \t\t\t}\n-\t\t\terr = sk_psock_skb_ingress_self(psock, skb, off, len, false);\n+\t\t\terr = sk_psock_skb_ingress_self(psock, skb, off, len,\n+\t\t\t\t\t\t\tfalse, settle_fwd_alloc);\n \t\t}\n \t\tif (err \u003c 0) {\n \t\t\tspin_lock_bh(\u0026psock-\u003eingress_lock);\ndiff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c b/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c\nindex 1d7231728eafd..c7ad21d0bbf49 100644\n--- a/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c\n+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c\n@@ -1,5 +1,9 @@\n // SPDX-License-Identifier: GPL-2.0\n #include \u003cerror.h\u003e\n+#include \u003clinux/inet_diag.h\u003e\n+#include \u003clinux/netlink.h\u003e\n+#include \u003clinux/rtnetlink.h\u003e\n+#include \u003clinux/sock_diag.h\u003e\n #include \u003cnetinet/tcp.h\u003e\n #include \u003ctest_progs.h\u003e\n #include \"sockmap_helpers.h\"\n@@ -460,6 +464,171 @@ static void test_sockmap_strp_parser_reject(void)\n \ttest_sockmap_strp__destroy(strp);\n }\n \n+/* Read sk_forward_alloc through inet_diag meminfo. */\n+static int sockmap_strp_get_fwd_alloc(int sock, int *fwd_alloc)\n+{\n+\tstruct sockaddr_storage local = {}, peer = {};\n+\tstruct sockaddr_in *local_in, *peer_in;\n+\tsocklen_t addr_len = sizeof(local);\n+\tchar buf[1024];\n+\tstruct {\n+\t\tstruct nlmsghdr nlh;\n+\t\tstruct inet_diag_req_v2 req;\n+\t} req = {\n+\t\t.nlh = {\n+\t\t\t.nlmsg_len = sizeof(req),\n+\t\t\t.nlmsg_type = SOCK_DIAG_BY_FAMILY,\n+\t\t\t.nlmsg_flags = NLM_F_REQUEST,\n+\t\t\t.nlmsg_seq = 1,\n+\t\t},\n+\t\t.req = {\n+\t\t\t.sdiag_family = AF_INET,\n+\t\t\t.sdiag_protocol = IPPROTO_TCP,\n+\t\t\t.idiag_ext = 1 \u003c\u003c (INET_DIAG_MEMINFO - 1),\n+\t\t\t.idiag_states = ~0U,\n+\t\t\t.id.idiag_cookie = {\n+\t\t\t\tINET_DIAG_NOCOOKIE,\n+\t\t\t\tINET_DIAG_NOCOOKIE,\n+\t\t\t},\n+\t\t},\n+\t};\n+\tint diag_fd, ret, err = -ENOENT;\n+\n+\tif (getsockname(sock, (struct sockaddr *)\u0026local, \u0026addr_len))\n+\t\treturn -errno;\n+\taddr_len = sizeof(peer);\n+\tif (getpeername(sock, (struct sockaddr *)\u0026peer, \u0026addr_len))\n+\t\treturn -errno;\n+\n+\tlocal_in = (struct sockaddr_in *)\u0026local;\n+\tpeer_in = (struct sockaddr_in *)\u0026peer;\n+\treq.req.id.idiag_sport = local_in-\u003esin_port;\n+\treq.req.id.idiag_dport = peer_in-\u003esin_port;\n+\treq.req.id.idiag_src[0] = local_in-\u003esin_addr.s_addr;\n+\treq.req.id.idiag_dst[0] = peer_in-\u003esin_addr.s_addr;\n+\n+\tdiag_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC,\n+\t\t\t NETLINK_SOCK_DIAG);\n+\tif (diag_fd \u003c 0)\n+\t\treturn -errno;\n+\n+\tret = send(diag_fd, \u0026req, sizeof(req), 0);\n+\tif (ret \u003c 0) {\n+\t\terr = -errno;\n+\t\tgoto out;\n+\t}\n+\tif (ret != sizeof(req)) {\n+\t\terr = -EIO;\n+\t\tgoto out;\n+\t}\n+\n+\tret = recv(diag_fd, buf, sizeof(buf), 0);\n+\tif (ret \u003c 0) {\n+\t\terr = -errno;\n+\t\tgoto out;\n+\t}\n+\n+\tfor (struct nlmsghdr *nlh = (struct nlmsghdr *)buf;\n+\t NLMSG_OK(nlh, ret); nlh = NLMSG_NEXT(nlh, ret)) {\n+\t\tstruct inet_diag_msg *msg = NLMSG_DATA(nlh);\n+\t\tstruct rtattr *attr;\n+\t\tint len;\n+\n+\t\tif (nlh-\u003enlmsg_type == NLMSG_ERROR) {\n+\t\t\terr = -EINVAL;\n+\t\t\tgoto out;\n+\t\t}\n+\t\tif (nlh-\u003enlmsg_type == NLMSG_DONE)\n+\t\t\tbreak;\n+\n+\t\tlen = nlh-\u003enlmsg_len - NLMSG_LENGTH(sizeof(*msg));\n+\t\tfor (attr = (struct rtattr *)(msg + 1); RTA_OK(attr, len);\n+\t\t attr = RTA_NEXT(attr, len)) {\n+\t\t\tstruct inet_diag_meminfo *minfo;\n+\n+\t\t\tif (attr-\u003erta_type != INET_DIAG_MEMINFO)\n+\t\t\t\tcontinue;\n+\t\t\tminfo = RTA_DATA(attr);\n+\t\t\t*fwd_alloc = (__s32)minfo-\u003eidiag_fmem;\n+\t\t\terr = 0;\n+\t\t\tgoto out;\n+\t\t}\n+\t}\n+\n+out:\n+\tclose(diag_fd);\n+\treturn err;\n+}\n+\n+/* Test strparser SK_PASS delivery to the same socket. */\n+static void test_sockmap_strp_self_pass_fwd_alloc(void)\n+{\n+\tstruct test_sockmap_strp *strp = NULL;\n+\tchar snd[4 * 1024];\n+\tint c = -1, p = -1;\n+\tint fwd_alloc;\n+\tint sndbuf = sizeof(snd);\n+\tint zero = 0;\n+\tchar rcv;\n+\tint sent, recvd;\n+\tint map;\n+\tint err;\n+\n+\tmemset(snd, 0xa5, sizeof(snd));\n+\n+\tstrp = test_sockmap_strp__open_and_load();\n+\tif (!ASSERT_OK_PTR(strp, \"test_sockmap_strp__open_and_load\"))\n+\t\treturn;\n+\n+\tmap = bpf_map__fd(strp-\u003emaps.sock_map);\n+\terr = xbpf_prog_attach(bpf_program__fd(strp-\u003eprogs.prog_skb_parser_one),\n+\t\t\t map, BPF_SK_SKB_STREAM_PARSER, 0);\n+\tif (err)\n+\t\tgoto out_destroy;\n+\n+\terr = xbpf_prog_attach(bpf_program__fd(strp-\u003eprogs.prog_skb_verdict_pass),\n+\t\t\t map, BPF_SK_SKB_STREAM_VERDICT, 0);\n+\tif (err)\n+\t\tgoto out_destroy;\n+\n+\terr = create_pair(AF_INET, SOCK_STREAM, \u0026c, \u0026p);\n+\tif (!ASSERT_OK(err, \"create_pair\"))\n+\t\tgoto out_destroy;\n+\n+\terr = xsetsockopt(c, SOL_SOCKET, SO_SNDBUF, \u0026sndbuf, sizeof(sndbuf));\n+\tif (err)\n+\t\tgoto out_destroy;\n+\n+\terr = xsetsockopt(p, SOL_SOCKET, SO_RCVBUF, \u0026sndbuf, sizeof(sndbuf));\n+\tif (err)\n+\t\tgoto out_destroy;\n+\n+\terr = xbpf_map_update_elem(map, \u0026zero, \u0026p, BPF_NOEXIST);\n+\tif (err)\n+\t\tgoto out_destroy;\n+\n+\tsent = send(c, snd, sizeof(snd), MSG_DONTWAIT);\n+\tif (!ASSERT_EQ(sent, sizeof(snd), \"send\"))\n+\t\tgoto out_destroy;\n+\n+\trecvd = recv_timeout(p, \u0026rcv, sizeof(rcv), MSG_DONTWAIT,\n+\t\t\t IO_TIMEOUT_SEC);\n+\tif (!ASSERT_EQ(recvd, sizeof(rcv), \"recv_timeout\") ||\n+\t !ASSERT_EQ(rcv, snd[0], \"data mismatch\"))\n+\t\tgoto out_destroy;\n+\n+\terr = sockmap_strp_get_fwd_alloc(p, \u0026fwd_alloc);\n+\tif (!ASSERT_OK(err, \"sockmap_strp_get_fwd_alloc\") ||\n+\t !ASSERT_GE(fwd_alloc, 0, \"sk_forward_alloc\"))\n+\t\tgoto out_destroy;\n+out_destroy:\n+\ttest_sockmap_strp__destroy(strp);\n+\tif (c \u003e= 0)\n+\t\tclose(c);\n+\tif (p \u003e= 0)\n+\t\tclose(p);\n+}\n+\n void test_sockmap_strp(void)\n {\n \tif (test__start_subtest(\"sockmap strp tcp pass\"))\n@@ -482,4 +651,6 @@ void test_sockmap_strp(void)\n \t\ttest_sockmap_strp_dispatch_pkt(AF_INET, SOCK_STREAM);\n \tif (test__start_subtest(\"sockmap strp parser reject pkt mod\"))\n \t\ttest_sockmap_strp_parser_reject();\n+\tif (test__start_subtest(\"sockmap strp self pass fwd alloc\"))\n+\t\ttest_sockmap_strp_self_pass_fwd_alloc();\n }\ndiff --git a/tools/testing/selftests/bpf/progs/test_sockmap_strp.c b/tools/testing/selftests/bpf/progs/test_sockmap_strp.c\nindex fe88fa6d40bc5..682e53d40751c 100644\n--- a/tools/testing/selftests/bpf/progs/test_sockmap_strp.c\n+++ b/tools/testing/selftests/bpf/progs/test_sockmap_strp.c\n@@ -50,6 +50,12 @@ int prog_skb_parser_partial(struct __sk_buff *skb)\n \treturn 10;\n }\n \n+SEC(\"sk_skb/stream_parser\")\n+int prog_skb_parser_one(struct __sk_buff *skb)\n+{\n+\treturn 1;\n+}\n+\n SEC(\"sk_skb/stream_parser\")\n int prog_skb_parser_resize(struct __sk_buff *skb)\n {\n"
} |
| 2/1 | 2026/08/17 16:44 | agent | patch-evaluator |
3mModel:best-expensive Args: null Results: {
"EnableConfigs": [
"BPF_SYSCALL",
"BPF_STREAM_PARSER"
],
"FocusSymbols": [
"sock_map_update_elem_sys",
"sock_map_get_from_fd",
"tcp_bpf_update_proto",
"tcp_bpf_strp_read_sock"
],
"Reasoning": "The patch modifies the BPF sockmap infrastructure, specifically how `sk_forward_alloc` memory accounting is handled when a stream parser (strparser) program returns `SK_PASS` and the skb is delivered to the same socket's ingress queue. It introduces `sk_psock_skb_ingress_self_assign` to settle any existing `sk_forward_alloc` deficit before assigning receive ownership to the skb. This is a functional change in reachable core kernel logic (BPF sockmap and stream parser) and is worth fuzzing to ensure memory accounting remains correct under various network conditions and BPF program behaviors.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). - Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU. - Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove) that are executed only during PCI hot-unplug or sysfs driver unbind operations. If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. Prefer non-static, non-inlined API entrypoint functions over internal static helper functions (which are inlined by the compiler and do not have distinct symbol addresses). 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs output array, and DO NOT add a '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: For your convenience, here is the diff of the changes:
commit 0b0e8cf8b321df88c026daea576491fca5c736e2
Author: syz-cluster <triage@syzkaller.com>
Date: Mon Aug 17 16:44:14 2026 +0000
syz-cluster: applied patch under review
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 2521b643fa05d..347cb168f7491 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -586,21 +586,24 @@ static int sk_psock_skb_ingress_enqueue(struct sk_buff *skb,
}
static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len, bool take_ref);
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc);
+static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,
+ struct sk_buff *skb,
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc);
static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len)
+ u32 off, u32 len, bool settle_fwd_alloc)
{
struct sock *sk = psock->sk;
struct sk_msg *msg;
int err;
- /* If we are receiving on the same sock skb->sk is already assigned,
- * skip memory accounting and owner transition seeing it already set
- * correctly.
- */
if (unlikely(skb->sk == sk))
- return sk_psock_skb_ingress_self(psock, skb, off, len, true);
+ return sk_psock_skb_ingress_self_backlog(psock, skb, off,
+ len, true,
+ settle_fwd_alloc);
msg = sk_psock_create_ingress_msg(sk, skb);
if (!msg)
return -EAGAIN;
@@ -618,34 +621,100 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,
return err;
}
-/* Puts an skb on the ingress queue of the socket already assigned to the
- * skb. In this case we do not need to check memory limits or skb_set_owner_r
- * because the skb is already accounted for here.
+static int sk_psock_skb_ingress_self_assign(struct sock *sk,
+ struct sk_buff *skb,
+ bool settle_fwd_alloc)
+{
+ /* Leave skbs already receive-accounted to sk untouched. */
+ if (skb->sk == sk && skb->destructor == sock_rfree)
+ return 0;
+
+ if (settle_fwd_alloc) {
+ sock_owned_by_me(sk);
+
+ if (!sk_rmem_schedule(sk, skb, 0))
+ return -EAGAIN;
+ }
+
+ skb_set_owner_r(skb, sk);
+ return 0;
+}
+
+/* Puts an skb on the ingress queue for psock->sk.
+ *
+ * If the skb already has receive ownership for this socket, leave socket
+ * memory accounting untouched. Otherwise, before assigning receive ownership
+ * to an unowned strparser SK_PASS skb, settle any existing sk_forward_alloc
+ * deficit from earlier clone charges.
*/
static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len, bool take_ref)
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc)
{
+ struct sock *sk = psock->sk;
struct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);
+ int err;
+
+ if (unlikely(!msg))
+ return -EAGAIN;
+
+ err = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);
+ if (err)
+ goto free;
+
+ /* This is used in tcp_bpf_recvmsg_parser() to determine whether the
+ * data originates from the socket's own protocol stack. No need to
+ * refcount sk because msg's lifetime is bound to sk via the ingress_msg.
+ */
+ msg->sk = sk;
+ err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,
+ take_ref);
+ if (err < 0)
+ goto free;
+
+ return err;
+free:
+ kfree(msg);
+ return err;
+}
+
+static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,
+ struct sk_buff *skb,
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc)
+{
struct sock *sk = psock->sk;
+ struct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);
int err;
if (unlikely(!msg))
return -EAGAIN;
- skb_set_owner_r(skb, sk);
+
+ lock_sock(sk);
+ err = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);
+ release_sock(sk);
+ if (err)
+ goto free;
/* This is used in tcp_bpf_recvmsg_parser() to determine whether the
* data originates from the socket's own protocol stack. No need to
* refcount sk because msg's lifetime is bound to sk via the ingress_msg.
*/
msg->sk = sk;
- err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg, take_ref);
+ err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,
+ take_ref);
if (err < 0)
- kfree(msg);
+ goto free;
+
+ return err;
+free:
+ kfree(msg);
return err;
}
static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len, bool ingress)
+ u32 off, u32 len, bool ingress,
+ bool self_pass, bool strparser)
{
if (!ingress) {
if (!sock_writeable(psock->sk))
@@ -653,7 +722,11 @@ static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb,
return skb_send_sock(psock->sk, skb, off, len);
}
- return sk_psock_skb_ingress(psock, skb, off, len);
+ if (self_pass)
+ return sk_psock_skb_ingress_self_backlog(psock, skb, off,
+ len, true, strparser);
+
+ return sk_psock_skb_ingress(psock, skb, off, len, strparser);
}
static void sk_psock_skb_state(struct sk_psock *psock,
@@ -694,9 +767,14 @@ static void sk_psock_backlog(struct work_struct *work)
return;
mutex_lock(&psock->work_mutex);
while ((skb = skb_peek(&psock->ingress_skb))) {
+ unsigned long saved_redir;
+ bool strparser;
+ bool self_pass;
+
len = skb->len;
off = 0;
- if (skb_bpf_strparser(skb)) {
+ strparser = skb_bpf_strparser(skb);
+ if (strparser) {
struct strp_msg *stm = strp_msg(skb);
off = stm->offset;
@@ -710,17 +788,20 @@ static void sk_psock_backlog(struct work_struct *work)
}
ingress = skb_bpf_ingress(skb);
+ self_pass = ingress && !skb_bpf_redirect_fetch(skb);
+ saved_redir = skb->_sk_redir;
skb_bpf_redirect_clear(skb);
do {
ret = -EIO;
if (!sock_flag(psock->sk, SOCK_DEAD))
ret = sk_psock_handle_skb(psock, skb, off,
- len, ingress);
+ len, ingress,
+ self_pass, strparser);
if (ret <= 0) {
if (ret == -EAGAIN) {
sk_psock_skb_state(psock, state, len, off);
/* Restore redir info we cleared before */
- skb_bpf_set_redir(skb, psock->sk, ingress);
+ skb->_sk_redir = saved_redir;
/* Delay slightly to prioritize any
* other work that might be here.
*/
@@ -1017,6 +1098,8 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,
* retrying later from workqueue.
*/
if (skb_queue_empty(&psock->ingress_skb)) {
+ bool settle_fwd_alloc = false;
+
len = skb->len;
off = 0;
if (skb_bpf_strparser(skb)) {
@@ -1024,8 +1107,10 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,
off = stm->offset;
len = stm->full_len;
+ settle_fwd_alloc = true;
}
- err = sk_psock_skb_ingress_self(psock, skb, off, len, false);
+ err = sk_psock_skb_ingress_self(psock, skb, off, len,
+ false, settle_fwd_alloc);
}
if (err < 0) {
spin_lock_bh(&psock->ingress_lock);
diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c b/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c
index 1d7231728eafd..c7ad21d0bbf49 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c
@@ -1,5 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <error.h>
+#include <linux/inet_diag.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+#include <linux/sock_diag.h>
#include <netinet/tcp.h>
#include <test_progs.h>
#include "sockmap_helpers.h"
@@ -460,6 +464,171 @@ static void test_sockmap_strp_parser_reject(void)
test_sockmap_strp__destroy(strp);
}
+/* Read sk_forward_alloc through inet_diag meminfo. */
+static int sockmap_strp_get_fwd_alloc(int sock, int *fwd_alloc)
+{
+ struct sockaddr_storage local = {}, peer = {};
+ struct sockaddr_in *local_in, *peer_in;
+ socklen_t addr_len = sizeof(local);
+ char buf[1024];
+ struct {
+ struct nlmsghdr nlh;
+ struct inet_diag_req_v2 req;
+ } req = {
+ .nlh = {
+ .nlmsg_len = sizeof(req),
+ .nlmsg_type = SOCK_DIAG_BY_FAMILY,
+ .nlmsg_flags = NLM_F_REQUEST,
+ .nlmsg_seq = 1,
+ },
+ .req = {
+ .sdiag_family = AF_INET,
+ .sdiag_protocol = IPPROTO_TCP,
+ .idiag_ext = 1 << (INET_DIAG_MEMINFO - 1),
+ .idiag_states = ~0U,
+ .id.idiag_cookie = {
+ INET_DIAG_NOCOOKIE,
+ INET_DIAG_NOCOOKIE,
+ },
+ },
+ };
+ int diag_fd, ret, err = -ENOENT;
+
+ if (getsockname(sock, (struct sockaddr *)&local, &addr_len))
+ return -errno;
+ addr_len = sizeof(peer);
+ if (getpeername(sock, (struct sockaddr *)&peer, &addr_len))
+ return -errno;
+
+ local_in = (struct sockaddr_in *)&local;
+ peer_in = (struct sockaddr_in *)&peer;
+ req.req.id.idiag_sport = local_in->sin_port;
+ req.req.id.idiag_dport = peer_in->sin_port;
+ req.req.id.idiag_src[0] = local_in->sin_addr.s_addr;
+ req.req.id.idiag_dst[0] = peer_in->sin_addr.s_addr;
+
+ diag_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC,
+ NETLINK_SOCK_DIAG);
+ if (diag_fd < 0)
+ return -errno;
+
+ ret = send(diag_fd, &req, sizeof(req), 0);
+ if (ret < 0) {
+ err = -errno;
+ goto out;
+ }
+ if (ret != sizeof(req)) {
+ err = -EIO;
+ goto out;
+ }
+
+ ret = recv(diag_fd, buf, sizeof(buf), 0);
+ if (ret < 0) {
+ err = -errno;
+ goto out;
+ }
+
+ for (struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
+ NLMSG_OK(nlh, ret); nlh = NLMSG_NEXT(nlh, ret)) {
+ struct inet_diag_msg *msg = NLMSG_DATA(nlh);
+ struct rtattr *attr;
+ int len;
+
+ if (nlh->nlmsg_type == NLMSG_ERROR) {
+ err = -EINVAL;
+ goto out;
+ }
+ if (nlh->nlmsg_type == NLMSG_DONE)
+ break;
+
+ len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*msg));
+ for (attr = (struct rtattr *)(msg + 1); RTA_OK(attr, len);
+ attr = RTA_NEXT(attr, len)) {
+ struct inet_diag_meminfo *minfo;
+
+ if (attr->rta_type != INET_DIAG_MEMINFO)
+ continue;
+ minfo = RTA_DATA(attr);
+ *fwd_alloc = (__s32)minfo->idiag_fmem;
+ err = 0;
+ goto out;
+ }
+ }
+
+out:
+ close(diag_fd);
+ return err;
+}
+
+/* Test strparser SK_PASS delivery to the same socket. */
+static void test_sockmap_strp_self_pass_fwd_alloc(void)
+{
+ struct test_sockmap_strp *strp = NULL;
+ char snd[4 * 1024];
+ int c = -1, p = -1;
+ int fwd_alloc;
+ int sndbuf = sizeof(snd);
+ int zero = 0;
+ char rcv;
+ int sent, recvd;
+ int map;
+ int err;
+
+ memset(snd, 0xa5, sizeof(snd));
+
+ strp = test_sockmap_strp__open_and_load();
+ if (!ASSERT_OK_PTR(strp, "test_sockmap_strp__open_and_load"))
+ return;
+
+ map = bpf_map__fd(strp->maps.sock_map);
+ err = xbpf_prog_attach(bpf_program__fd(strp->progs.prog_skb_parser_one),
+ map, BPF_SK_SKB_STREAM_PARSER, 0);
+ if (err)
+ goto out_destroy;
+
+ err = xbpf_prog_attach(bpf_program__fd(strp->progs.prog_skb_verdict_pass),
+ map, BPF_SK_SKB_STREAM_VERDICT, 0);
+ if (err)
+ goto out_destroy;
+
+ err = create_pair(AF_INET, SOCK_STREAM, &c, &p);
+ if (!ASSERT_OK(err, "create_pair"))
+ goto out_destroy;
+
+ err = xsetsockopt(c, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf));
+ if (err)
+ goto out_destroy;
+
+ err = xsetsockopt(p, SOL_SOCKET, SO_RCVBUF, &sndbuf, sizeof(sndbuf));
+ if (err)
+ goto out_destroy;
+
+ err = xbpf_map_update_elem(map, &zero, &p, BPF_NOEXIST);
+ if (err)
+ goto out_destroy;
+
+ sent = send(c, snd, sizeof(snd), MSG_DONTWAIT);
+ if (!ASSERT_EQ(sent, sizeof(snd), "send"))
+ goto out_destroy;
+
+ recvd = recv_timeout(p, &rcv, sizeof(rcv), MSG_DONTWAIT,
+ IO_TIMEOUT_SEC);
+ if (!ASSERT_EQ(recvd, sizeof(rcv), "recv_timeout") ||
+ !ASSERT_EQ(rcv, snd[0], "data mismatch"))
+ goto out_destroy;
+
+ err = sockmap_strp_get_fwd_alloc(p, &fwd_alloc);
+ if (!ASSERT_OK(err, "sockmap_strp_get_fwd_alloc") ||
+ !ASSERT_GE(fwd_alloc, 0, "sk_forward_alloc"))
+ goto out_destroy;
+out_destroy:
+ test_sockmap_strp__destroy(strp);
+ if (c >= 0)
+ close(c);
+ if (p >= 0)
+ close(p);
+}
+
void test_sockmap_strp(void)
{
if (test__start_subtest("sockmap strp tcp pass"))
@@ -482,4 +651,6 @@ void test_sockmap_strp(void)
test_sockmap_strp_dispatch_pkt(AF_INET, SOCK_STREAM);
if (test__start_subtest("sockmap strp parser reject pkt mod"))
test_sockmap_strp_parser_reject();
+ if (test__start_subtest("sockmap strp self pass fwd alloc"))
+ test_sockmap_strp_self_pass_fwd_alloc();
}
diff --git a/tools/testing/selftests/bpf/progs/test_sockmap_strp.c b/tools/testing/selftests/bpf/progs/test_sockmap_strp.c
index fe88fa6d40bc5..682e53d40751c 100644
--- a/tools/testing/selftests/bpf/progs/test_sockmap_strp.c
+++ b/tools/testing/selftests/bpf/progs/test_sockmap_strp.c
@@ -50,6 +50,12 @@ int prog_skb_parser_partial(struct __sk_buff *skb)
return 10;
}
+SEC("sk_skb/stream_parser")
+int prog_skb_parser_one(struct __sk_buff *skb)
+{
+ return 1;
+}
+
SEC("sk_skb/stream_parser")
int prog_skb_parser_resize(struct __sk_buff *skb)
{
|
| 3/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 7281 output: 29 thoughts: 340 Thoughts: **Analyzing a Patch: Sockmap/SKMSG Core Logic** Okay, so I'm looking at this patch and my initial impression is that it's touching pretty critical stuff within the BPF sockmap infrastructure. We have modifications to `net/core/skmsg.c` which, if I remember correctly, is compiled with `CONFIG_NET_SOCK_MSG`. That's the heart of the SKMSG functionality, and that always gets my attention. We're also seeing a corresponding test added in `tools/testing/selftests/bpf/prog_tests/sockmap_strp.c`, which is good; regression tests are crucial, but let's see if it's thorough. Specifically, the patch seems to be reworking how `sk_forward_alloc` is handled when a `strparser` SK_PASS skb gets delivered to the *same* socket. That's interesting, and potentially a very tricky area from a concurrency and resource management perspective. I need to quickly confirm the exact functions involved. I'm seeing changes to: `sk_psock_skb_ingress_self`, `sk_psock_skb_ingress_self_backlog`, `sk_psock_skb_ingress`, `sk_psock_handle_skb`, `sk_psock_backlog`, and `sk_psock_verdict_apply`. That's a comprehensive touch on the ingress path. Looks like we're introducing `sk_psock_skb_ingress_self_assign`, which probably means we're trying to optimize the direct ingress path to the socket, or something like that. Given the scope of the changes and the centrality of these functions, this is definitely kernel logic that's worth a *very* close look and likely fuzzing. I'll need to go back and verify the kernel configs – confirm `CONFIG_NET_SOCK_MSG` and possibly other related ones, and then it's time to dig into the code and see how `sk_forward_alloc` is actually being used in this context. |
| 4/2 | 2026/08/17 16:44 | tool | grepper |
0mArgs:{
"Expression": "skmsg.o",
"PathPrefix": "net/core/Makefile"
}Results: {
"Output": "net/core/Makefile=43=obj-$(CONFIG_FAILOVER) += failover.o\nnet/core/Makefile:44:obj-$(CONFIG_NET_SOCK_MSG) += skmsg.o\nnet/core/Makefile-45-obj-$(CONFIG_BPF_SYSCALL) += sock_map.o\n"
} |
| 5/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 8184 output: 30 thoughts: 38 Thoughts: Okay, here's my take on those thoughts, framed as my own mental process, given my expertise: **Checking the Dependencies of `CONFIG_NET_SOCK_MSG`** Alright, the code's pointing to a requirement for `CONFIG_NET_SOCK_MSG`. My initial thought is to figure out the dependencies and potential configurability of this option. I need to understand what other features or configurations trigger this setting. Is it something that's automatically selected based on another choice higher up in the configuration hierarchy, or is it directly user-selectable? Is there some context I'm missing? I need to drill down and see *what* exactly selects this or gives me the ability to decide. This will help me diagnose why this is being requested and what impact it will have on the broader system. I'll start digging through the Kconfig files, starting with the immediate surrounding code and then tracing back to see what paths lead to its activation. Understanding this dependency is key to understanding the bigger picture. |
| 6/2 | 2026/08/17 16:44 | tool | grepper |
0mArgs:{
"Expression": "config NET_SOCK_MSG",
"PathPrefix": "net/Kconfig"
}Results: {
"Output": "net/Kconfig=475=config NET_SELFTESTS\n--\nnet/Kconfig-478-\nnet/Kconfig:479:config NET_SOCK_MSG\nnet/Kconfig-480-\tbool\n"
} |
| 7/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 8529 output: 20 thoughts: 15 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Analyzing a Boolean Flag** Okay, so I've stumbled upon a hidden boolean variable. My initial instinct is to dig deeper and understand its purpose. "Hidden" usually means there's a reason it's not immediately obvious, and that reason is likely going to provide the important information. My first step is to trace all the potential code paths that could possibly set or modify this flag. I need to figure out the conditions that trigger a change in its state; what code selects (or sets) it? Knowing *when* this flag flips is key to understanding its implications within the system's overall logic. From there, I can begin to infer the larger design context and see what this bool is meant to signal. |
| 8/2 | 2026/08/17 16:44 | tool | grepper |
0mArgs:{
"Expression": "select NET_SOCK_MSG"
}Results: {
"Output": "kernel/bpf/Kconfig=27=config BPF_SYSCALL\n--\nkernel/bpf/Kconfig-33-\tselect BINARY_PRINTF\nkernel/bpf/Kconfig:34:\tselect NET_SOCK_MSG if NET\nkernel/bpf/Kconfig-35-\tselect NET_XGRESS if NET\n--\nnet/Kconfig=361=config BPF_STREAM_PARSER\n--\nnet/Kconfig-366-\tselect STREAM_PARSER\nnet/Kconfig:367:\tselect NET_SOCK_MSG\nnet/Kconfig-368-\thelp\n--\nnet/ipv4/Kconfig=382=config INET_ESPINTCP\n--\nnet/ipv4/Kconfig-385-\tselect STREAM_PARSER\nnet/ipv4/Kconfig:386:\tselect NET_SOCK_MSG\nnet/ipv4/Kconfig-387-\tselect XFRM_ESPINTCP\n--\nnet/ipv6/Kconfig=90=config INET6_ESPINTCP\n--\nnet/ipv6/Kconfig-93-\tselect STREAM_PARSER\nnet/ipv6/Kconfig:94:\tselect NET_SOCK_MSG\nnet/ipv6/Kconfig-95-\tselect XFRM_ESPINTCP\n--\nnet/tls/Kconfig=5=config TLS\n--\nnet/tls/Kconfig-10-\tselect CRYPTO_GCM\nnet/tls/Kconfig:11:\tselect NET_SOCK_MSG\nnet/tls/Kconfig-12-\tdefault n\n"
} |
| 9/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 9124 output: 22 thoughts: 63 Thoughts: **My Initial Thoughts on this BPF Selection** Alright, let's break this down. It looks like the system is using `BPF_SYSCALL` along with the `NET` setting to make a selection. Furthermore, the `BPF_STREAM_PARSER` also comes into play here. The patch mentions `strparser` and `skb_bpf_strparser`, which is a clue. I'm going to focus my attention on `BPF_STREAM_PARSER` now to better understand its role in this process. Time to dig in a bit further on that particular code path. |
| 10/2 | 2026/08/17 16:44 | tool | grepper |
0mArgs:{
"Expression": "config BPF_STREAM_PARSER"
}Results: {
"Output": "net/Kconfig=354=config BQL\n--\nnet/Kconfig-360-\nnet/Kconfig:361:config BPF_STREAM_PARSER\nnet/Kconfig-362-\tbool \"enable BPF STREAM_PARSER\"\n"
} |
| 11/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 9415 output: 35 thoughts: 158 Thoughts: **My Initial Assessment of the BPF Patch** Okay, so this patch is suggesting the inclusion of `BPF_STREAM_PARSER` as a user-selectable configuration option. Makes sense; flexibility is key in BPF. I'll make sure that's accounted for. I'll also add in `BPF_SYSCALL` – that's a given for BPF functionality. Now, let's get down to the core of this. I need to identify the critical symbols this patch is modifying. Right, here they are: `sk_psock_skb_ingress_self`, `sk_psock_skb_ingress_self_backlog`, `sk_psock_skb_ingress`, `sk_psock_handle_skb`, `sk_psock_backlog`, and `sk_psock_verdict_apply`. They're all static, which gives me a good starting point. My next step is to trace the call paths to these static functions. Knowing the callers will illuminate exactly how these changes are being integrated and what impact they'll have on the existing architecture. |
| 12/2 | 2026/08/17 16:44 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_backlog",
"PathPrefix": "net/core/skmsg.c"
}Results: {
"Output": "net/core/skmsg.c=732=static void sk_psock_skb_state(struct sk_psock *psock,\n--\nnet/core/skmsg.c-743-\nnet/core/skmsg.c:744:static void sk_psock_backlog(struct work_struct *work)\nnet/core/skmsg.c-745-{\n--\nnet/core/skmsg.c=831=struct sk_psock *sk_psock_init(struct sock *sk, int node)\n--\nnet/core/skmsg.c-865-\nnet/core/skmsg.c:866:\tINIT_DELAYED_WORK(\u0026psock-\u003ework, sk_psock_backlog);\nnet/core/skmsg.c-867-\tmutex_init(\u0026psock-\u003ework_mutex);\n"
} |
| 13/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 10072 output: 37 thoughts: 30 Thoughts: Okay, here's my take on those thoughts, framed as my own: **Pondering Socket Filtering and Workqueues** Right, so `sk_psock_backlog`... that's definitely a workqueue callback, isn't it? Okay, got it. It's handling backlogged packet sockets. Now, what's bugging me is... I'm thinking about related functions in that area. Where does this workqueue fit with other filtering mechanisms? Let me see... I wonder how `sk_psock_verdict_apply` figures into all this. Is it called before, after, or completely independently of the workqueue callback? Does it influence what gets enqueued? Is it the ultimate decision-maker, or just a part of the process? I should really make sure I'm thinking about the order of operations here. |
| 14/2 | 2026/08/17 16:44 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_verdict_apply",
"PathPrefix": "net/core/skmsg.c"
}Results: {
"Output": "net/core/skmsg.c=1039=static int sk_psock_skb_redirect(struct sk_psock *from, struct sk_buff *skb)\n--\nnet/core/skmsg.c-1076-\nnet/core/skmsg.c:1077:static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,\nnet/core/skmsg.c-1078-\t\t\t\t int verdict)\n--\nnet/core/skmsg.c=1160=static void sk_psock_strp_read(struct strparser *strp, struct sk_buff *skb)\n--\nnet/core/skmsg.c-1183-\t}\nnet/core/skmsg.c:1184:\tsk_psock_verdict_apply(psock, skb, ret);\nnet/core/skmsg.c-1185-out:\n--\nnet/core/skmsg.c=1283=static int sk_psock_verdict_recv(struct sock *sk, struct sk_buff *skb)\n--\nnet/core/skmsg.c-1306-\t}\nnet/core/skmsg.c:1307:\tret = sk_psock_verdict_apply(psock, skb, ret);\nnet/core/skmsg.c-1308-\tif (ret \u003c 0)\n"
} |
| 15/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 10691 output: 37 thoughts: 49 Thoughts: Okay, here's my interpretation of those thoughts, presented as my own mental process, given my expertise: **Examining the PSOCK Verdict Application Path** Right, so `sk_psock_strp_read` and `sk_psock_verdict_recv` both seem to hinge on `sk_psock_verdict_apply`. That's interesting, and potentially critical, because that means all traffic that needs to be considered by the process likely passes through that function at some point. It’s the central point where the decisions about packet handling are made in this PSOCK (packet socket) context, or perhaps where they are *applied* at least. I need to understand its role better. My first instinct, as always, is to figure out the calling hierarchy – who *else* is using `sk_psock_verdict_apply`, and if it's exported, then where are those calls originating from? Is it solely within the kernel space, or is there a user space interaction involved? That level of detail matters *a lot* when dealing with networking and security, and it informs whether this would be something that needs attention. Are there any other paths to it, and are there dependencies or related functions to consider? The goal is to fully understand how policy decisions are made for these packet sockets and see what avenues exist to potentially influence or modify that process, if the need arises. Time to dig in! |
| 16/2 | 2026/08/17 16:44 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_strp_read",
"PathPrefix": "net/core/skmsg.c"
}Results: {
"Output": "net/core/skmsg.c=1142=static void sk_psock_write_space(struct sock *sk)\n--\nnet/core/skmsg.c-1159-#if IS_ENABLED(CONFIG_BPF_STREAM_PARSER)\nnet/core/skmsg.c:1160:static void sk_psock_strp_read(struct strparser *strp, struct sk_buff *skb)\nnet/core/skmsg.c-1161-{\n--\nnet/core/skmsg.c-1188-\nnet/core/skmsg.c:1189:static int sk_psock_strp_read_done(struct strparser *strp, int err)\nnet/core/skmsg.c-1190-{\n--\nnet/core/skmsg.c=1228=int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)\n--\nnet/core/skmsg.c-1232-\tstatic const struct strp_callbacks cb = {\nnet/core/skmsg.c:1233:\t\t.rcv_msg\t= sk_psock_strp_read,\nnet/core/skmsg.c:1234:\t\t.read_sock_done\t= sk_psock_strp_read_done,\nnet/core/skmsg.c-1235-\t\t.parse_msg\t= sk_psock_strp_parse,\n"
} |
| 17/2 | 2026/08/17 16:44 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 11451 output: 23 thoughts: 18 Thoughts: Here's my take on those thoughts: **Considering `sk_psock_init_strp`'s Scope** Okay, so I'm looking at `sk_psock_init_strp`. The immediate question that pops into my head is: is this function exposed, meaning is it exported or non-static? Is it meant to be used externally, or is it internal to a specific module or component? I need to figure out its visibility. Knowing this is crucial because it informs how I can interact with the function, if at all, in my own work. A non-static function implies it's part of the public interface, and I can call it from other parts of the system. A static one, however, is likely only meant for use within its defining translation unit. That makes a huge difference in how I proceed. |
| 18/2 | 2026/08/17 16:45 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_init_strp"
}Results: {
"Output": "include/linux/skmsg.h=437=void sk_psock_stop(struct sk_psock *psock);\n--\ninclude/linux/skmsg.h-439-#if IS_ENABLED(CONFIG_BPF_STREAM_PARSER)\ninclude/linux/skmsg.h:440:int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock);\ninclude/linux/skmsg.h-441-void sk_psock_start_strp(struct sock *sk, struct sk_psock *psock);\ninclude/linux/skmsg.h=442=void sk_psock_stop_strp(struct sock *sk, struct sk_psock *psock);\ninclude/linux/skmsg.h-443-#else\ninclude/linux/skmsg.h:444:static inline int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)\ninclude/linux/skmsg.h-445-{\n--\nnet/core/skmsg.c=1212=static void sk_psock_strp_data_ready(struct sock *sk)\n--\nnet/core/skmsg.c-1227-\nnet/core/skmsg.c:1228:int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-1229-{\n--\nnet/core/sock_map.c=217=static int sock_map_link(struct bpf_map *map, struct sock *sk)\n--\nnet/core/sock_map.c-306-\t\tif (sk_is_tcp(sk))\nnet/core/sock_map.c:307:\t\t\tret = sk_psock_init_strp(sk, psock);\nnet/core/sock_map.c-308-\t\telse\n"
} |
| 19/2 | 2026/08/17 16:45 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 12155 output: 37 thoughts: 34 Thoughts: Okay, here's my interpretation of those thoughts, presented as a personal thought process, as requested: **Callback Investigation** Alright, let's see. My mental model here is that `sk_psock_strp_read` is a callback function specifically designed to be used with the strparser. Makes sense. It's probably responsible for handling the reading part of parsing data into a string format, using this strparser. But what about `sk_psock_verdict_recv`? That one's nagging at me a bit. I need to understand its role within the overall system. Is it also related to data reception, but perhaps at a higher level, after the initial string parsing? Is it responsible for making security verdicts based on the received data, or is it related to receiving the raw verdict information? Time to dig a little deeper. I'm going to have to look into the broader context to figure out how these two functions interact and fit together in the architecture. It's likely that `sk_psock_verdict_recv` takes action on the information received by `sk_psock_strp_read`. I need to figure out exactly how, and how it informs the overall process. |
| 20/2 | 2026/08/17 16:45 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_verdict_recv",
"PathPrefix": "net/core/skmsg.c"
}Results: {
"Output": "net/core/skmsg.c=1278=static void sk_psock_done_strp(struct sk_psock *psock)\n--\nnet/core/skmsg.c-1282-\nnet/core/skmsg.c:1283:static int sk_psock_verdict_recv(struct sock *sk, struct sk_buff *skb)\nnet/core/skmsg.c-1284-{\n--\nnet/core/skmsg.c=1315=static void sk_psock_verdict_data_ready(struct sock *sk)\n--\nnet/core/skmsg.c-1331-\nnet/core/skmsg.c:1332:\tcopied = ops-\u003eread_skb(sk, sk_psock_verdict_recv);\nnet/core/skmsg.c-1333-\tif (copied \u003e= 0) {\n"
} |
| 21/2 | 2026/08/17 16:45 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 12717 output: 39 thoughts: 28 Thoughts: Here's a summary of my thought process: **Diving into `sk_psock_verdict_data_ready`** Okay, so `sk_psock_verdict_data_ready`. It's a callback, and a pretty specific one at that. My first thought is: where is this function actually *used*? I need to trace its connections. I want to see which parts of the system are triggering it and what kind of data or actions are being processed when it's called. Gotta understand the context to grasp its true purpose and function. Time to start digging! |
| 22/2 | 2026/08/17 16:45 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_verdict_data_ready",
"PathPrefix": "net/core/skmsg.c"
}Results: {
"Output": "net/core/skmsg.c=1283=static int sk_psock_verdict_recv(struct sock *sk, struct sk_buff *skb)\n--\nnet/core/skmsg.c-1314-\nnet/core/skmsg.c:1315:static void sk_psock_verdict_data_ready(struct sock *sk)\nnet/core/skmsg.c-1316-{\n--\nnet/core/skmsg.c=1342=void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock)\n--\nnet/core/skmsg.c-1347-\tpsock-\u003esaved_data_ready = sk-\u003esk_data_ready;\nnet/core/skmsg.c:1348:\tWRITE_ONCE(sk-\u003esk_data_ready, sk_psock_verdict_data_ready);\nnet/core/skmsg.c-1349-\tWRITE_ONCE(sk-\u003esk_write_space, sk_psock_write_space);\n"
} |
| 23/2 | 2026/08/17 16:45 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 13185 output: 23 thoughts: 23 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Analyzing the `sk_psock_start_verdict` Export** Okay, so `sk_psock_start_verdict` is exported. That's the key. My immediate thought is, "What's touching it? What parts of the kernel are relying on this functionality?" I need to understand its role within the broader picture. My next step is to trace the call graph. I'll need to identify the call sites to fully grok its purpose and implications within the network stack. I'm looking for where this function hooks into, so I can understand the context of its execution. |
| 24/2 | 2026/08/17 16:45 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_start_verdict"
}Results: {
"Output": "include/linux/skmsg.h=453=static inline void sk_psock_stop_strp(struct sock *sk, struct sk_psock *psock)\n--\ninclude/linux/skmsg.h-457-\ninclude/linux/skmsg.h:458:void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock);\ninclude/linux/skmsg.h-459-void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock);\n--\nnet/core/skmsg.c=1315=static void sk_psock_verdict_data_ready(struct sock *sk)\n--\nnet/core/skmsg.c-1341-\nnet/core/skmsg.c:1342:void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-1343-{\n--\nnet/core/sock_map.c=217=static int sock_map_link(struct bpf_map *map, struct sock *sk)\n--\nnet/core/sock_map.c-316-\t} else if (!stream_parser \u0026\u0026 stream_verdict \u0026\u0026 !psock-\u003esaved_data_ready) {\nnet/core/sock_map.c:317:\t\tsk_psock_start_verdict(sk,psock);\nnet/core/sock_map.c-318-\t} else if (!stream_verdict \u0026\u0026 skb_verdict \u0026\u0026 !psock-\u003esaved_data_ready) {\nnet/core/sock_map.c:319:\t\tsk_psock_start_verdict(sk, psock);\nnet/core/sock_map.c-320-\t}\n"
} |
| 25/2 | 2026/08/17 16:45 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 13831 output: 36 thoughts: 522 Thoughts: **Analyzing the BPF Socket Map Linking Patch** Okay, so I'm looking at this patch related to BPF socket map linking. The entry point, as I see it, is `sock_map_link`, which is called from the BPF syscall. The main functions modified in this patch are `sk_psock_skb_ingress_self`, `sk_psock_skb_ingress_self_backlog`, `sk_psock_skb_ingress`, `sk_psock_handle_skb`, `sk_psock_backlog`, and `sk_psock_verdict_apply`. My immediate thought is to zero in on the key functions here. Let's see, we have `sk_psock_backlog` (a workqueue callback), `sk_psock_strp_read` (a string parser callback), `sk_psock_verdict_recv` (a `read_skb` callback), and `sk_psock_verdict_apply` which is static but called by the previous two. Hmm, wait a minute, are those all static? Yes, `sk_psock_verdict_apply`, `sk_psock_strp_read`, `sk_psock_verdict_recv`, and `sk_psock_backlog` all seem to be. Given the patch modifies `sk_psock_backlog` and `sk_psock_verdict_apply`, my next step would be to identify if there are any *non-static* functions that either call or directly rely on those modified functions. `sk_psock_backlog` is called by the workqueue infrastructure, so the triggering mechanism is the workqueue. `sk_psock_verdict_apply` is called by `sk_psock_strp_read` and `sk_psock_verdict_recv`. And those are, respectively, a callback for `strp_callbacks.rcv_msg` and `ops->read_skb`. Okay, the issue is that they are all static, and I need to identify the non-static entry points. So, the staticness is a problem given the instructions. I need to find the non-static functions that are indirectly affected. It looks like `sock_map_link` *is* static. What about `sock_map_update_elem`? |
| 26/2 | 2026/08/17 16:45 | tool | grepper |
0mArgs:{
"Expression": "sock_map_update_elem",
"PathPrefix": "net/core/sock_map.c"
}Results: {
"Output": "net/core/sock_map.c=555=static int sock_hash_update_common(struct bpf_map *map, void *key,\n--\nnet/core/sock_map.c-557-\nnet/core/sock_map.c:558:int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value,\nnet/core/sock_map.c-559-\t\t\t u64 flags)\n--\nnet/core/sock_map.c-598-\nnet/core/sock_map.c:599:static long sock_map_update_elem(struct bpf_map *map, void *key,\nnet/core/sock_map.c-600-\t\t\t\t void *value, u64 flags)\n--\nnet/core/sock_map.c=831=const struct bpf_map_ops sock_map_ops = {\n--\nnet/core/sock_map.c-836-\t.map_lookup_elem_sys_only = sock_map_lookup_sys,\nnet/core/sock_map.c:837:\t.map_update_elem\t= sock_map_update_elem,\nnet/core/sock_map.c-838-\t.map_delete_elem\t= sock_map_delete_elem,\n--\nnet/core/sock_map.c=1447=const struct bpf_map_ops sock_hash_ops = {\n--\nnet/core/sock_map.c-1451-\t.map_get_next_key\t= sock_hash_get_next_key,\nnet/core/sock_map.c:1452:\t.map_update_elem\t= sock_map_update_elem,\nnet/core/sock_map.c-1453-\t.map_delete_elem\t= sock_hash_delete_elem,\n"
} |
| 27/2 | 2026/08/17 16:45 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 15386 output: 40 thoughts: 162 Thoughts: **Analyzing the Data Flow of Packet Sockets** Okay, so I'm digging into how data moves through these packet sockets. My initial thought is to look at functions like `sk_psock_init_strp` and `sk_psock_start_verdict`, because they're not declared as static. But, wait, those are just about *initializing* things and setting up callbacks. The actual verdict, the actual processing of data, that doesn't happen until data is received, right? Data reception. That's the key. That triggers `sk_data_ready`, which then points to either `sk_psock_verdict_data_ready` or `strp_data_ready`. Now, I recall that `sk_psock_verdict_data_ready` is static, which limits its scope. Okay. What about `strp_data_ready`? Let me see… yep, that's in `net/strparser/strparser.c`, as I expected. Alright, so the core data flow is likely initiated by some kind of external event causing data to be placed in `sk_data_ready`. Time to shift focus. Let's shift our gaze to `net/core/skmsg.c` and see if there are any non-static functions within that file that might be involved with handling the data path or related processing. That's the most logical place to look next. |
| 28/2 | 2026/08/17 16:45 | tool | grepper |
0mArgs:{
"Expression": "^[a-z].*sk_psock.*\\(",
"PathPrefix": "net/core/skmsg.c"
}Results: {
"Output": "net/core/skmsg.c=522=static struct sk_msg *alloc_sk_msg(gfp_t gfp)\n--\nnet/core/skmsg.c-532-\nnet/core/skmsg.c:533:static struct sk_msg *sk_psock_create_ingress_msg(struct sock *sk,\nnet/core/skmsg.c-534-\t\t\t\t\t\t struct sk_buff *skb)\n--\nnet/core/skmsg.c-544-\nnet/core/skmsg.c:545:static int sk_psock_skb_ingress_enqueue(struct sk_buff *skb,\nnet/core/skmsg.c-546-\t\t\t\t\tu32 off, u32 len,\n--\nnet/core/skmsg.c-587-\nnet/core/skmsg.c:588:static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,\nnet/core/skmsg.c-589-\t\t\t\t u32 off, u32 len, bool take_ref,\nnet/core/skmsg.c-590-\t\t\t\t bool settle_fwd_alloc);\nnet/core/skmsg.c:591:static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,\nnet/core/skmsg.c-592-\t\t\t\t\t struct sk_buff *skb,\n--\nnet/core/skmsg.c-595-\nnet/core/skmsg.c:596:static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,\nnet/core/skmsg.c-597-\t\t\t\tu32 off, u32 len, bool settle_fwd_alloc)\n--\nnet/core/skmsg.c-623-\nnet/core/skmsg.c:624:static int sk_psock_skb_ingress_self_assign(struct sock *sk,\nnet/core/skmsg.c-625-\t\t\t\t\t struct sk_buff *skb,\n--\nnet/core/skmsg.c-649- */\nnet/core/skmsg.c:650:static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,\nnet/core/skmsg.c-651-\t\t\t\t u32 off, u32 len, bool take_ref,\n--\nnet/core/skmsg.c-680-\nnet/core/skmsg.c:681:static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,\nnet/core/skmsg.c-682-\t\t\t\t\t struct sk_buff *skb,\n--\nnet/core/skmsg.c-714-\nnet/core/skmsg.c:715:static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb,\nnet/core/skmsg.c-716-\t\t\t u32 off, u32 len, bool ingress,\n--\nnet/core/skmsg.c-731-\nnet/core/skmsg.c:732:static void sk_psock_skb_state(struct sk_psock *psock,\nnet/core/skmsg.c-733-\t\t\t struct sk_psock_work_state *state,\n--\nnet/core/skmsg.c-743-\nnet/core/skmsg.c:744:static void sk_psock_backlog(struct work_struct *work)\nnet/core/skmsg.c-745-{\n--\nnet/core/skmsg.c-830-\nnet/core/skmsg.c:831:struct sk_psock *sk_psock_init(struct sock *sk, int node)\nnet/core/skmsg.c-832-{\n--\nnet/core/skmsg.c=884=EXPORT_SYMBOL_GPL(sk_psock_init);\nnet/core/skmsg.c-885-\nnet/core/skmsg.c:886:struct sk_psock_link *sk_psock_link_pop(struct sk_psock *psock)\nnet/core/skmsg.c-887-{\n--\nnet/core/skmsg.c-898-\nnet/core/skmsg.c:899:static void __sk_psock_purge_ingress_msg(struct sk_psock *psock)\nnet/core/skmsg.c-900-{\n--\nnet/core/skmsg.c-913-\nnet/core/skmsg.c:914:static void __sk_psock_zap_ingress(struct sk_psock *psock)\nnet/core/skmsg.c-915-{\n--\nnet/core/skmsg.c-924-\nnet/core/skmsg.c:925:static void sk_psock_link_destroy(struct sk_psock *psock)\nnet/core/skmsg.c-926-{\n--\nnet/core/skmsg.c-934-\nnet/core/skmsg.c:935:void sk_psock_stop(struct sk_psock *psock)\nnet/core/skmsg.c-936-{\n--\nnet/core/skmsg.c-942-\nnet/core/skmsg.c:943:static void sk_psock_done_strp(struct sk_psock *psock);\nnet/core/skmsg.c-944-\nnet/core/skmsg.c:945:static void sk_psock_destroy(struct work_struct *work)\nnet/core/skmsg.c-946-{\n--\nnet/core/skmsg.c-969-\nnet/core/skmsg.c:970:void sk_psock_drop(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-971-{\n--\nnet/core/skmsg.c=986=EXPORT_SYMBOL_GPL(sk_psock_drop);\nnet/core/skmsg.c-987-\nnet/core/skmsg.c:988:static int sk_psock_map_verd(int verdict, bool redir)\nnet/core/skmsg.c-989-{\n--\nnet/core/skmsg.c-1000-\nnet/core/skmsg.c:1001:int sk_psock_msg_verdict(struct sock *sk, struct sk_psock *psock,\nnet/core/skmsg.c-1002-\t\t\t struct sk_msg *msg)\n--\nnet/core/skmsg.c=1037=EXPORT_SYMBOL_GPL(sk_psock_msg_verdict);\nnet/core/skmsg.c-1038-\nnet/core/skmsg.c:1039:static int sk_psock_skb_redirect(struct sk_psock *from, struct sk_buff *skb)\nnet/core/skmsg.c-1040-{\n--\nnet/core/skmsg.c-1076-\nnet/core/skmsg.c:1077:static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,\nnet/core/skmsg.c-1078-\t\t\t\t int verdict)\n--\nnet/core/skmsg.c-1141-\nnet/core/skmsg.c:1142:static void sk_psock_write_space(struct sock *sk)\nnet/core/skmsg.c-1143-{\n--\nnet/core/skmsg.c-1159-#if IS_ENABLED(CONFIG_BPF_STREAM_PARSER)\nnet/core/skmsg.c:1160:static void sk_psock_strp_read(struct strparser *strp, struct sk_buff *skb)\nnet/core/skmsg.c-1161-{\n--\nnet/core/skmsg.c-1188-\nnet/core/skmsg.c:1189:static int sk_psock_strp_read_done(struct strparser *strp, int err)\nnet/core/skmsg.c-1190-{\n--\nnet/core/skmsg.c-1193-\nnet/core/skmsg.c:1194:static int sk_psock_strp_parse(struct strparser *strp, struct sk_buff *skb)\nnet/core/skmsg.c-1195-{\n--\nnet/core/skmsg.c-1211-/* Called with socket lock held. */\nnet/core/skmsg.c:1212:static void sk_psock_strp_data_ready(struct sock *sk)\nnet/core/skmsg.c-1213-{\n--\nnet/core/skmsg.c-1227-\nnet/core/skmsg.c:1228:int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-1229-{\n--\nnet/core/skmsg.c-1248-\nnet/core/skmsg.c:1249:void sk_psock_start_strp(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-1250-{\n--\nnet/core/skmsg.c-1258-\nnet/core/skmsg.c:1259:void sk_psock_stop_strp(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-1260-{\n--\nnet/core/skmsg.c-1270-\nnet/core/skmsg.c:1271:static void sk_psock_done_strp(struct sk_psock *psock)\nnet/core/skmsg.c-1272-{\n--\nnet/core/skmsg.c-1277-#else\nnet/core/skmsg.c:1278:static void sk_psock_done_strp(struct sk_psock *psock)\nnet/core/skmsg.c-1279-{\n--\nnet/core/skmsg.c-1282-\nnet/core/skmsg.c:1283:static int sk_psock_verdict_recv(struct sock *sk, struct sk_buff *skb)\nnet/core/skmsg.c-1284-{\n--\nnet/core/skmsg.c-1314-\nnet/core/skmsg.c:1315:static void sk_psock_verdict_data_ready(struct sock *sk)\nnet/core/skmsg.c-1316-{\n--\nnet/core/skmsg.c-1341-\nnet/core/skmsg.c:1342:void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-1343-{\n--\nnet/core/skmsg.c-1351-\nnet/core/skmsg.c:1352:void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock)\nnet/core/skmsg.c-1353-{\n"
} |
| 29/2 | 2026/08/17 16:45 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 18800 output: 23 thoughts: 274 Thoughts: **My Analysis of the PSock Functions** Okay, let's break down these PSock functions. I see a clear pattern here. Primarily, the non-static functions – `sk_psock_init`, `sk_psock_link_pop`, `sk_psock_stop`, `sk_psock_drop`, `sk_psock_init_strp`, `sk_psock_start_strp`, `sk_psock_stop_strp`, `sk_psock_start_verdict`, `sk_psock_stop_verdict` – are mostly focused on initialization and teardown. Standard stuff; setting up resources, tearing them down. Nothing particularly groundbreaking there. The interesting part is the data path. The networking stack isn't directly calling these non-static functions. It looks like the socket layer is triggering the data flow via `sk_data_ready` or `sk_write_space`, and we're hooking into that. So, instead of the usual `tcp_data_ready`, we have something like `sk_psock_strp_data_ready` or `sk_psock_verdict_data_ready` which are static. They are used internally for data handling. This is how the PSock interacts with the networking stack. Wait a second… `sk_psock_msg_verdict` is exported. That's not what I expected. Let's delve into what that function is doing; there may be a clue here. This bears further investigation. |
| 30/2 | 2026/08/17 16:46 | tool | grepper |
0mArgs:{
"Expression": "sk_psock_msg_verdict"
}Results: {
"Output": "include/linux/skmsg.h=459=void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock);\ninclude/linux/skmsg.h-460-\ninclude/linux/skmsg.h:461:int sk_psock_msg_verdict(struct sock *sk, struct sk_psock *psock,\ninclude/linux/skmsg.h-462-\t\t\t struct sk_msg *msg);\n--\nnet/core/skmsg.c=988=static int sk_psock_map_verd(int verdict, bool redir)\n--\nnet/core/skmsg.c-1000-\nnet/core/skmsg.c:1001:int sk_psock_msg_verdict(struct sock *sk, struct sk_psock *psock,\nnet/core/skmsg.c-1002-\t\t\t struct sk_msg *msg)\n--\nnet/core/skmsg.c-1036-}\nnet/core/skmsg.c:1037:EXPORT_SYMBOL_GPL(sk_psock_msg_verdict);\nnet/core/skmsg.c-1038-\n--\nnet/ipv4/tcp_bpf.c=418=static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,\n--\nnet/ipv4/tcp_bpf.c-434-\t\tdelta = msg-\u003esg.size;\nnet/ipv4/tcp_bpf.c:435:\t\tpsock-\u003eeval = sk_psock_msg_verdict(sk, psock, msg);\nnet/ipv4/tcp_bpf.c-436-\t\tdelta -= msg-\u003esg.size;\n"
} |
| 31/2 | 2026/08/17 16:46 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 19868 output: 21 thoughts: 199 Thoughts: **Analyzing the TCP BPF Ingress Patch** Okay, so I'm looking at this patch and immediately something feels off. `tcp_bpf_send_verdict` is called from `tcp_bpf_sendmsg`, but the patch description seems to be focused on ingress functionality, not the sending path. That's my first red flag, as this connection is not the primary focus. Let's see, it's modifying a bunch of functions: `sk_psock_skb_ingress_self`, `sk_psock_skb_ingress_self_backlog`, `sk_psock_skb_ingress`, `sk_psock_handle_skb`, `sk_psock_backlog`, and `sk_psock_verdict_apply`. Right, these are all definitely ingress-related. That lines up. The ingress entry points I'm familiar with, at least in this context, are `sk_psock_strp_data_ready` and `sk_psock_verdict_data_ready`. Wait, a second. `sk_psock_backlog`... that's the workqueue callback, isn't it? Okay, I'm getting a better picture here, but still need to identify the exact connection. Hmm, I wonder if there's a good, non-static function I can use as a central point, a focus symbol, to better understand where this all fits in? Perhaps `tcp_bpf_recvmsg`? That seems like a logical place to start digging deeper. |
| 32/2 | 2026/08/17 16:46 | tool | grepper |
0mArgs:{
"Expression": "tcp_bpf_recvmsg"
}Results: {
"Output": "net/core/skmsg.c=596=static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,\n--\nnet/core/skmsg.c-613-\t * we will eventually receive this data on. The data will be released\nnet/core/skmsg.c:614:\t * from skb_consume found in __tcp_bpf_recvmsg() after its been copied\nnet/core/skmsg.c-615-\t * into user buffers.\n--\nnet/core/skmsg.c=650=static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,\n--\nnet/core/skmsg.c-664-\nnet/core/skmsg.c:665:\t/* This is used in tcp_bpf_recvmsg_parser() to determine whether the\nnet/core/skmsg.c-666-\t * data originates from the socket's own protocol stack. No need to\n--\nnet/core/skmsg.c=681=static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,\n--\nnet/core/skmsg.c-698-\nnet/core/skmsg.c:699:\t/* This is used in tcp_bpf_recvmsg_parser() to determine whether the\nnet/core/skmsg.c-700-\t * data originates from the socket's own protocol stack. No need to\n--\nnet/ipv4/tcp_bpf.c=203=static bool is_next_msg_fin(struct sk_psock *psock)\n--\nnet/ipv4/tcp_bpf.c-220-\nnet/ipv4/tcp_bpf.c:221:static int tcp_bpf_recvmsg_parser(struct sock *sk,\nnet/ipv4/tcp_bpf.c-222-\t\t\t\t struct msghdr *msg,\n--\nnet/ipv4/tcp_bpf.c=335=static int tcp_bpf_ioctl(struct sock *sk, int cmd, int *karg)\n--\nnet/ipv4/tcp_bpf.c-367-\nnet/ipv4/tcp_bpf.c:368:static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,\nnet/ipv4/tcp_bpf.c-369-\t\t\t int flags)\n--\nnet/ipv4/tcp_bpf.c=640=static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS],\n--\nnet/ipv4/tcp_bpf.c-645-\tprot[TCP_BPF_BASE].close\t\t= sock_map_close;\nnet/ipv4/tcp_bpf.c:646:\tprot[TCP_BPF_BASE].recvmsg\t\t= tcp_bpf_recvmsg;\nnet/ipv4/tcp_bpf.c-647-\tprot[TCP_BPF_BASE].sock_is_readable\t= sk_msg_is_readable;\n--\nnet/ipv4/tcp_bpf.c-653-\tprot[TCP_BPF_RX]\t\t\t= prot[TCP_BPF_BASE];\nnet/ipv4/tcp_bpf.c:654:\tprot[TCP_BPF_RX].recvmsg\t\t= tcp_bpf_recvmsg_parser;\nnet/ipv4/tcp_bpf.c-655-\nnet/ipv4/tcp_bpf.c-656-\tprot[TCP_BPF_TXRX]\t\t\t= prot[TCP_BPF_TX];\nnet/ipv4/tcp_bpf.c:657:\tprot[TCP_BPF_TXRX].recvmsg\t\t= tcp_bpf_recvmsg_parser;\nnet/ipv4/tcp_bpf.c-658-}\n--\nnet/ipv4/tcp_bpf.c=690=int tcp_bpf_strp_read_sock(struct strparser *strp, read_descriptor_t *desc,\n--\nnet/ipv4/tcp_bpf.c-713-\t * For SK_REDIRECT, we need to ack the frame immediately but for\nnet/ipv4/tcp_bpf.c:714:\t * SK_PASS, we want to delay the ack until tcp_bpf_recvmsg_parser().\nnet/ipv4/tcp_bpf.c-715-\t */\n--\ntools/testing/selftests/bpf/prog_tests/sockmap_basic.c=1113=static void test_sockmap_zc(void)\n--\ntools/testing/selftests/bpf/prog_tests/sockmap_basic.c-1148-\ntools/testing/selftests/bpf/prog_tests/sockmap_basic.c:1149:\t/* trigger tcp_bpf_recvmsg_parser and inc copied_seq of p1 */\ntools/testing/selftests/bpf/prog_tests/sockmap_basic.c-1150-\trecvd = recv_timeout(p1, rcv, sizeof(rcv), MSG_DONTWAIT, 1);\n--\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c=18=static const int test_packet_num = 100;\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c-19-\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c:20:/* Current implementation of tcp_bpf_recvmsg_parser() invokes data_ready\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c-21- * with sk held if an skb exists in sk_receive_queue. Then for the\n--\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c=293=static void test_sockmap_strp_pass(int family, int sotype, bool fionread)\n--\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c-311-\t * correctly because we check sk_receive_queue in\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c:312:\t * tcp_bpf_recvmsg_parser().\ntools/testing/selftests/bpf/prog_tests/sockmap_strp.c-313-\t */\n"
} |
| 33/2 | 2026/08/17 16:46 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22063 output: 40 thoughts: 244 Thoughts: **Analyzing Function Visibility in the TCP BPF and Sock Map Subsystems** Okay, let's break this down. First, I was looking at `tcp_bpf_recvmsg_parser` and initially thought it was non-static, but then I realized it *is* static within `net/ipv4/tcp_bpf.c`. Good catch, me! So, I confirmed `static int tcp_bpf_recvmsg_parser`. Fine. And `tcp_bpf_recvmsg`... yep, also `static int tcp_bpf_recvmsg`. That makes sense in the context of keeping those parsing functions internal to the TCP BPF implementation. Now, shifting gears, I moved on to functions related to packet sockets (`psock`). `sk_psock_init_strp` is non-static, which is what I would expect for an initialization function. Similarly, `sk_psock_start_verdict`, `sk_psock_msg_verdict`, `sk_psock_drop`, `sk_psock_stop`, `sk_psock_init`, and `sk_psock_link_pop` are all non-static. This likely means they're part of the public API or at least used more broadly within the networking stack. So, they all have a broader scope. Next step? I'll probably scan through `net/core/sock_map.c` to see which functions there are non-static and how they are used. |
| 34/2 | 2026/08/17 16:46 | tool | grepper |
0mArgs:{
"Expression": "^[a-z].*sock_map.*\\(",
"PathPrefix": "net/core/sock_map.c"
}Results: {
"Output": "net/core/sock_map.c=32=static DEFINE_MUTEX(sockmap_mutex);\nnet/core/sock_map.c-33-\nnet/core/sock_map.c:34:static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,\nnet/core/sock_map.c-35-\t\t\t\tstruct bpf_prog *old, struct bpf_link *link,\nnet/core/sock_map.c-36-\t\t\t\tu32 which);\nnet/core/sock_map.c:37:static struct sk_psock_progs *sock_map_progs(struct bpf_map *map);\nnet/core/sock_map.c-38-\nnet/core/sock_map.c:39:static struct bpf_map *sock_map_alloc(union bpf_attr *attr)\nnet/core/sock_map.c-40-{\n--\nnet/core/sock_map.c-67-\nnet/core/sock_map.c:68:int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog)\nnet/core/sock_map.c-69-{\n--\nnet/core/sock_map.c-85-\nnet/core/sock_map.c:86:int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype)\nnet/core/sock_map.c-87-{\n--\nnet/core/sock_map.c-116-\nnet/core/sock_map.c:117:static void sock_map_sk_acquire(struct sock *sk)\nnet/core/sock_map.c-118-\t__acquires(\u0026sk-\u003esk_lock.slock)\n--\nnet/core/sock_map.c-123-\nnet/core/sock_map.c:124:static void sock_map_sk_release(struct sock *sk)\nnet/core/sock_map.c-125-\t__releases(\u0026sk-\u003esk_lock.slock)\n--\nnet/core/sock_map.c-130-\nnet/core/sock_map.c:131:static void sock_map_add_link(struct sk_psock *psock,\nnet/core/sock_map.c-132-\t\t\t struct sk_psock_link *link,\n--\nnet/core/sock_map.c-141-\nnet/core/sock_map.c:142:static void sock_map_del_link(struct sock *sk,\nnet/core/sock_map.c-143-\t\t\t struct sk_psock *psock, void *link_raw)\n--\nnet/core/sock_map.c-178-\nnet/core/sock_map.c:179:static void sock_map_unref(struct sock *sk, void *link_raw)\nnet/core/sock_map.c-180-{\n--\nnet/core/sock_map.c-188-\nnet/core/sock_map.c:189:static int sock_map_init_proto(struct sock *sk, struct sk_psock *psock)\nnet/core/sock_map.c-190-{\n--\nnet/core/sock_map.c-196-\nnet/core/sock_map.c:197:static struct sk_psock *sock_map_psock_get_checked(struct sock *sk)\nnet/core/sock_map.c-198-{\n--\nnet/core/sock_map.c-216-\nnet/core/sock_map.c:217:static int sock_map_link(struct bpf_map *map, struct sock *sk)\nnet/core/sock_map.c-218-{\n--\nnet/core/sock_map.c-338-\nnet/core/sock_map.c:339:static void sock_map_free(struct bpf_map *map)\nnet/core/sock_map.c-340-{\n--\nnet/core/sock_map.c-371-\nnet/core/sock_map.c:372:static void sock_map_release_progs(struct bpf_map *map)\nnet/core/sock_map.c-373-{\n--\nnet/core/sock_map.c-376-\nnet/core/sock_map.c:377:static struct sock *__sock_map_lookup_elem(struct bpf_map *map, u32 key)\nnet/core/sock_map.c-378-{\n--\nnet/core/sock_map.c-387-\nnet/core/sock_map.c:388:static void *sock_map_lookup(struct bpf_map *map, void *key)\nnet/core/sock_map.c-389-{\n--\nnet/core/sock_map.c-399-\nnet/core/sock_map.c:400:static void *sock_map_lookup_sys(struct bpf_map *map, void *key)\nnet/core/sock_map.c-401-{\n--\nnet/core/sock_map.c-414-\nnet/core/sock_map.c:415:static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test,\nnet/core/sock_map.c-416-\t\t\t struct sock **psk)\n--\nnet/core/sock_map.c-433-\nnet/core/sock_map.c:434:static void sock_map_delete_from_link(struct bpf_map *map, struct sock *sk,\nnet/core/sock_map.c-435-\t\t\t\t void *link_raw)\n--\nnet/core/sock_map.c-441-\nnet/core/sock_map.c:442:static long sock_map_delete_elem(struct bpf_map *map, void *key)\nnet/core/sock_map.c-443-{\n--\nnet/core/sock_map.c-454-\nnet/core/sock_map.c:455:static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next)\nnet/core/sock_map.c-456-{\n--\nnet/core/sock_map.c-469-\nnet/core/sock_map.c:470:static int sock_map_update_common(struct bpf_map *map, u32 idx,\nnet/core/sock_map.c-471-\t\t\t\t struct sock *sk, u64 flags)\n--\nnet/core/sock_map.c-520-\nnet/core/sock_map.c:521:static bool sock_map_op_okay(const struct bpf_sock_ops_kern *ops)\nnet/core/sock_map.c-522-{\n--\nnet/core/sock_map.c-527-\nnet/core/sock_map.c:528:static bool sock_map_redirect_allowed(const struct sock *sk)\nnet/core/sock_map.c-529-{\n--\nnet/core/sock_map.c-535-\nnet/core/sock_map.c:536:static bool sock_map_sk_is_suitable(const struct sock *sk)\nnet/core/sock_map.c-537-{\n--\nnet/core/sock_map.c-540-\nnet/core/sock_map.c:541:static bool sock_map_sk_state_allowed(const struct sock *sk)\nnet/core/sock_map.c-542-{\n--\nnet/core/sock_map.c=555=static int sock_hash_update_common(struct bpf_map *map, void *key,\n--\nnet/core/sock_map.c-557-\nnet/core/sock_map.c:558:int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value,\nnet/core/sock_map.c-559-\t\t\t u64 flags)\n--\nnet/core/sock_map.c-598-\nnet/core/sock_map.c:599:static long sock_map_update_elem(struct bpf_map *map, void *key,\nnet/core/sock_map.c-600-\t\t\t\t void *value, u64 flags)\n--\nnet/core/sock_map.c=719=DEFINE_BPF_ITER_FUNC(sockmap, struct bpf_iter_meta *meta,\n--\nnet/core/sock_map.c-722-\nnet/core/sock_map.c:723:static void *sock_map_seq_lookup_elem(struct sock_map_seq_info *info)\nnet/core/sock_map.c-724-{\n--\nnet/core/sock_map.c-733-\nnet/core/sock_map.c:734:static void *sock_map_seq_start(struct seq_file *seq, loff_t *pos)\nnet/core/sock_map.c-735-\t__acquires(rcu)\n--\nnet/core/sock_map.c-746-\nnet/core/sock_map.c:747:static void *sock_map_seq_next(struct seq_file *seq, void *v, loff_t *pos)\nnet/core/sock_map.c-748-\t__must_hold(rcu)\n--\nnet/core/sock_map.c-757-\nnet/core/sock_map.c:758:static int sock_map_seq_show(struct seq_file *seq, void *v)\nnet/core/sock_map.c-759-\t__must_hold(rcu)\n--\nnet/core/sock_map.c-780-\nnet/core/sock_map.c:781:static void sock_map_seq_stop(struct seq_file *seq, void *v)\nnet/core/sock_map.c-782-\t__releases(rcu)\n--\nnet/core/sock_map.c=791=static const struct seq_operations sock_map_seq_ops = {\n--\nnet/core/sock_map.c-797-\nnet/core/sock_map.c:798:static int sock_map_init_seq_private(void *priv_data,\nnet/core/sock_map.c-799-\t\t\t\t struct bpf_iter_aux_info *aux)\n--\nnet/core/sock_map.c-807-\nnet/core/sock_map.c:808:static void sock_map_fini_seq_private(void *priv_data)\nnet/core/sock_map.c-809-{\n--\nnet/core/sock_map.c-814-\nnet/core/sock_map.c:815:static u64 sock_map_mem_usage(const struct bpf_map *map)\nnet/core/sock_map.c-816-{\n--\nnet/core/sock_map.c=1447=const struct bpf_map_ops sock_hash_ops = {\n--\nnet/core/sock_map.c-1462-\nnet/core/sock_map.c:1463:static struct sk_psock_progs *sock_map_progs(struct bpf_map *map)\nnet/core/sock_map.c-1464-{\n--\nnet/core/sock_map.c-1476-\nnet/core/sock_map.c:1477:static int sock_map_prog_link_lookup(struct bpf_map *map, struct bpf_prog ***pprog,\nnet/core/sock_map.c-1478-\t\t\t\t struct bpf_link ***plink, u32 which)\n--\nnet/core/sock_map.c-1519-\nnet/core/sock_map.c:1520:static int sock_map_prog_attach_check(enum bpf_attach_type attach_type,\nnet/core/sock_map.c-1521-\t\t\t\t struct bpf_prog *prog)\n--\nnet/core/sock_map.c-1536- */\nnet/core/sock_map.c:1537:static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,\nnet/core/sock_map.c-1538-\t\t\t\tstruct bpf_prog *old, struct bpf_link *link,\n--\nnet/core/sock_map.c-1571-\nnet/core/sock_map.c:1572:int sock_map_bpf_prog_query(const union bpf_attr *attr,\nnet/core/sock_map.c-1573-\t\t\t union bpf_attr __user *uattr)\n--\nnet/core/sock_map.c-1620-\nnet/core/sock_map.c:1621:static void sock_map_unlink(struct sock *sk, struct sk_psock_link *link)\nnet/core/sock_map.c-1622-{\n--\nnet/core/sock_map.c-1634-\nnet/core/sock_map.c:1635:static void sock_map_remove_links(struct sock *sk, struct sk_psock *psock)\nnet/core/sock_map.c-1636-{\n--\nnet/core/sock_map.c-1644-\nnet/core/sock_map.c:1645:void sock_map_unhash(struct sock *sk)\nnet/core/sock_map.c-1646-{\n--\nnet/core/sock_map.c=1670=EXPORT_SYMBOL_GPL(sock_map_unhash);\nnet/core/sock_map.c-1671-\nnet/core/sock_map.c:1672:void sock_map_destroy(struct sock *sk)\nnet/core/sock_map.c-1673-{\n--\nnet/core/sock_map.c=1699=EXPORT_SYMBOL_GPL(sock_map_destroy);\nnet/core/sock_map.c-1700-\nnet/core/sock_map.c:1701:void sock_map_close(struct sock *sk, long timeout)\nnet/core/sock_map.c-1702-{\n--\nnet/core/sock_map.c=1737=struct sockmap_link {\n--\nnet/core/sock_map.c-1741-\nnet/core/sock_map.c:1742:static void sock_map_link_release(struct bpf_link *link)\nnet/core/sock_map.c-1743-{\n--\nnet/core/sock_map.c-1758-\nnet/core/sock_map.c:1759:static int sock_map_link_detach(struct bpf_link *link)\nnet/core/sock_map.c-1760-{\n--\nnet/core/sock_map.c-1764-\nnet/core/sock_map.c:1765:static void sock_map_link_dealloc(struct bpf_link *link)\nnet/core/sock_map.c-1766-{\n--\nnet/core/sock_map.c-1773- */\nnet/core/sock_map.c:1774:static int sock_map_link_update_prog(struct bpf_link *link,\nnet/core/sock_map.c-1775-\t\t\t\t struct bpf_prog *prog,\n--\nnet/core/sock_map.c-1833-\nnet/core/sock_map.c:1834:static u32 sock_map_link_get_map_id(const struct sockmap_link *sockmap_link)\nnet/core/sock_map.c-1835-{\n--\nnet/core/sock_map.c-1844-\nnet/core/sock_map.c:1845:static int sock_map_link_fill_info(const struct bpf_link *link,\nnet/core/sock_map.c-1846-\t\t\t\t struct bpf_link_info *info)\n--\nnet/core/sock_map.c-1855-\nnet/core/sock_map.c:1856:static void sock_map_link_show_fdinfo(const struct bpf_link *link,\nnet/core/sock_map.c-1857-\t\t\t\t struct seq_file *seq)\n--\nnet/core/sock_map.c=1866=static const struct bpf_link_ops sock_map_link_ops = {\n--\nnet/core/sock_map.c-1874-\nnet/core/sock_map.c:1875:int sock_map_link_create(const union bpf_attr *attr, struct bpf_prog *prog)\nnet/core/sock_map.c-1876-{\n--\nnet/core/sock_map.c-1934-\nnet/core/sock_map.c:1935:static int sock_map_iter_attach_target(struct bpf_prog *prog,\nnet/core/sock_map.c-1936-\t\t\t\t union bpf_iter_link_info *linfo,\n--\nnet/core/sock_map.c-1965-\nnet/core/sock_map.c:1966:static void sock_map_iter_detach_target(struct bpf_iter_aux_info *aux)\nnet/core/sock_map.c-1967-{\n"
} |
| 35/2 | 2026/08/17 16:46 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 27182 output: 38 thoughts: 269 Thoughts: **My Analysis of the Sockmap Bug** Okay, so I'm looking at this sockmap issue and need to pinpoint the relevant functions. Let's see... it looks like `sock_map_update_elem_sys`, `sock_map_get_from_fd`, `sock_map_prog_detach`, `sock_map_bpf_prog_query`, `sock_map_unhash`, `sock_map_destroy`, `sock_map_close`, and `sock_map_link_create` are all non-static, which is a good starting point. They're definitely in play here. The core of the problem seems to be an `sk_forward_alloc` issue when the traffic is being delivered *back* to the same socket (`sk_psock_skb_ingress_self`). That screams sockmap and BPF interaction. It's happening because a socket gets added to the sockmap, and then a BPF program reroutes traffic *back* to that very socket. So, where do the pieces fit together? Clearly, `sock_map_update_elem_sys` is a likely candidate, since it's the function responsible for adding the socket to the map in the first place. That's a key function for my investigation, definitely. And since we're dealing with receiving data, `tcp_bpf_recvmsg` is crucial. It's the function where the data is actually read. Finally, the BPF program itself gets attached by `bpf_prog_attach` or `sock_map_link_create`. So those are important as well. I'm going to start with a deeper dive into `tcp_bpf_recvmsg` and see what I can find there. That seems like a good place to start digging into the details of the data handling and the interaction with the sockmap within the receiving process. |
| 36/2 | 2026/08/17 16:46 | tool | grepper |
0mArgs:{
"Expression": "tcp_bpf_recvmsg",
"PathPrefix": "net/ipv4/tcp_bpf.c"
}Results: {
"Output": "net/ipv4/tcp_bpf.c=203=static bool is_next_msg_fin(struct sk_psock *psock)\n--\nnet/ipv4/tcp_bpf.c-220-\nnet/ipv4/tcp_bpf.c:221:static int tcp_bpf_recvmsg_parser(struct sock *sk,\nnet/ipv4/tcp_bpf.c-222-\t\t\t\t struct msghdr *msg,\n--\nnet/ipv4/tcp_bpf.c=335=static int tcp_bpf_ioctl(struct sock *sk, int cmd, int *karg)\n--\nnet/ipv4/tcp_bpf.c-367-\nnet/ipv4/tcp_bpf.c:368:static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,\nnet/ipv4/tcp_bpf.c-369-\t\t\t int flags)\n--\nnet/ipv4/tcp_bpf.c=640=static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS],\n--\nnet/ipv4/tcp_bpf.c-645-\tprot[TCP_BPF_BASE].close\t\t= sock_map_close;\nnet/ipv4/tcp_bpf.c:646:\tprot[TCP_BPF_BASE].recvmsg\t\t= tcp_bpf_recvmsg;\nnet/ipv4/tcp_bpf.c-647-\tprot[TCP_BPF_BASE].sock_is_readable\t= sk_msg_is_readable;\n--\nnet/ipv4/tcp_bpf.c-653-\tprot[TCP_BPF_RX]\t\t\t= prot[TCP_BPF_BASE];\nnet/ipv4/tcp_bpf.c:654:\tprot[TCP_BPF_RX].recvmsg\t\t= tcp_bpf_recvmsg_parser;\nnet/ipv4/tcp_bpf.c-655-\nnet/ipv4/tcp_bpf.c-656-\tprot[TCP_BPF_TXRX]\t\t\t= prot[TCP_BPF_TX];\nnet/ipv4/tcp_bpf.c:657:\tprot[TCP_BPF_TXRX].recvmsg\t\t= tcp_bpf_recvmsg_parser;\nnet/ipv4/tcp_bpf.c-658-}\n--\nnet/ipv4/tcp_bpf.c=690=int tcp_bpf_strp_read_sock(struct strparser *strp, read_descriptor_t *desc,\n--\nnet/ipv4/tcp_bpf.c-713-\t * For SK_REDIRECT, we need to ack the frame immediately but for\nnet/ipv4/tcp_bpf.c:714:\t * SK_PASS, we want to delay the ack until tcp_bpf_recvmsg_parser().\nnet/ipv4/tcp_bpf.c-715-\t */\n"
} |
| 37/2 | 2026/08/17 16:46 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 28647 output: 43 thoughts: 62 Thoughts: **My Initial Assessment of TCP BPF Receiver Functions** Okay, so I'm looking into the `net/ipv4/tcp_bpf.c` module again. Let me just make sure I'm following the code correctly. Right, `tcp_bpf_recvmsg` and `tcp_bpf_recvmsg_parser` are definitely declared as static. Interesting, so they won't be exposed outside of the compilation unit. But wait, focusing in on `tcp_bpf_recvmsg` specifically, it's also static. That means, it can not be called from outside the source file, which limits my ability to trace this function as it is not part of the external API. Now I'm wondering, are there *any* non-static functions defined in this file? I need to know the scope of what is visible externally. This needs further investigation. I'm going to have to dive deeper. |
| 38/2 | 2026/08/17 16:46 | tool | grepper |
0mArgs:{
"Expression": "^[a-z].*tcp_bpf.*\\(",
"PathPrefix": "net/ipv4/tcp_bpf.c"
}Results: {
"Output": "net/ipv4/tcp_bpf.c=33=static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,\n--\nnet/ipv4/tcp_bpf.c-90-\nnet/ipv4/tcp_bpf.c:91:static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes,\nnet/ipv4/tcp_bpf.c-92-\t\t\tint flags, bool uncharge)\n--\nnet/ipv4/tcp_bpf.c-152-\nnet/ipv4/tcp_bpf.c:153:static int tcp_bpf_push_locked(struct sock *sk, struct sk_msg *msg,\nnet/ipv4/tcp_bpf.c-154-\t\t\t u32 apply_bytes, int flags, bool uncharge)\n--\nnet/ipv4/tcp_bpf.c-163-\nnet/ipv4/tcp_bpf.c:164:int tcp_bpf_sendmsg_redir(struct sock *sk, bool ingress,\nnet/ipv4/tcp_bpf.c-165-\t\t\t struct sk_msg *msg, u32 bytes, int flags)\n--\nnet/ipv4/tcp_bpf.c=203=static bool is_next_msg_fin(struct sk_psock *psock)\n--\nnet/ipv4/tcp_bpf.c-220-\nnet/ipv4/tcp_bpf.c:221:static int tcp_bpf_recvmsg_parser(struct sock *sk,\nnet/ipv4/tcp_bpf.c-222-\t\t\t\t struct msghdr *msg,\n--\nnet/ipv4/tcp_bpf.c-334-\nnet/ipv4/tcp_bpf.c:335:static int tcp_bpf_ioctl(struct sock *sk, int cmd, int *karg)\nnet/ipv4/tcp_bpf.c-336-{\n--\nnet/ipv4/tcp_bpf.c-367-\nnet/ipv4/tcp_bpf.c:368:static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,\nnet/ipv4/tcp_bpf.c-369-\t\t\t int flags)\n--\nnet/ipv4/tcp_bpf.c-417-\nnet/ipv4/tcp_bpf.c:418:static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,\nnet/ipv4/tcp_bpf.c-419-\t\t\t\tstruct sk_msg *msg, int *copied, int flags)\n--\nnet/ipv4/tcp_bpf.c-533-\nnet/ipv4/tcp_bpf.c:534:static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)\nnet/ipv4/tcp_bpf.c-535-{\n--\nnet/ipv4/tcp_bpf.c=638=static struct proto tcp_bpf_prots[TCP_BPF_NUM_PROTS][TCP_BPF_NUM_CFGS];\nnet/ipv4/tcp_bpf.c-639-\nnet/ipv4/tcp_bpf.c:640:static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS],\nnet/ipv4/tcp_bpf.c-641-\t\t\t\t struct proto *base)\n--\nnet/ipv4/tcp_bpf.c-659-\nnet/ipv4/tcp_bpf.c:660:static void tcp_bpf_check_v6_needs_rebuild(struct proto *ops)\nnet/ipv4/tcp_bpf.c-661-{\n--\nnet/ipv4/tcp_bpf.c-671-\nnet/ipv4/tcp_bpf.c:672:static int __init tcp_bpf_v4_build_proto(void)\nnet/ipv4/tcp_bpf.c-673-{\n--\nnet/ipv4/tcp_bpf.c=677=late_initcall(tcp_bpf_v4_build_proto);\nnet/ipv4/tcp_bpf.c-678-\nnet/ipv4/tcp_bpf.c:679:static int tcp_bpf_assert_proto_ops(struct proto *ops)\nnet/ipv4/tcp_bpf.c-680-{\n--\nnet/ipv4/tcp_bpf.c-689-#if IS_ENABLED(CONFIG_BPF_STREAM_PARSER)\nnet/ipv4/tcp_bpf.c:690:int tcp_bpf_strp_read_sock(struct strparser *strp, read_descriptor_t *desc,\nnet/ipv4/tcp_bpf.c-691-\t\t\t sk_read_actor_t recv_actor)\n--\nnet/ipv4/tcp_bpf.c-724-\nnet/ipv4/tcp_bpf.c:725:int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)\nnet/ipv4/tcp_bpf.c-726-{\n--\nnet/ipv4/tcp_bpf.c=762=EXPORT_SYMBOL_GPL(tcp_bpf_update_proto);\n--\nnet/ipv4/tcp_bpf.c-768- */\nnet/ipv4/tcp_bpf.c:769:void tcp_bpf_clone(const struct sock *sk, struct sock *newsk)\nnet/ipv4/tcp_bpf.c-770-{\n"
} |
| 39/2 | 2026/08/17 16:46 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 30401 output: 25 thoughts: 431 Thoughts: **Analyzing the BPF Stream Parser Patch** Okay, so I'm looking at this patch and immediately noticing a few things. `tcp_bpf_update_proto`, `tcp_bpf_sendmsg_redir`, `tcp_bpf_strp_read_sock`, and `tcp_bpf_clone` are all *non-static* and exported. That's good to keep in mind, as it indicates they are intended for broader use within the kernel (or potentially user space). The core of the change seems to be around `sk_psock_skb_ingress_self`. This function gets called when a packet is redirected *back* to the same socket, which is handled in either `sk_psock_verdict_apply` or possibly `sk_psock_backlog`. The test case is interesting. It's using `xbpf_prog_attach` to hook up a stream parser (`prog_skb_parser_one`) and a verdict program (`prog_skb_verdict_pass`) to a map using `BPF_SK_SKB_STREAM_PARSER` and `BPF_SK_SKB_STREAM_VERDICT` respectively. It then sends some data. My guess is that the data triggers the stream parser and the verdict logic, and the verdict is set to `SK_PASS`. Because it passes, the packet ends up being delivered back to the *same* socket, all happening within `sk_psock_verdict_apply` or, if the packet is queued, `sk_psock_backlog`. The key here is that the function `sk_psock_skb_ingress_self` is being called as a result of that *same-socket* delivery. It makes sense, given the context. The data that *triggers* all of this is being handled by `tcp_bpf_strp_read_sock`. Wait a second. `tcp_bpf_strp_read_sock` is clearly for string parser functionality. It's very likely going to call `strp_data_ready` or something equivalent. I need to make sure my understanding of `tcp_bpf_strp_read_sock` is correct. Let me check its definition. |
| 40/2 | 2026/08/17 16:46 | tool | grepper |
0mArgs:{
"Expression": "tcp_bpf_strp_read_sock"
}Results: {
"Output": "include/net/tcp.h=2844=struct strparser;\ninclude/net/tcp.h:2845:int tcp_bpf_strp_read_sock(struct strparser *strp, read_descriptor_t *desc,\ninclude/net/tcp.h-2846-\t\t\t sk_read_actor_t recv_actor);\n--\nnet/core/skmsg.c=1228=int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)\n--\nnet/core/skmsg.c-1242-\tif (sk_is_tcp(sk)) {\nnet/core/skmsg.c:1243:\t\tpsock-\u003estrp.cb.read_sock = tcp_bpf_strp_read_sock;\nnet/core/skmsg.c-1244-\t\tpsock-\u003ecopied_seq = tcp_sk(sk)-\u003ecopied_seq;\n--\nnet/ipv4/tcp_bpf.c=679=static int tcp_bpf_assert_proto_ops(struct proto *ops)\n--\nnet/ipv4/tcp_bpf.c-689-#if IS_ENABLED(CONFIG_BPF_STREAM_PARSER)\nnet/ipv4/tcp_bpf.c:690:int tcp_bpf_strp_read_sock(struct strparser *strp, read_descriptor_t *desc,\nnet/ipv4/tcp_bpf.c-691-\t\t\t sk_read_actor_t recv_actor)\n"
} |
| 41/2 | 2026/08/17 16:46 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 31734 output: 36 thoughts: 213 Thoughts: **My Initial Investigation into Socket BPF Program Interaction** Okay, so I'm starting to piece together how this socket BPF interaction is working. It looks like `tcp_bpf_strp_read_sock` is a callback function related to the `strparser` mechanism. The `strparser` itself is triggered by `strp_data_ready`, which makes sense because that’s what gets called when data lands on the socket. So, `tcp_bpf_strp_read_sock` is definitely a key function to focus on right now. I also need to see how the sockmap is set up. `sock_map_update_elem_sys` seems like a good focus symbol for that, so I'll double-check it. Ah yes, it's defined in `net/core/sock_map.c`. Now, let me see if I'm missing any other important non-static function calls here… Ah, here's `sock_map_link_create`! That's called when attaching a BPF program to a sockmap. So, `bpf_prog_attach` calls either `sock_map_link_create` or `sock_map_prog_update`, which suggests there are two distinct mechanisms for updating sockmap programs. Let me dig into that second option, and see what `sock_map_prog_update` is doing. |
| 42/2 | 2026/08/17 16:47 | tool | grepper |
0mArgs:{
"Expression": "sock_map_prog_update",
"PathPrefix": "net/core/sock_map.c"
}Results: {
"Output": "net/core/sock_map.c=32=static DEFINE_MUTEX(sockmap_mutex);\nnet/core/sock_map.c-33-\nnet/core/sock_map.c:34:static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,\nnet/core/sock_map.c-35-\t\t\t\tstruct bpf_prog *old, struct bpf_link *link,\n--\nnet/core/sock_map.c=68=int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog)\n--\nnet/core/sock_map.c-80-\tmutex_lock(\u0026sockmap_mutex);\nnet/core/sock_map.c:81:\tret = sock_map_prog_update(map, prog, NULL, NULL, attr-\u003eattach_type);\nnet/core/sock_map.c-82-\tmutex_unlock(\u0026sockmap_mutex);\n--\nnet/core/sock_map.c=86=int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype)\n--\nnet/core/sock_map.c-109-\tmutex_lock(\u0026sockmap_mutex);\nnet/core/sock_map.c:110:\tret = sock_map_prog_update(map, NULL, prog, NULL, attr-\u003eattach_type);\nnet/core/sock_map.c-111-\tmutex_unlock(\u0026sockmap_mutex);\n--\nnet/core/sock_map.c=1520=static int sock_map_prog_attach_check(enum bpf_attach_type attach_type,\n--\nnet/core/sock_map.c-1536- */\nnet/core/sock_map.c:1537:static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,\nnet/core/sock_map.c-1538-\t\t\t\tstruct bpf_prog *old, struct bpf_link *link,\n--\nnet/core/sock_map.c=1742=static void sock_map_link_release(struct bpf_link *link)\n--\nnet/core/sock_map.c-1749-\nnet/core/sock_map.c:1750:\tWARN_ON_ONCE(sock_map_prog_update(sockmap_link-\u003emap, NULL, link-\u003eprog, link,\nnet/core/sock_map.c-1751-\t\t\t\t\t link-\u003eattach_type));\n--\nnet/core/sock_map.c=1875=int sock_map_link_create(const union bpf_attr *attr, struct bpf_prog *prog)\n--\nnet/core/sock_map.c-1911-\tmutex_lock(\u0026sockmap_mutex);\nnet/core/sock_map.c:1912:\tret = sock_map_prog_update(map, prog, NULL, \u0026sockmap_link-\u003elink, attach_type);\nnet/core/sock_map.c-1913-\tmutex_unlock(\u0026sockmap_mutex);\n"
} |
| 43/2 | 2026/08/17 16:47 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 33078 output: 23 thoughts: 38 Thoughts: Here's my take on the thought process, as requested: **Diving into `bpf_prog_attach`'s Dependency Chain** Okay, so `bpf_prog_attach` is making a call to `sock_map_get_from_fd`. That's interesting. I need to understand what's happening there, specifically how this `sock_map_get_from_fd` function fits into the overall picture. I'm going to dig into the implementation of `sock_map_get_from_fd` immediately. I'm already formulating hypotheses about how it's interacting with socket maps, maybe retrieving some data or validating an input, given its name. Time to see what's really going on under the hood and its implications for attaching BPF programs. |
| 44/2 | 2026/08/17 16:47 | tool | grepper |
0mArgs:{
"Expression": "sock_map_get_from_fd"
}Results: {
"Output": "include/linux/bpf.h=3654=int bpf_prog_test_run_syscall(struct bpf_prog *prog,\n--\ninclude/linux/bpf.h-3657-\ninclude/linux/bpf.h:3658:int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog);\ninclude/linux/bpf.h-3659-int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);\n--\ninclude/linux/bpf.h=3731=static inline int bpf_prog_test_run_syscall(struct bpf_prog *prog,\n--\ninclude/linux/bpf.h-3738-#ifdef CONFIG_BPF_SYSCALL\ninclude/linux/bpf.h:3739:static inline int sock_map_get_from_fd(const union bpf_attr *attr,\ninclude/linux/bpf.h-3740-\t\t\t\t struct bpf_prog *prog)\n--\nkernel/bpf/syscall.c=4634=static int bpf_prog_attach(const union bpf_attr *attr)\n--\nkernel/bpf/syscall.c-4676-\tcase BPF_PROG_TYPE_SK_MSG:\nkernel/bpf/syscall.c:4677:\t\tret = sock_map_get_from_fd(attr, prog);\nkernel/bpf/syscall.c-4678-\t\tbreak;\n--\nnet/core/sock_map.c=39=static struct bpf_map *sock_map_alloc(union bpf_attr *attr)\n--\nnet/core/sock_map.c-67-\nnet/core/sock_map.c:68:int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog)\nnet/core/sock_map.c-69-{\n"
} |
| 45/2 | 2026/08/17 16:47 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 33810 output: 37 thoughts: 127 Thoughts: **Analyzing BPF Program Attachment** Okay, so I'm focusing on how BPF programs are attached, specifically for `BPF_PROG_TYPE_SK_SKB` and `BPF_PROG_TYPE_SK_MSG`. I'm tracing the flow, and it looks like `sock_map_get_from_fd` is the critical entry point when using `bpf_prog_attach` for those program types. Aha, and now I'm remembering that `BPF_PROG_TYPE_SK_SKB` covers both `BPF_SK_SKB_STREAM_PARSER` and `BPF_SK_SKB_STREAM_VERDICT` use cases. It's good to keep those distinctions clear. I need to confirm all of this, so let me quickly jump into `kernel/bpf/syscall.c` and take a look at the `bpf_prog_attach` function directly. I'll get a clearer picture of the details from there. |
| 46/2 | 2026/08/17 16:47 | tool | grepper |
0mArgs:{
"Expression": "sock_map_get_from_fd",
"PathPrefix": "kernel/bpf/syscall.c"
}Results: {
"Output": "kernel/bpf/syscall.c=4634=static int bpf_prog_attach(const union bpf_attr *attr)\n--\nkernel/bpf/syscall.c-4676-\tcase BPF_PROG_TYPE_SK_MSG:\nkernel/bpf/syscall.c:4677:\t\tret = sock_map_get_from_fd(attr, prog);\nkernel/bpf/syscall.c-4678-\t\tbreak;\n"
} |
| 47/2 | 2026/08/17 16:47 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 34320 output: 23 thoughts: 277 Thoughts: **My Current Assessment of the Relevant Focus Areas** Okay, so I've identified a few key functions to keep in mind, and those are: `sock_map_get_from_fd`, `sock_map_update_elem_sys`, `tcp_bpf_strp_read_sock`, and, let's add `tcp_bpf_recvmsg` to the list. I need to understand how these relate to the bigger picture, particularly concerning BPF integration. Now, regarding configuration, it looks like `CONFIG_BPF_SYSCALL`, `CONFIG_NET_SOCK_MSG`, which is selected by the former and `NET`, and `CONFIG_BPF_STREAM_PARSER` are all important. I already confirmed that the `BPF_STREAM_PARSER` option *is* user-selectable, which is good. That likely means we need to explicitly enable both `BPF_SYSCALL` and `BPF_STREAM_PARSER` in our config. Let me just double-check one thing...specifically, how `sock_map_update_elem_sys` is invoked. I need to make sure I understand the full call path, particularly from the system call perspective. |
| 48/2 | 2026/08/17 16:47 | tool | grepper |
0mArgs:{
"Expression": "sock_map_update_elem_sys"
}Results: {
"Output": "include/linux/bpf.h=3659=int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);\ninclude/linux/bpf.h:3660:int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value, u64 flags);\ninclude/linux/bpf.h-3661-int sock_map_bpf_prog_query(const union bpf_attr *attr,\n--\ninclude/linux/bpf.h=3745=static inline int sock_map_prog_detach(const union bpf_attr *attr,\n--\ninclude/linux/bpf.h-3750-\ninclude/linux/bpf.h:3751:static inline int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value,\ninclude/linux/bpf.h-3752-\t\t\t\t\t u64 flags)\n--\nkernel/bpf/syscall.c=251=static int bpf_map_update_value(struct bpf_map *map, struct file *map_file,\n--\nkernel/bpf/syscall.c-264-\t\t map-\u003emap_type == BPF_MAP_TYPE_SOCKMAP) {\nkernel/bpf/syscall.c:265:\t\treturn sock_map_update_elem_sys(map, key, value, flags);\nkernel/bpf/syscall.c-266-\t} else if (IS_FD_PROG_ARRAY(map)) {\n--\nnet/core/sock_map.c=555=static int sock_hash_update_common(struct bpf_map *map, void *key,\n--\nnet/core/sock_map.c-557-\nnet/core/sock_map.c:558:int sock_map_update_elem_sys(struct bpf_map *map, void *key, void *value,\nnet/core/sock_map.c-559-\t\t\t u64 flags)\n"
} |
| 49/2 | 2026/08/17 16:47 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 35401 output: 22 thoughts: 253 Thoughts: **My Analysis of Sockmap Updates and Data Reception** Okay, so `sock_map_update_elem_sys` is definitely the key function here; it's the gateway for updating a sockmap from userspace, as it's called by `bpf_map_update_value` in `kernel/bpf/syscall.c`. That's the entry point I need to consider. Now, I need to understand how data is received on a socket managed by a sockmap. Let's look at `tcp_bpf_recvmsg`. Is *that* the entry point for `recvmsg` operations on a socket within a sockmap? Ah, yes, `tcp_bpf_rebuild_protos` handles that by swapping out the standard `recvmsg` with `tcp_bpf_recvmsg` or `tcp_bpf_recvmsg_parser`. Hmm, hold on. `tcp_bpf_recvmsg` is declared as `static`. That limits its direct usefulness for my purposes. Are there any other non-static functions available that can be more directly utilized? Let me see... `tcp_bpf_update_proto` is exported and non-static, and it handles the crucial task of replacing the protocol operations. Promising. And, ah yes, `tcp_bpf_strp_read_sock` is also non-static and exported, specifically used by the `strparser` mechanism. Given that it is used by a string parser, that would likely be a very good focus symbol as well. So, either `tcp_bpf_update_proto` or `tcp_bpf_strp_read_sock` looks like a good place to start my deep dive. I'll need to evaluate each to determine which is more relevant and actionable for my goals. |
| 50/2 | 2026/08/17 16:47 | tool | grepper |
0mArgs:{
"Expression": "tcp_bpf_update_proto"
}Results: {
"Output": "include/net/tcp.h=2838=struct sk_psock;\n--\ninclude/net/tcp.h-2840-#ifdef CONFIG_BPF_SYSCALL\ninclude/net/tcp.h:2841:int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore);\ninclude/net/tcp.h-2842-void tcp_bpf_clone(const struct sock *sk, struct sock *newsk);\n--\nnet/ipv4/tcp_bpf.c=690=int tcp_bpf_strp_read_sock(struct strparser *strp, read_descriptor_t *desc,\n--\nnet/ipv4/tcp_bpf.c-724-\nnet/ipv4/tcp_bpf.c:725:int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)\nnet/ipv4/tcp_bpf.c-726-{\n--\nnet/ipv4/tcp_bpf.c-761-}\nnet/ipv4/tcp_bpf.c:762:EXPORT_SYMBOL_GPL(tcp_bpf_update_proto);\nnet/ipv4/tcp_bpf.c-763-\n--\nnet/ipv4/tcp_ipv4.c=3348=struct proto tcp_prot = {\n--\nnet/ipv4/tcp_ipv4.c-3373-#ifdef CONFIG_BPF_SYSCALL\nnet/ipv4/tcp_ipv4.c:3374:\t.psock_update_sk_prot\t= tcp_bpf_update_proto,\nnet/ipv4/tcp_ipv4.c-3375-#endif\n--\nnet/ipv6/tcp_ipv6.c=2276=struct proto tcpv6_prot = {\n--\nnet/ipv6/tcp_ipv6.c-2301-#ifdef CONFIG_BPF_SYSCALL\nnet/ipv6/tcp_ipv6.c:2302:\t.psock_update_sk_prot\t= tcp_bpf_update_proto,\nnet/ipv6/tcp_ipv6.c-2303-#endif\n"
} |
| 51/2 | 2026/08/17 16:47 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 36622 output: 228 thoughts: 529 Thoughts: **My Analysis of the BPF Sockmap Patch** Okay, let's break this down. My initial thought is that `tcp_bpf_update_proto` is a key focus symbol, especially since it gets called when a socket is added to a sockmap. That suggests a critical point of integration. Here's my summary: This patch is a fix for a memory accounting issue within the BPF sockmap infrastructure. Specifically, it addresses a scenario where `sk_forward_alloc` isn't correctly handled when a `strparser` BPF program returns `SK_PASS` on a socket and the resulting skb is delivered back to the same socket's ingress queue. This is a classic potential memory leak situation. The introduced solution, `sk_psock_skb_ingress_self_assign`, aims to settle any pre-existing forward allocation deficit before receive ownership is granted, which seems like the right approach. This change is fundamentally functional, touching core BPF and networking code, and that makes it a prime candidate for fuzzing. I need to make sure this code path is robust and correct. I'll need to stress test this under many network conditions and various BPF programs. The important focus symbols are: * `sock_map_update_elem_sys` * `sock_map_get_from_fd` * `tcp_bpf_update_proto` * `tcp_bpf_strp_read_sock` As for the necessary configurations, it looks like `BPF_SYSCALL` and `BPF_STREAM_PARSER` are sufficient. `CONFIG_NET_SOCK_MSG` and `CONFIG_STREAM_PARSER` are properly selected by those. I don't see any other dependencies that I need to be aware of. My assessment is that this patch directly addresses a potential memory leak in a critical part of the kernel's BPF networking stack. Good catch. Let's get to testing and verify this fix. |
| 52/2 | 2026/08/17 16:47 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"BPF_SYSCALL",
"BPF_STREAM_PARSER"
],
"FocusSymbols": [
"sock_map_update_elem_sys",
"sock_map_get_from_fd",
"tcp_bpf_update_proto",
"tcp_bpf_strp_read_sock"
],
"Reasoning": "The patch modifies the BPF sockmap infrastructure, specifically how `sk_forward_alloc` memory accounting is handled when a stream parser (strparser) program returns `SK_PASS` and the skb is delivered to the same socket's ingress queue. It introduces `sk_psock_skb_ingress_self_assign` to settle any existing `sk_forward_alloc` deficit before assigning receive ownership to the skb. This is a functional change in reachable core kernel logic (BPF sockmap and stream parser) and is worth fuzzing to ensure memory accounting remains correct under various network conditions and BPF program behaviors.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"BPF_SYSCALL",
"BPF_STREAM_PARSER"
],
"FocusSymbols": [
"sock_map_update_elem_sys",
"sock_map_get_from_fd",
"tcp_bpf_update_proto",
"tcp_bpf_strp_read_sock"
],
"Reasoning": "The patch modifies the BPF sockmap infrastructure, specifically how `sk_forward_alloc` memory accounting is handled when a stream parser (strparser) program returns `SK_PASS` and the skb is delivered to the same socket's ingress queue. It introduces `sk_psock_skb_ingress_self_assign` to settle any existing `sk_forward_alloc` deficit before assigning receive ownership to the skb. This is a functional change in reachable core kernel logic (BPF sockmap and stream parser) and is worth fuzzing to ensure memory accounting remains correct under various network conditions and BPF program behaviors.",
"WorthFuzzing": true
} |
| 53/1 | 2026/08/17 16:47 | action | If |
0mArgs:{
"WorthFuzzing": true
}Results: null |
| 54/2 | 2026/08/17 16:47 | agent | kmsan-evaluator |
0mModel:best-expensive Args: null Results: {
"KMSANReasoning": "The patch addresses an issue with socket memory accounting (`sk_forward_alloc`) when an skb is passed to the same socket via BPF stream parser/verdict. It introduces `sk_psock_skb_ingress_self_assign` to properly handle `sk_rmem_schedule` and `skb_set_owner_r`. The changes involve memory accounting, locking, and saving/restoring `skb-\u003e_sk_redir`. There are no new data structures allocated without initialization, no changes to bounds checking that would expose uninitialized memory, and no data copied to user space that could contain uninitialized fields. Any potential bugs related to these changes would be logic errors, memory leaks, or use-after-free, which are adequately covered by standard KASAN and memory leak detectors. Therefore, a dedicated KMSAN fuzzing session is not required.",
"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: For your convenience, here is the diff of the changes:
commit 0b0e8cf8b321df88c026daea576491fca5c736e2
Author: syz-cluster <triage@syzkaller.com>
Date: Mon Aug 17 16:44:14 2026 +0000
syz-cluster: applied patch under review
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 2521b643fa05d..347cb168f7491 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -586,21 +586,24 @@ static int sk_psock_skb_ingress_enqueue(struct sk_buff *skb,
}
static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len, bool take_ref);
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc);
+static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,
+ struct sk_buff *skb,
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc);
static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len)
+ u32 off, u32 len, bool settle_fwd_alloc)
{
struct sock *sk = psock->sk;
struct sk_msg *msg;
int err;
- /* If we are receiving on the same sock skb->sk is already assigned,
- * skip memory accounting and owner transition seeing it already set
- * correctly.
- */
if (unlikely(skb->sk == sk))
- return sk_psock_skb_ingress_self(psock, skb, off, len, true);
+ return sk_psock_skb_ingress_self_backlog(psock, skb, off,
+ len, true,
+ settle_fwd_alloc);
msg = sk_psock_create_ingress_msg(sk, skb);
if (!msg)
return -EAGAIN;
@@ -618,34 +621,100 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,
return err;
}
-/* Puts an skb on the ingress queue of the socket already assigned to the
- * skb. In this case we do not need to check memory limits or skb_set_owner_r
- * because the skb is already accounted for here.
+static int sk_psock_skb_ingress_self_assign(struct sock *sk,
+ struct sk_buff *skb,
+ bool settle_fwd_alloc)
+{
+ /* Leave skbs already receive-accounted to sk untouched. */
+ if (skb->sk == sk && skb->destructor == sock_rfree)
+ return 0;
+
+ if (settle_fwd_alloc) {
+ sock_owned_by_me(sk);
+
+ if (!sk_rmem_schedule(sk, skb, 0))
+ return -EAGAIN;
+ }
+
+ skb_set_owner_r(skb, sk);
+ return 0;
+}
+
+/* Puts an skb on the ingress queue for psock->sk.
+ *
+ * If the skb already has receive ownership for this socket, leave socket
+ * memory accounting untouched. Otherwise, before assigning receive ownership
+ * to an unowned strparser SK_PASS skb, settle any existing sk_forward_alloc
+ * deficit from earlier clone charges.
*/
static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len, bool take_ref)
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc)
{
+ struct sock *sk = psock->sk;
struct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);
+ int err;
+
+ if (unlikely(!msg))
+ return -EAGAIN;
+
+ err = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);
+ if (err)
+ goto free;
+
+ /* This is used in tcp_bpf_recvmsg_parser() to determine whether the
+ * data originates from the socket's own protocol stack. No need to
+ * refcount sk because msg's lifetime is bound to sk via the ingress_msg.
+ */
+ msg->sk = sk;
+ err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,
+ take_ref);
+ if (err < 0)
+ goto free;
+
+ return err;
+free:
+ kfree(msg);
+ return err;
+}
+
+static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,
+ struct sk_buff *skb,
+ u32 off, u32 len, bool take_ref,
+ bool settle_fwd_alloc)
+{
struct sock *sk = psock->sk;
+ struct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);
int err;
if (unlikely(!msg))
return -EAGAIN;
- skb_set_owner_r(skb, sk);
+
+ lock_sock(sk);
+ err = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);
+ release_sock(sk);
+ if (err)
+ goto free;
/* This is used in tcp_bpf_recvmsg_parser() to determine whether the
* data originates from the socket's own protocol stack. No need to
* refcount sk because msg's lifetime is bound to sk via the ingress_msg.
*/
msg->sk = sk;
- err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg, take_ref);
+ err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,
+ take_ref);
if (err < 0)
- kfree(msg);
+ goto free;
+
+ return err;
+free:
+ kfree(msg);
return err;
}
static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb,
- u32 off, u32 len, bool ingress)
+ u32 off, u32 len, bool ingress,
+ bool self_pass, bool strparser)
{
if (!ingress) {
if (!sock_writeable(psock->sk))
@@ -653,7 +722,11 @@ static int sk_psock_handle_skb(struct sk_psock *psock, struct sk_buff *skb,
return skb_send_sock(psock->sk, skb, off, len);
}
- return sk_psock_skb_ingress(psock, skb, off, len);
+ if (self_pass)
+ return sk_psock_skb_ingress_self_backlog(psock, skb, off,
+ len, true, strparser);
+
+ return sk_psock_skb_ingress(psock, skb, off, len, strparser);
}
static void sk_psock_skb_state(struct sk_psock *psock,
@@ -694,9 +767,14 @@ static void sk_psock_backlog(struct work_struct *work)
return;
mutex_lock(&psock->work_mutex);
while ((skb = skb_peek(&psock->ingress_skb))) {
+ unsigned long saved_redir;
+ bool strparser;
+ bool self_pass;
+
len = skb->len;
off = 0;
- if (skb_bpf_strparser(skb)) {
+ strparser = skb_bpf_strparser(skb);
+ if (strparser) {
struct strp_msg *stm = strp_msg(skb);
off = stm->offset;
@@ -710,17 +788,20 @@ static void sk_psock_backlog(struct work_struct *work)
}
ingress = skb_bpf_ingress(skb);
+ self_pass = ingress && !skb_bpf_redirect_fetch(skb);
+ saved_redir = skb->_sk_redir;
skb_bpf_redirect_clear(skb);
do {
ret = -EIO;
if (!sock_flag(psock->sk, SOCK_DEAD))
ret = sk_psock_handle_skb(psock, skb, off,
- len, ingress);
+ len, ingress,
+ self_pass, strparser);
if (ret <= 0) {
if (ret == -EAGAIN) {
sk_psock_skb_state(psock, state, len, off);
/* Restore redir info we cleared before */
- skb_bpf_set_redir(skb, psock->sk, ingress);
+ skb->_sk_redir = saved_redir;
/* Delay slightly to prioritize any
* other work that might be here.
*/
@@ -1017,6 +1098,8 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,
* retrying later from workqueue.
*/
if (skb_queue_empty(&psock->ingress_skb)) {
+ bool settle_fwd_alloc = false;
+
len = skb->len;
off = 0;
if (skb_bpf_strparser(skb)) {
@@ -1024,8 +1107,10 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,
off = stm->offset;
len = stm->full_len;
+ settle_fwd_alloc = true;
}
- err = sk_psock_skb_ingress_self(psock, skb, off, len, false);
+ err = sk_psock_skb_ingress_self(psock, skb, off, len,
+ false, settle_fwd_alloc);
}
if (err < 0) {
spin_lock_bh(&psock->ingress_lock);
diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c b/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c
index 1d7231728eafd..c7ad21d0bbf49 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_strp.c
@@ -1,5 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <error.h>
+#include <linux/inet_diag.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+#include <linux/sock_diag.h>
#include <netinet/tcp.h>
#include <test_progs.h>
#include "sockmap_helpers.h"
@@ -460,6 +464,171 @@ static void test_sockmap_strp_parser_reject(void)
test_sockmap_strp__destroy(strp);
}
+/* Read sk_forward_alloc through inet_diag meminfo. */
+static int sockmap_strp_get_fwd_alloc(int sock, int *fwd_alloc)
+{
+ struct sockaddr_storage local = {}, peer = {};
+ struct sockaddr_in *local_in, *peer_in;
+ socklen_t addr_len = sizeof(local);
+ char buf[1024];
+ struct {
+ struct nlmsghdr nlh;
+ struct inet_diag_req_v2 req;
+ } req = {
+ .nlh = {
+ .nlmsg_len = sizeof(req),
+ .nlmsg_type = SOCK_DIAG_BY_FAMILY,
+ .nlmsg_flags = NLM_F_REQUEST,
+ .nlmsg_seq = 1,
+ },
+ .req = {
+ .sdiag_family = AF_INET,
+ .sdiag_protocol = IPPROTO_TCP,
+ .idiag_ext = 1 << (INET_DIAG_MEMINFO - 1),
+ .idiag_states = ~0U,
+ .id.idiag_cookie = {
+ INET_DIAG_NOCOOKIE,
+ INET_DIAG_NOCOOKIE,
+ },
+ },
+ };
+ int diag_fd, ret, err = -ENOENT;
+
+ if (getsockname(sock, (struct sockaddr *)&local, &addr_len))
+ return -errno;
+ addr_len = sizeof(peer);
+ if (getpeername(sock, (struct sockaddr *)&peer, &addr_len))
+ return -errno;
+
+ local_in = (struct sockaddr_in *)&local;
+ peer_in = (struct sockaddr_in *)&peer;
+ req.req.id.idiag_sport = local_in->sin_port;
+ req.req.id.idiag_dport = peer_in->sin_port;
+ req.req.id.idiag_src[0] = local_in->sin_addr.s_addr;
+ req.req.id.idiag_dst[0] = peer_in->sin_addr.s_addr;
+
+ diag_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC,
+ NETLINK_SOCK_DIAG);
+ if (diag_fd < 0)
+ return -errno;
+
+ ret = send(diag_fd, &req, sizeof(req), 0);
+ if (ret < 0) {
+ err = -errno;
+ goto out;
+ }
+ if (ret != sizeof(req)) {
+ err = -EIO;
+ goto out;
+ }
+
+ ret = recv(diag_fd, buf, sizeof(buf), 0);
+ if (ret < 0) {
+ err = -errno;
+ goto out;
+ }
+
+ for (struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
+ NLMSG_OK(nlh, ret); nlh = NLMSG_NEXT(nlh, ret)) {
+ struct inet_diag_msg *msg = NLMSG_DATA(nlh);
+ struct rtattr *attr;
+ int len;
+
+ if (nlh->nlmsg_type == NLMSG_ERROR) {
+ err = -EINVAL;
+ goto out;
+ }
+ if (nlh->nlmsg_type == NLMSG_DONE)
+ break;
+
+ len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*msg));
+ for (attr = (struct rtattr *)(msg + 1); RTA_OK(attr, len);
+ attr = RTA_NEXT(attr, len)) {
+ struct inet_diag_meminfo *minfo;
+
+ if (attr->rta_type != INET_DIAG_MEMINFO)
+ continue;
+ minfo = RTA_DATA(attr);
+ *fwd_alloc = (__s32)minfo->idiag_fmem;
+ err = 0;
+ goto out;
+ }
+ }
+
+out:
+ close(diag_fd);
+ return err;
+}
+
+/* Test strparser SK_PASS delivery to the same socket. */
+static void test_sockmap_strp_self_pass_fwd_alloc(void)
+{
+ struct test_sockmap_strp *strp = NULL;
+ char snd[4 * 1024];
+ int c = -1, p = -1;
+ int fwd_alloc;
+ int sndbuf = sizeof(snd);
+ int zero = 0;
+ char rcv;
+ int sent, recvd;
+ int map;
+ int err;
+
+ memset(snd, 0xa5, sizeof(snd));
+
+ strp = test_sockmap_strp__open_and_load();
+ if (!ASSERT_OK_PTR(strp, "test_sockmap_strp__open_and_load"))
+ return;
+
+ map = bpf_map__fd(strp->maps.sock_map);
+ err = xbpf_prog_attach(bpf_program__fd(strp->progs.prog_skb_parser_one),
+ map, BPF_SK_SKB_STREAM_PARSER, 0);
+ if (err)
+ goto out_destroy;
+
+ err = xbpf_prog_attach(bpf_program__fd(strp->progs.prog_skb_verdict_pass),
+ map, BPF_SK_SKB_STREAM_VERDICT, 0);
+ if (err)
+ goto out_destroy;
+
+ err = create_pair(AF_INET, SOCK_STREAM, &c, &p);
+ if (!ASSERT_OK(err, "create_pair"))
+ goto out_destroy;
+
+ err = xsetsockopt(c, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf));
+ if (err)
+ goto out_destroy;
+
+ err = xsetsockopt(p, SOL_SOCKET, SO_RCVBUF, &sndbuf, sizeof(sndbuf));
+ if (err)
+ goto out_destroy;
+
+ err = xbpf_map_update_elem(map, &zero, &p, BPF_NOEXIST);
+ if (err)
+ goto out_destroy;
+
+ sent = send(c, snd, sizeof(snd), MSG_DONTWAIT);
+ if (!ASSERT_EQ(sent, sizeof(snd), "send"))
+ goto out_destroy;
+
+ recvd = recv_timeout(p, &rcv, sizeof(rcv), MSG_DONTWAIT,
+ IO_TIMEOUT_SEC);
+ if (!ASSERT_EQ(recvd, sizeof(rcv), "recv_timeout") ||
+ !ASSERT_EQ(rcv, snd[0], "data mismatch"))
+ goto out_destroy;
+
+ err = sockmap_strp_get_fwd_alloc(p, &fwd_alloc);
+ if (!ASSERT_OK(err, "sockmap_strp_get_fwd_alloc") ||
+ !ASSERT_GE(fwd_alloc, 0, "sk_forward_alloc"))
+ goto out_destroy;
+out_destroy:
+ test_sockmap_strp__destroy(strp);
+ if (c >= 0)
+ close(c);
+ if (p >= 0)
+ close(p);
+}
+
void test_sockmap_strp(void)
{
if (test__start_subtest("sockmap strp tcp pass"))
@@ -482,4 +651,6 @@ void test_sockmap_strp(void)
test_sockmap_strp_dispatch_pkt(AF_INET, SOCK_STREAM);
if (test__start_subtest("sockmap strp parser reject pkt mod"))
test_sockmap_strp_parser_reject();
+ if (test__start_subtest("sockmap strp self pass fwd alloc"))
+ test_sockmap_strp_self_pass_fwd_alloc();
}
diff --git a/tools/testing/selftests/bpf/progs/test_sockmap_strp.c b/tools/testing/selftests/bpf/progs/test_sockmap_strp.c
index fe88fa6d40bc5..682e53d40751c 100644
--- a/tools/testing/selftests/bpf/progs/test_sockmap_strp.c
+++ b/tools/testing/selftests/bpf/progs/test_sockmap_strp.c
@@ -50,6 +50,12 @@ int prog_skb_parser_partial(struct __sk_buff *skb)
return 10;
}
+SEC("sk_skb/stream_parser")
+int prog_skb_parser_one(struct __sk_buff *skb)
+{
+ return 1;
+}
+
SEC("sk_skb/stream_parser")
int prog_skb_parser_resize(struct __sk_buff *skb)
{
|
| 55/3 | 2026/08/17 16:47 | llm | kmsan-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 7278 output: 206 thoughts: 1559 Thoughts: **KMSAN Assessment: SKMSG Changes for Socket Memory Accounting** Okay, let's break this down. My initial assessment is that this patch, touching `net/core/skmsg.c` and adding a test in `tools/testing/selftests/bpf/prog_tests/sockmap_strp.c`, is likely *not* a KMSAN concern. The core of the changes seem to revolve around correcting socket memory accounting, specifically related to `sk_forward_alloc`, when an `skb` is routed back to the same socket via BPF stream parsing. This involves modifications to `sk_psock_skb_ingress_self`, `sk_psock_skb_ingress_self_backlog`, and `sk_psock_skb_ingress_self_assign`. My primary concern, as a KMSAN expert, is whether this patch introduces any risks of exposing uninitialized memory. Let's dig in: The introduction of `settle_fwd_alloc` and the calls to `sk_rmem_schedule(sk, skb, 0)` and `skb_set_owner_r(skb, sk)` are purely about memory management on the *receiving* side, nothing that touches uninitialized memory. Specifically, the patch seems to address a bug or potential leak related to incorrect accounting, possibly resulting in negative values for `sk_forward_alloc`. That's not the same as an uninitialized memory bug. It's more of a logic error that could lead to memory leaks or, potentially, other memory-related errors, but not directly KMSAN-related. Reviewing the code snippets, the addition of `sk_psock_skb_ingress_self_assign` is solely for the purpose of managing memory ownership and accounting. I see no allocation of new, complex structures, nor any manipulation of existing structures that could leave fields uninitialized. The changes also include saving and restoring the `skb->_sk_redir` field, but this field is initialized either when the `skb` is allocated, or cleared by the kernel. There's no scenario here that risks leaking uninitialized memory to user space. The test added appears to verify the socket memory information using `inet_diag_req_v2`, but this is simply a test and does not create an exposure of uninitialized memory. The core functions – `sk_psock_skb_ingress_self`, `sk_psock_skb_ingress_self_backlog`, and the new function `sk_psock_skb_ingress_self_assign` – are all focused on memory accounting. They involve locking, ownership management, and scheduling receive memory. Therefore, my conclusion is that a `NeedsKMSAN` tag is *not* appropriate here. While a bug in these changes *could* lead to memory leaks or use-after-free, those are already well-covered by KASAN and memory leak detectors. The introduced changes do not introduce new allocation/initialization paths, bounds-check changes that could leak uninitialized memory to user space or any user space data structures with fields that could contain uninitialized values. This is strictly logic for socket accounting; KMSAN is not necessary in this instance. |
| 56/3 | 2026/08/17 16:47 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch addresses an issue with socket memory accounting (`sk_forward_alloc`) when an skb is passed to the same socket via BPF stream parser/verdict. It introduces `sk_psock_skb_ingress_self_assign` to properly handle `sk_rmem_schedule` and `skb_set_owner_r`. The changes involve memory accounting, locking, and saving/restoring `skb-\u003e_sk_redir`. There are no new data structures allocated without initialization, no changes to bounds checking that would expose uninitialized memory, and no data copied to user space that could contain uninitialized fields. Any potential bugs related to these changes would be logic errors, memory leaks, or use-after-free, which are adequately covered by standard KASAN and memory leak detectors. Therefore, a dedicated KMSAN fuzzing session is not required.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch addresses an issue with socket memory accounting (`sk_forward_alloc`) when an skb is passed to the same socket via BPF stream parser/verdict. It introduces `sk_psock_skb_ingress_self_assign` to properly handle `sk_rmem_schedule` and `skb_set_owner_r`. The changes involve memory accounting, locking, and saving/restoring `skb-\u003e_sk_redir`. There are no new data structures allocated without initialization, no changes to bounds checking that would expose uninitialized memory, and no data copied to user space that could contain uninitialized fields. Any potential bugs related to these changes would be logic errors, memory leaks, or use-after-free, which are adequately covered by standard KASAN and memory leak detectors. Therefore, a dedicated KMSAN fuzzing session is not required.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|