| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/26 18:43 | flow | patch-triage |
3mArgs:null Results: {
"EnableConfigs": [
"INET",
"MPTCP"
],
"FocusSymbols": [
"sk_set_nospace",
"sk_clear_nospace",
"__tcp_check_space",
"sk_stream_wait_memory",
"sk_stream_write_space",
"mptcp_check_writeable",
"subflow_ulp_init"
],
"KMSANReasoning": "The patch introduces a cache field `tcp_nospace` in `struct tcp_sock` mirroring `SOCK_NOSPACE` on `sk-\u003esk_socket-\u003eflags`, and wraps setting/clearing of this flag with `sk_set_nospace()` and `sk_clear_nospace()` across socket callers (TCP, MPTCP, DLM, NVMe-oF, RDS, SMC, SUNRPC, TLS).\n\n1. `struct tcp_sock` is zero-initialized on allocation via `sk_alloc()`, where `want_init_on_alloc()` triggers `sk_prot_clear_nulls()` clearing the object. For cloned child sockets, `sock_copy()` replicates the zeroed state from the parent socket, and MPTCP subflows explicitly initialize `tp-\u003etcp_nospace = 1` in `subflow_ulp_init()`. The field is always properly initialized before any read.\n2. `tcp_nospace` is an internal kernel-only field within `struct tcp_sock` and is not part of user-facing structures (such as `struct tcp_info` in `include/uapi/linux/tcp.h`). No padding or structure bytes are copied to user space.\n3. No buffer bounds, length calculations, or allocations with uninitialized memory are modified.\n\nAny potential bugs from this patch (such as race conditions, memory ordering, or NULL pointer dereferences) fall under concurrency issues or standard functional errors, which are not detected by KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies core networking flow control and write-space notification logic by introducing tcp_nospace in struct tcp_sock to mirror SOCK_NOSPACE, adding memory barriers (smp_store_mb, smp_mb__before/after_atomic) and helpers sk_set_nospace() and sk_clear_nospace(). These changes affect reachable TCP, MPTCP, socket wait/wake paths and are prone to race conditions or lost wakeups under concurrent traffic.",
"WorthFuzzing": true
} |
| 1/1 | 2026/09/26 18:43 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 8fd6a816640b16f6d1066b4da2c1e4ff561e8025\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Sep 26 18:43:11 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/networking/net_cachelines/tcp_sock.rst b/Documentation/networking/net_cachelines/tcp_sock.rst\nindex 0f6088c4ab8bb..103328dc409e4 100644\n--- a/Documentation/networking/net_cachelines/tcp_sock.rst\n+++ b/Documentation/networking/net_cachelines/tcp_sock.rst\n@@ -50,6 +50,7 @@ u8:1 tcp_usec_ts read_mostly read_m\n u32 chrono_start read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)\n u32[3] chrono_stat read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)\n u8:2 chrono_type read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)\n+u8 tcp_nospace read_mostly read_mostly tcp_check_space(tx);tcp_check_space(rx)\n u8:1 rate_app_limited read_write tcp_rate_gen\n u8:1 fastopen_connect\n u8:1 fastopen_no_cookie\ndiff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c\nindex 0697f99fed18d..8e50131b5a569 100644\n--- a/drivers/block/drbd/drbd_worker.c\n+++ b/drivers/block/drbd/drbd_worker.c\n@@ -635,8 +635,7 @@ static int make_resync_request(struct drbd_peer_device *const peer_device, int c\n \t\t\tint sndbuf = sk-\u003esk_sndbuf;\n \t\t\tif (queued \u003e sndbuf / 2) {\n \t\t\t\trequeue = 1;\n-\t\t\t\tif (sk-\u003esk_socket)\n-\t\t\t\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\t\t\tsk_set_nospace(sk);\n \t\t\t}\n \t\t} else\n \t\t\trequeue = 1;\ndiff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c\nindex 921934028e0b2..b853ca2d598fa 100644\n--- a/drivers/nvme/host/tcp.c\n+++ b/drivers/nvme/host/tcp.c\n@@ -1133,7 +1133,7 @@ static void nvme_tcp_write_space(struct sock *sk)\n \tread_lock_bh(\u0026sk-\u003esk_callback_lock);\n \tqueue = sk-\u003esk_user_data;\n \tif (likely(queue \u0026\u0026 sk_stream_is_writeable(sk))) {\n-\t\tclear_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_clear_nospace(sk);\n \t\t/* Ensure pending TLS partial records are retried */\n \t\tif (nvme_tcp_queue_tls(queue))\n \t\t\tqueue-\u003ewrite_space(sk);\ndiff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c\nindex e598101752620..c38ea3501ea5d 100644\n--- a/drivers/nvme/target/tcp.c\n+++ b/drivers/nvme/target/tcp.c\n@@ -1686,7 +1686,7 @@ static void nvmet_tcp_write_space(struct sock *sk)\n \t}\n \n \tif (sk_stream_is_writeable(sk)) {\n-\t\tclear_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_clear_nospace(sk);\n \t\tqueue_work_on(queue_cpu(queue), nvmet_tcp_wq, \u0026queue-\u003eio_work);\n \t}\n out:\ndiff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c\nindex 2aff1c7c17de4..6aa68a24acab5 100644\n--- a/fs/dlm/lowcomms.c\n+++ b/fs/dlm/lowcomms.c\n@@ -519,13 +519,11 @@ static void lowcomms_write_space(struct sock *sk)\n {\n \tstruct connection *con = sock2con(sk);\n \n-\tclear_bit(SOCK_NOSPACE, \u0026con-\u003esock-\u003eflags);\n+\tsk_clear_nospace(sk);\n \n \tspin_lock_bh(\u0026con-\u003ewritequeue_lock);\n-\tif (test_and_clear_bit(CF_APP_LIMITED, \u0026con-\u003eflags)) {\n+\tif (test_and_clear_bit(CF_APP_LIMITED, \u0026con-\u003eflags))\n \t\tcon-\u003esock-\u003esk-\u003esk_write_pending--;\n-\t\tclear_bit(SOCKWQ_ASYNC_NOSPACE, \u0026con-\u003esock-\u003eflags);\n-\t}\n \n \tlowcomms_queue_swork(con);\n \tspin_unlock_bh(\u0026con-\u003ewritequeue_lock);\n@@ -1391,12 +1389,12 @@ static int send_to_sock(struct connection *con)\n \tif (ret == -EAGAIN || ret == 0) {\n \t\tlock_sock(con-\u003esock-\u003esk);\n \t\tspin_lock_bh(\u0026con-\u003ewritequeue_lock);\n-\t\tif (test_bit(SOCKWQ_ASYNC_NOSPACE, \u0026con-\u003esock-\u003eflags) \u0026\u0026\n+\t\tif (test_bit(SOCK_NOSPACE, \u0026con-\u003esock-\u003eflags) \u0026\u0026\n \t\t !test_and_set_bit(CF_APP_LIMITED, \u0026con-\u003eflags)) {\n \t\t\t/* Notify TCP that we're limited by the\n \t\t\t * application window size.\n \t\t\t */\n-\t\t\tset_bit(SOCK_NOSPACE, \u0026con-\u003esock-\u003esk-\u003esk_socket-\u003eflags);\n+\t\t\tsk_set_nospace(con-\u003esock-\u003esk);\n \t\t\tcon-\u003esock-\u003esk-\u003esk_write_pending++;\n \n \t\t\tclear_bit(CF_SEND_PENDING, \u0026con-\u003eflags);\ndiff --git a/include/linux/tcp.h b/include/linux/tcp.h\nindex 6a8c77719322f..e4d1720f49f08 100644\n--- a/include/linux/tcp.h\n+++ b/include/linux/tcp.h\n@@ -269,6 +269,9 @@ struct tcp_sock {\n \t\t\t\t */\n \tu32\tsnd_sml;\t/* Last byte of the most recently transmitted small packet */\n \tu8\tchrono_type;\t/* current chronograph type */\n+\tu8\ttcp_nospace;\t/* mirrors SOCK_NOSPACE, must be set whenever\n+\t\t\t\t * SOCK_NOSPACE is set.\n+\t\t\t\t */\n \tu32\tchrono_start;\t/* Start time in jiffies of a TCP chrono */\n \tu32\tchrono_stat[3];\t/* Time in jiffies for chrono_stat stats */\n \tu32\twrite_seq;\t/* Tail(+1) of data held in tcp send buffer */\ndiff --git a/include/net/sock.h b/include/net/sock.h\nindex 60ea55dc18854..f4dd2e1051713 100644\n--- a/include/net/sock.h\n+++ b/include/net/sock.h\n@@ -1129,6 +1129,8 @@ static inline void sk_forward_alloc_add(struct sock *sk, int val)\n }\n \n void sk_stream_write_space(struct sock *sk);\n+void sk_set_nospace(struct sock *sk);\n+void sk_clear_nospace(struct sock *sk);\n \n /* OOB backlog add */\n static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)\ndiff --git a/include/net/tcp.h b/include/net/tcp.h\nindex 5e5f5f9b89a38..3389c51790e6b 100644\n--- a/include/net/tcp.h\n+++ b/include/net/tcp.h\n@@ -783,14 +783,42 @@ void tcp_done_with_error(struct sock *sk, int err);\n void tcp_reset(struct sock *sk, struct sk_buff *skb);\n void tcp_fin(struct sock *sk);\n void __tcp_check_space(struct sock *sk);\n+\n+/* Mirror of SOCK_NOSPACE in tcp_sock, maintained by sk_set_nospace()\n+ * and sk_clear_nospace().\n+ *\n+ * MPTCP subflows share the parent socket, and thus its SOCK_NOSPACE bit.\n+ * Keep their mirror always set (see subflow_ulp_init()) so that they\n+ * always reach __tcp_check_space() and behave as before.\n+ */\n+static inline void tcp_set_nospace(struct sock *sk)\n+{\n+\tif (sk_is_tcp(sk)) {\n+\t\t/* pairs with smp_mb__before_atomic() in tcp_clear_nospace() */\n+\t\tsmp_mb__after_atomic();\n+\t\t/* pairs with smp_mb() in tcp_check_space() */\n+\t\tsmp_store_mb(tcp_sk(sk)-\u003etcp_nospace, 1);\n+\t}\n+}\n+\n+static inline void tcp_clear_nospace(struct sock *sk)\n+{\n+\tif (sk_is_tcp(sk) \u0026\u0026 !sk_is_mptcp(sk)) {\n+\t\tWRITE_ONCE(tcp_sk(sk)-\u003etcp_nospace, 0);\n+\t\t/* pairs with smp_mb__after_atomic() in tcp_set_nospace() */\n+\t\tsmp_mb__before_atomic();\n+\t}\n+}\n+\n static inline void tcp_check_space(struct sock *sk)\n {\n \t/* pairs with tcp_poll() */\n \tsmp_mb();\n \n-\tif (sk-\u003esk_socket \u0026\u0026 test_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags))\n+\tif (unlikely(READ_ONCE(tcp_sk(sk)-\u003etcp_nospace)))\n \t\t__tcp_check_space(sk);\n }\n+\n void tcp_sack_compress_send_ack(struct sock *sk);\n \n static inline void tcp_cleanup_skb(struct sk_buff *skb)\ndiff --git a/net/ceph/messenger.c b/net/ceph/messenger.c\nindex 212e7797f9e48..cc7db8c61db37 100644\n--- a/net/ceph/messenger.c\n+++ b/net/ceph/messenger.c\n@@ -375,7 +375,7 @@ static void ceph_sock_write_space(struct sock *sk)\n \tif (ceph_con_flag_test(con, CEPH_CON_F_WRITE_PENDING)) {\n \t\tif (sk_stream_is_writeable(sk)) {\n \t\t\tdout(\"%s %p queueing write work\\n\", __func__, con);\n-\t\t\tclear_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\t\tsk_clear_nospace(sk);\n \t\t\tqueue_con(con);\n \t\t}\n \t} else {\ndiff --git a/net/core/sock.c b/net/core/sock.c\nindex 2948dffcc3e1b..946f614f665b3 100644\n--- a/net/core/sock.c\n+++ b/net/core/sock.c\n@@ -2957,6 +2957,48 @@ void sock_kzfree_s(struct sock *sk, void *mem, int size)\n }\n EXPORT_SYMBOL(sock_kzfree_s);\n \n+/**\n+ *\tsk_set_nospace - tell the transport a writer is waiting for space\n+ *\t@sk: socket\n+ *\n+ *\tMust be called before the final check of the available send space,\n+ *\tso that the transport can not miss the request and forget to call\n+ *\tsk-\u003esk_write_space() once space is available again.\n+ */\n+void sk_set_nospace(struct sock *sk)\n+{\n+\tstruct socket *sock = sk-\u003esk_socket;\n+\n+\tif (!sock)\n+\t\treturn;\n+\t/* Set SOCK_NOSPACE before tp-\u003etcp_nospace (paired with\n+\t * sk_clear_nospace() clearing tp-\u003etcp_nospace before SOCK_NOSPACE)\n+\t * so a concurrent clear cannot leave SOCK_NOSPACE set with\n+\t * tp-\u003etcp_nospace cleared.\n+\t */\n+\tset_bit(SOCK_NOSPACE, \u0026sock-\u003eflags);\n+\ttcp_set_nospace(sk);\n+}\n+EXPORT_SYMBOL(sk_set_nospace);\n+\n+/**\n+ *\tsk_clear_nospace - tell the transport no writer is waiting for space\n+ *\t@sk: socket\n+ *\n+ *\tCalled from -\u003esk_write_space() handlers, once send space has been\n+ *\tmade available to writers.\n+ */\n+void sk_clear_nospace(struct sock *sk)\n+{\n+\tstruct socket *sock = sk-\u003esk_socket;\n+\n+\tif (!sock)\n+\t\treturn;\n+\ttcp_clear_nospace(sk);\n+\tclear_bit(SOCK_NOSPACE, \u0026sock-\u003eflags);\n+}\n+EXPORT_SYMBOL(sk_clear_nospace);\n+\n /* It is almost wait_for_tcp_memory minus release_sock/lock_sock.\n I think, these locks should be removed for datagram sockets.\n */\n@@ -2970,7 +3012,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)\n \t\t\tbreak;\n \t\tif (signal_pending(current))\n \t\t\tbreak;\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\tprepare_to_wait(sk_sleep(sk), \u0026wait, TASK_INTERRUPTIBLE);\n \t\tif (refcount_read(\u0026sk-\u003esk_wmem_alloc) \u003c READ_ONCE(sk-\u003esk_sndbuf))\n \t\t\tbreak;\n@@ -3011,7 +3053,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,\n \t\t\tbreak;\n \n \t\tsk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\terr = -EAGAIN;\n \t\tif (!timeo)\n \t\t\tgoto failure;\ndiff --git a/net/core/stream.c b/net/core/stream.c\nindex 2d748581862d0..a853b60afdc35 100644\n--- a/net/core/stream.c\n+++ b/net/core/stream.c\n@@ -37,7 +37,7 @@ void sk_stream_write_space(struct sock *sk)\n \tstruct socket_wq *wq;\n \n \tif (__sk_stream_is_writeable(sk, 1) \u0026\u0026 sock) {\n-\t\tclear_bit(SOCK_NOSPACE, \u0026sock-\u003eflags);\n+\t\tsk_clear_nospace(sk);\n \n \t\trcu_read_lock();\n \t\twq = rcu_dereference(sk-\u003esk_wq);\n@@ -143,7 +143,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)\n \t\tif (sk_stream_memory_free(sk) \u0026\u0026 !vm_wait)\n \t\t\tbreak;\n \n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\tsk-\u003esk_write_pending++;\n \t\tret = sk_wait_event(sk, \u0026current_timeo, READ_ONCE(sk-\u003esk_err) ||\n \t\t\t\t (READ_ONCE(sk-\u003esk_shutdown) \u0026 SEND_SHUTDOWN) ||\n@@ -177,7 +177,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)\n \t * When TCP receives ACK packets that make room, tcp_check_space()\n \t * only calls tcp_new_space() if SOCK_NOSPACE is set.\n \t */\n-\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\tsk_set_nospace(sk);\n \terr = -EAGAIN;\n \tgoto out;\n do_interrupted:\ndiff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c\nindex 3ac4856852794..f44cbd3e76178 100644\n--- a/net/ipv4/tcp.c\n+++ b/net/ipv4/tcp.c\n@@ -607,7 +607,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)\n \t\t\t\tmask |= EPOLLOUT | EPOLLWRNORM;\n \t\t\t} else { /* send SIGIO later */\n \t\t\t\tsk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);\n-\t\t\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\t\t\tsk_set_nospace(sk);\n \n \t\t\t\t/* Race breaker. If space is freed after\n \t\t\t\t * wspace test but before the flags are set,\n@@ -1398,7 +1398,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)\n \t\tcontinue;\n \n wait_for_space:\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\ttcp_remove_empty_skb(sk);\n \t\tif (copied)\n \t\t\ttcp_push(sk, flags \u0026 ~MSG_MORE, mss_now,\n@@ -5242,6 +5242,7 @@ static void __init tcp_struct_check(void)\n \tCACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, first_tx_mstamp);\n \tCACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, delivered_mstamp);\n \tCACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, snd_sml);\n+\tCACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, tcp_nospace);\n \tCACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, chrono_start);\n \tCACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, chrono_stat);\n \tCACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, write_seq);\ndiff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c\nindex 2e234d155b5e6..64d74d92af52d 100644\n--- a/net/ipv4/tcp_bpf.c\n+++ b/net/ipv4/tcp_bpf.c\n@@ -602,7 +602,7 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)\n \t\t\tgoto out_err;\n \t\tcontinue;\n wait_for_sndbuf:\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n wait_for_memory:\n \t\terr = sk_stream_wait_memory(sk, \u0026timeo);\n \t\tif (err) {\ndiff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c\nindex 892ff256e2352..cdea30d07fe2c 100644\n--- a/net/ipv4/tcp_input.c\n+++ b/net/ipv4/tcp_input.c\n@@ -6098,8 +6098,14 @@ static void tcp_new_space(struct sock *sk)\n */\n void __tcp_check_space(struct sock *sk)\n {\n+\tstruct socket *sock = sk-\u003esk_socket;\n+\n+\t/* tp-\u003etcp_nospace is only a hint, SOCK_NOSPACE is authoritative. */\n+\tif (!sock || !test_bit(SOCK_NOSPACE, \u0026sock-\u003eflags))\n+\t\treturn;\n+\n \ttcp_new_space(sk);\n-\tif (!test_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags))\n+\tif (!test_bit(SOCK_NOSPACE, \u0026sock-\u003eflags))\n \t\ttcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);\n }\n \ndiff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c\nindex 71af69d442f21..b29c0ed9caf52 100644\n--- a/net/kcm/kcmsock.c\n+++ b/net/kcm/kcmsock.c\n@@ -735,7 +735,7 @@ static void kcm_tx_work(struct work_struct *w)\n \t/* Primarily for SOCK_SEQPACKET sockets */\n \tif (likely(sk-\u003esk_socket) \u0026\u0026\n \t test_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags)) {\n-\t\tclear_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_clear_nospace(sk);\n \t\tsk-\u003esk_write_space(sk);\n \t}\n \n@@ -779,7 +779,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)\n \t/* Call the sk_stream functions to manage the sndbuf mem. */\n \tif (!sk_stream_memory_free(sk)) {\n \t\tkcm_push(kcm);\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\terr = sk_stream_wait_memory(sk, \u0026timeo);\n \t\tif (err)\n \t\t\tgoto out_error;\ndiff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c\nindex e89a69ab927c9..74b1a51207287 100644\n--- a/net/mptcp/protocol.c\n+++ b/net/mptcp/protocol.c\n@@ -2106,7 +2106,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)\n \t\tcontinue;\n \n wait_for_memory:\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\t__mptcp_push_pending(sk, msg-\u003emsg_flags);\n \t\tret = sk_stream_wait_memory(sk, \u0026timeo);\n \t\tif (ret)\n@@ -4472,7 +4472,7 @@ static __poll_t mptcp_check_writeable(struct mptcp_sock *msk)\n \tif (__mptcp_stream_is_writeable(sk, 1))\n \t\treturn EPOLLOUT | EPOLLWRNORM;\n \n-\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\tsk_set_nospace(sk);\n \tsmp_mb__after_atomic(); /* NOSPACE is changed by mptcp_write_space() */\n \tif (__mptcp_stream_is_writeable(sk, 1))\n \t\treturn EPOLLOUT | EPOLLWRNORM;\ndiff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c\nindex f0a6725d2c376..e297c88be503b 100644\n--- a/net/mptcp/subflow.c\n+++ b/net/mptcp/subflow.c\n@@ -2001,6 +2001,11 @@ static int subflow_ulp_init(struct sock *sk)\n \tpr_debug(\"subflow=%p, family=%d\\n\", ctx, sk-\u003esk_family);\n \n \ttp-\u003eis_mptcp = 1;\n+\t/* Subflows share the MPTCP socket, and thus its SOCK_NOSPACE bit,\n+\t * which tcp_check_space() can not mirror. Pin the mirror so that\n+\t * __tcp_check_space() always tests the shared bit.\n+\t */\n+\ttp-\u003etcp_nospace = 1;\n \tctx-\u003eicsk_af_ops = icsk-\u003eicsk_af_ops;\n \ticsk-\u003eicsk_af_ops = subflow_default_af_ops(sk);\n \tctx-\u003etcp_state_change = sk-\u003esk_state_change;\ndiff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c\nindex 7c52acc749cf4..824222c475119 100644\n--- a/net/rds/tcp_send.c\n+++ b/net/rds/tcp_send.c\n@@ -100,7 +100,7 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,\n \n \tif (hdr_off \u003c sizeof(struct rds_header)) {\n \t\t/* see rds_tcp_write_space() */\n-\t\tset_bit(SOCK_NOSPACE, \u0026tc-\u003et_sock-\u003esk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(tc-\u003et_sock-\u003esk);\n \n \t\tret = rds_tcp_sendmsg(tc-\u003et_sock,\n \t\t\t\t (void *)\u0026rm-\u003em_inc.i_hdr + hdr_off,\n@@ -221,6 +221,5 @@ void rds_tcp_write_space(struct sock *sk)\n \t */\n \twrite_space(sk);\n \n-\tif (sk-\u003esk_socket)\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\tsk_set_nospace(sk);\n }\ndiff --git a/net/smc/af_smc.c b/net/smc/af_smc.c\nindex e9f93b3ab435b..4f2afbbdef2d7 100644\n--- a/net/smc/af_smc.c\n+++ b/net/smc/af_smc.c\n@@ -2919,7 +2919,7 @@ __poll_t smc_poll(struct file *file, struct socket *sock,\n \t\t\t\tmask |= EPOLLOUT | EPOLLWRNORM;\n \t\t\t} else {\n \t\t\t\tsk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);\n-\t\t\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\t\t\tsk_set_nospace(sk);\n \n \t\t\t\tif (sk-\u003esk_state != SMC_INIT) {\n \t\t\t\t\t/* Race breaker the same way as tcp_poll(). */\ndiff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c\nindex 3144b4b1fe290..52e5395484fd3 100644\n--- a/net/smc/smc_tx.c\n+++ b/net/smc/smc_tx.c\n@@ -48,7 +48,7 @@ static void smc_tx_write_space(struct sock *sk)\n \tif (atomic_read(\u0026smc-\u003econn.sndbuf_space) \u0026\u0026 sock) {\n \t\tif (test_bit(SOCK_NOSPACE, \u0026sock-\u003eflags))\n \t\t\tSMC_STAT_RMB_TX_FULL(smc, !smc-\u003econn.lnk);\n-\t\tclear_bit(SOCK_NOSPACE, \u0026sock-\u003eflags);\n+\t\tsk_clear_nospace(sk);\n \t\trcu_read_lock();\n \t\twq = rcu_dereference(sk-\u003esk_wq);\n \t\tif (skwq_has_sleeper(wq))\n@@ -100,7 +100,7 @@ static int smc_tx_wait(struct smc_sock *smc, int flags)\n \t\t}\n \t\tif (!timeo) {\n \t\t\t/* ensure EPOLLOUT is subsequently generated */\n-\t\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\t\tsk_set_nospace(sk);\n \t\t\trc = -EAGAIN;\n \t\t\tbreak;\n \t\t}\n@@ -111,7 +111,7 @@ static int smc_tx_wait(struct smc_sock *smc, int flags)\n \t\tsk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);\n \t\tif (atomic_read(\u0026conn-\u003esndbuf_space) \u0026\u0026 !conn-\u003eurg_tx_pend)\n \t\t\tbreak; /* at least 1 byte of free \u0026 no urgent data */\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\tsk_wait_event(sk, \u0026timeo,\n \t\t\t READ_ONCE(sk-\u003esk_err) ||\n \t\t\t (READ_ONCE(sk-\u003esk_shutdown) \u0026 SEND_SHUTDOWN) ||\ndiff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c\nindex 50e5e7f5b762d..2d8cdee0798d5 100644\n--- a/net/sunrpc/svcsock.c\n+++ b/net/sunrpc/svcsock.c\n@@ -792,11 +792,11 @@ static int svc_udp_has_wspace(struct svc_xprt *xprt)\n \t * Set the SOCK_NOSPACE flag before checking the available\n \t * sock space.\n \t */\n-\tset_bit(SOCK_NOSPACE, \u0026svsk-\u003esk_sock-\u003eflags);\n+\tsk_set_nospace(svsk-\u003esk_sk);\n \trequired = atomic_read(\u0026svsk-\u003esk_xprt.xpt_reserved) + serv-\u003esv_max_mesg;\n \tif (required*2 \u003e sock_wspace(svsk-\u003esk_sk))\n \t\treturn 0;\n-\tclear_bit(SOCK_NOSPACE, \u0026svsk-\u003esk_sock-\u003eflags);\n+\tsk_clear_nospace(svsk-\u003esk_sk);\n \treturn 1;\n }\n \ndiff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c\nindex 7f60723fa64d8..b97c70c12f627 100644\n--- a/net/sunrpc/xprtsock.c\n+++ b/net/sunrpc/xprtsock.c\n@@ -858,7 +858,7 @@ static int xs_nospace(struct rpc_rqst *req, struct sock_xprt *transport)\n \tif (xprt_connected(xprt)) {\n \t\t/* wait for more buffer space */\n \t\tset_bit(XPRT_SOCK_NOSPACE, \u0026transport-\u003esock_state);\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n \t\tsk-\u003esk_write_pending++;\n \t\txprt_wait_for_buffer_space(xprt);\n \t} else\n@@ -1615,7 +1615,7 @@ static void xs_write_space(struct sock *sk)\n \n \tif (!sk-\u003esk_socket)\n \t\treturn;\n-\tclear_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\tsk_clear_nospace(sk);\n \n \tif (unlikely(!(xprt = xprt_from_sock(sk))))\n \t\treturn;\ndiff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c\nindex d1ad31986cf2c..312e51270f293 100644\n--- a/net/tls/tls_sw.c\n+++ b/net/tls/tls_sw.c\n@@ -966,7 +966,7 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,\n \t\tcontinue;\n \n wait_for_sndbuf:\n-\t\tset_bit(SOCK_NOSPACE, \u0026sk-\u003esk_socket-\u003eflags);\n+\t\tsk_set_nospace(sk);\n wait_for_memory:\n \t\tret = sk_stream_wait_memory(sk, \u0026timeo);\n \t\tif (ret) {\n"
} |
| 2/1 | 2026/09/26 18:43 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": [
"INET",
"MPTCP"
],
"FocusSymbols": [
"sk_set_nospace",
"sk_clear_nospace",
"__tcp_check_space",
"sk_stream_wait_memory",
"sk_stream_write_space",
"mptcp_check_writeable",
"subflow_ulp_init"
],
"Reasoning": "The patch modifies core networking flow control and write-space notification logic by introducing tcp_nospace in struct tcp_sock to mirror SOCK_NOSPACE, adding memory barriers (smp_store_mb, smp_mb__before/after_atomic) and helpers sk_set_nospace() and sk_clear_nospace(). These changes affect reachable TCP, MPTCP, socket wait/wake paths and are prone to race conditions or lost wakeups under concurrent traffic.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 8fd6a816640b16f6d1066b4da2c1e4ff561e8025
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Sep 26 18:43:11 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/networking/net_cachelines/tcp_sock.rst b/Documentation/networking/net_cachelines/tcp_sock.rst
index 0f6088c4ab8bb..103328dc409e4 100644
--- a/Documentation/networking/net_cachelines/tcp_sock.rst
+++ b/Documentation/networking/net_cachelines/tcp_sock.rst
@@ -50,6 +50,7 @@ u8:1 tcp_usec_ts read_mostly read_m
u32 chrono_start read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)
u32[3] chrono_stat read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)
u8:2 chrono_type read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)
+u8 tcp_nospace read_mostly read_mostly tcp_check_space(tx);tcp_check_space(rx)
u8:1 rate_app_limited read_write tcp_rate_gen
u8:1 fastopen_connect
u8:1 fastopen_no_cookie
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index 0697f99fed18d..8e50131b5a569 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -635,8 +635,7 @@ static int make_resync_request(struct drbd_peer_device *const peer_device, int c
int sndbuf = sk->sk_sndbuf;
if (queued > sndbuf / 2) {
requeue = 1;
- if (sk->sk_socket)
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
}
} else
requeue = 1;
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 921934028e0b2..b853ca2d598fa 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1133,7 +1133,7 @@ static void nvme_tcp_write_space(struct sock *sk)
read_lock_bh(&sk->sk_callback_lock);
queue = sk->sk_user_data;
if (likely(queue && sk_stream_is_writeable(sk))) {
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
/* Ensure pending TLS partial records are retried */
if (nvme_tcp_queue_tls(queue))
queue->write_space(sk);
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index e598101752620..c38ea3501ea5d 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1686,7 +1686,7 @@ static void nvmet_tcp_write_space(struct sock *sk)
}
if (sk_stream_is_writeable(sk)) {
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
queue_work_on(queue_cpu(queue), nvmet_tcp_wq, &queue->io_work);
}
out:
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 2aff1c7c17de4..6aa68a24acab5 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -519,13 +519,11 @@ static void lowcomms_write_space(struct sock *sk)
{
struct connection *con = sock2con(sk);
- clear_bit(SOCK_NOSPACE, &con->sock->flags);
+ sk_clear_nospace(sk);
spin_lock_bh(&con->writequeue_lock);
- if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) {
+ if (test_and_clear_bit(CF_APP_LIMITED, &con->flags))
con->sock->sk->sk_write_pending--;
- clear_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags);
- }
lowcomms_queue_swork(con);
spin_unlock_bh(&con->writequeue_lock);
@@ -1391,12 +1389,12 @@ static int send_to_sock(struct connection *con)
if (ret == -EAGAIN || ret == 0) {
lock_sock(con->sock->sk);
spin_lock_bh(&con->writequeue_lock);
- if (test_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags) &&
+ if (test_bit(SOCK_NOSPACE, &con->sock->flags) &&
!test_and_set_bit(CF_APP_LIMITED, &con->flags)) {
/* Notify TCP that we're limited by the
* application window size.
*/
- set_bit(SOCK_NOSPACE, &con->sock->sk->sk_socket->flags);
+ sk_set_nospace(con->sock->sk);
con->sock->sk->sk_write_pending++;
clear_bit(CF_SEND_PENDING, &con->flags);
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 6a8c77719322f..e4d1720f49f08 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -269,6 +269,9 @@ struct tcp_sock {
*/
u32 snd_sml; /* Last byte of the most recently transmitted small packet */
u8 chrono_type; /* current chronograph type */
+ u8 tcp_nospace; /* mirrors SOCK_NOSPACE, must be set whenever
+ * SOCK_NOSPACE is set.
+ */
u32 chrono_start; /* Start time in jiffies of a TCP chrono */
u32 chrono_stat[3]; /* Time in jiffies for chrono_stat stats */
u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
diff --git a/include/net/sock.h b/include/net/sock.h
index 60ea55dc18854..f4dd2e1051713 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1129,6 +1129,8 @@ static inline void sk_forward_alloc_add(struct sock *sk, int val)
}
void sk_stream_write_space(struct sock *sk);
+void sk_set_nospace(struct sock *sk);
+void sk_clear_nospace(struct sock *sk);
/* OOB backlog add */
static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 5e5f5f9b89a38..3389c51790e6b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -783,14 +783,42 @@ void tcp_done_with_error(struct sock *sk, int err);
void tcp_reset(struct sock *sk, struct sk_buff *skb);
void tcp_fin(struct sock *sk);
void __tcp_check_space(struct sock *sk);
+
+/* Mirror of SOCK_NOSPACE in tcp_sock, maintained by sk_set_nospace()
+ * and sk_clear_nospace().
+ *
+ * MPTCP subflows share the parent socket, and thus its SOCK_NOSPACE bit.
+ * Keep their mirror always set (see subflow_ulp_init()) so that they
+ * always reach __tcp_check_space() and behave as before.
+ */
+static inline void tcp_set_nospace(struct sock *sk)
+{
+ if (sk_is_tcp(sk)) {
+ /* pairs with smp_mb__before_atomic() in tcp_clear_nospace() */
+ smp_mb__after_atomic();
+ /* pairs with smp_mb() in tcp_check_space() */
+ smp_store_mb(tcp_sk(sk)->tcp_nospace, 1);
+ }
+}
+
+static inline void tcp_clear_nospace(struct sock *sk)
+{
+ if (sk_is_tcp(sk) && !sk_is_mptcp(sk)) {
+ WRITE_ONCE(tcp_sk(sk)->tcp_nospace, 0);
+ /* pairs with smp_mb__after_atomic() in tcp_set_nospace() */
+ smp_mb__before_atomic();
+ }
+}
+
static inline void tcp_check_space(struct sock *sk)
{
/* pairs with tcp_poll() */
smp_mb();
- if (sk->sk_socket && test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
+ if (unlikely(READ_ONCE(tcp_sk(sk)->tcp_nospace)))
__tcp_check_space(sk);
}
+
void tcp_sack_compress_send_ack(struct sock *sk);
static inline void tcp_cleanup_skb(struct sk_buff *skb)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 212e7797f9e48..cc7db8c61db37 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -375,7 +375,7 @@ static void ceph_sock_write_space(struct sock *sk)
if (ceph_con_flag_test(con, CEPH_CON_F_WRITE_PENDING)) {
if (sk_stream_is_writeable(sk)) {
dout("%s %p queueing write work\n", __func__, con);
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
queue_con(con);
}
} else {
diff --git a/net/core/sock.c b/net/core/sock.c
index 2948dffcc3e1b..946f614f665b3 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2957,6 +2957,48 @@ void sock_kzfree_s(struct sock *sk, void *mem, int size)
}
EXPORT_SYMBOL(sock_kzfree_s);
+/**
+ * sk_set_nospace - tell the transport a writer is waiting for space
+ * @sk: socket
+ *
+ * Must be called before the final check of the available send space,
+ * so that the transport can not miss the request and forget to call
+ * sk->sk_write_space() once space is available again.
+ */
+void sk_set_nospace(struct sock *sk)
+{
+ struct socket *sock = sk->sk_socket;
+
+ if (!sock)
+ return;
+ /* Set SOCK_NOSPACE before tp->tcp_nospace (paired with
+ * sk_clear_nospace() clearing tp->tcp_nospace before SOCK_NOSPACE)
+ * so a concurrent clear cannot leave SOCK_NOSPACE set with
+ * tp->tcp_nospace cleared.
+ */
+ set_bit(SOCK_NOSPACE, &sock->flags);
+ tcp_set_nospace(sk);
+}
+EXPORT_SYMBOL(sk_set_nospace);
+
+/**
+ * sk_clear_nospace - tell the transport no writer is waiting for space
+ * @sk: socket
+ *
+ * Called from ->sk_write_space() handlers, once send space has been
+ * made available to writers.
+ */
+void sk_clear_nospace(struct sock *sk)
+{
+ struct socket *sock = sk->sk_socket;
+
+ if (!sock)
+ return;
+ tcp_clear_nospace(sk);
+ clear_bit(SOCK_NOSPACE, &sock->flags);
+}
+EXPORT_SYMBOL(sk_clear_nospace);
+
/* It is almost wait_for_tcp_memory minus release_sock/lock_sock.
I think, these locks should be removed for datagram sockets.
*/
@@ -2970,7 +3012,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)
break;
if (signal_pending(current))
break;
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
if (refcount_read(&sk->sk_wmem_alloc) < READ_ONCE(sk->sk_sndbuf))
break;
@@ -3011,7 +3053,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
break;
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
err = -EAGAIN;
if (!timeo)
goto failure;
diff --git a/net/core/stream.c b/net/core/stream.c
index 2d748581862d0..a853b60afdc35 100644
--- a/net/core/stream.c
+++ b/net/core/stream.c
@@ -37,7 +37,7 @@ void sk_stream_write_space(struct sock *sk)
struct socket_wq *wq;
if (__sk_stream_is_writeable(sk, 1) && sock) {
- clear_bit(SOCK_NOSPACE, &sock->flags);
+ sk_clear_nospace(sk);
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
@@ -143,7 +143,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
if (sk_stream_memory_free(sk) && !vm_wait)
break;
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
sk->sk_write_pending++;
ret = sk_wait_event(sk, ¤t_timeo, READ_ONCE(sk->sk_err) ||
(READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN) ||
@@ -177,7 +177,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
* When TCP receives ACK packets that make room, tcp_check_space()
* only calls tcp_new_space() if SOCK_NOSPACE is set.
*/
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
err = -EAGAIN;
goto out;
do_interrupted:
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3ac4856852794..f44cbd3e76178 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -607,7 +607,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
mask |= EPOLLOUT | EPOLLWRNORM;
} else { /* send SIGIO later */
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
/* Race breaker. If space is freed after
* wspace test but before the flags are set,
@@ -1398,7 +1398,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
continue;
wait_for_space:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
tcp_remove_empty_skb(sk);
if (copied)
tcp_push(sk, flags & ~MSG_MORE, mss_now,
@@ -5242,6 +5242,7 @@ static void __init tcp_struct_check(void)
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, first_tx_mstamp);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, delivered_mstamp);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, snd_sml);
+ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, tcp_nospace);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, chrono_start);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, chrono_stat);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, write_seq);
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 2e234d155b5e6..64d74d92af52d 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -602,7 +602,7 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
goto out_err;
continue;
wait_for_sndbuf:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
wait_for_memory:
err = sk_stream_wait_memory(sk, &timeo);
if (err) {
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 892ff256e2352..cdea30d07fe2c 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6098,8 +6098,14 @@ static void tcp_new_space(struct sock *sk)
*/
void __tcp_check_space(struct sock *sk)
{
+ struct socket *sock = sk->sk_socket;
+
+ /* tp->tcp_nospace is only a hint, SOCK_NOSPACE is authoritative. */
+ if (!sock || !test_bit(SOCK_NOSPACE, &sock->flags))
+ return;
+
tcp_new_space(sk);
- if (!test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
+ if (!test_bit(SOCK_NOSPACE, &sock->flags))
tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);
}
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 71af69d442f21..b29c0ed9caf52 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -735,7 +735,7 @@ static void kcm_tx_work(struct work_struct *w)
/* Primarily for SOCK_SEQPACKET sockets */
if (likely(sk->sk_socket) &&
test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
sk->sk_write_space(sk);
}
@@ -779,7 +779,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
/* Call the sk_stream functions to manage the sndbuf mem. */
if (!sk_stream_memory_free(sk)) {
kcm_push(kcm);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
err = sk_stream_wait_memory(sk, &timeo);
if (err)
goto out_error;
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index e89a69ab927c9..74b1a51207287 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2106,7 +2106,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
continue;
wait_for_memory:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
__mptcp_push_pending(sk, msg->msg_flags);
ret = sk_stream_wait_memory(sk, &timeo);
if (ret)
@@ -4472,7 +4472,7 @@ static __poll_t mptcp_check_writeable(struct mptcp_sock *msk)
if (__mptcp_stream_is_writeable(sk, 1))
return EPOLLOUT | EPOLLWRNORM;
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
smp_mb__after_atomic(); /* NOSPACE is changed by mptcp_write_space() */
if (__mptcp_stream_is_writeable(sk, 1))
return EPOLLOUT | EPOLLWRNORM;
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index f0a6725d2c376..e297c88be503b 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -2001,6 +2001,11 @@ static int subflow_ulp_init(struct sock *sk)
pr_debug("subflow=%p, family=%d\n", ctx, sk->sk_family);
tp->is_mptcp = 1;
+ /* Subflows share the MPTCP socket, and thus its SOCK_NOSPACE bit,
+ * which tcp_check_space() can not mirror. Pin the mirror so that
+ * __tcp_check_space() always tests the shared bit.
+ */
+ tp->tcp_nospace = 1;
ctx->icsk_af_ops = icsk->icsk_af_ops;
icsk->icsk_af_ops = subflow_default_af_ops(sk);
ctx->tcp_state_change = sk->sk_state_change;
diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
index 7c52acc749cf4..824222c475119 100644
--- a/net/rds/tcp_send.c
+++ b/net/rds/tcp_send.c
@@ -100,7 +100,7 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
if (hdr_off < sizeof(struct rds_header)) {
/* see rds_tcp_write_space() */
- set_bit(SOCK_NOSPACE, &tc->t_sock->sk->sk_socket->flags);
+ sk_set_nospace(tc->t_sock->sk);
ret = rds_tcp_sendmsg(tc->t_sock,
(void *)&rm->m_inc.i_hdr + hdr_off,
@@ -221,6 +221,5 @@ void rds_tcp_write_space(struct sock *sk)
*/
write_space(sk);
- if (sk->sk_socket)
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
}
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index e9f93b3ab435b..4f2afbbdef2d7 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2919,7 +2919,7 @@ __poll_t smc_poll(struct file *file, struct socket *sock,
mask |= EPOLLOUT | EPOLLWRNORM;
} else {
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
if (sk->sk_state != SMC_INIT) {
/* Race breaker the same way as tcp_poll(). */
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index 3144b4b1fe290..52e5395484fd3 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -48,7 +48,7 @@ static void smc_tx_write_space(struct sock *sk)
if (atomic_read(&smc->conn.sndbuf_space) && sock) {
if (test_bit(SOCK_NOSPACE, &sock->flags))
SMC_STAT_RMB_TX_FULL(smc, !smc->conn.lnk);
- clear_bit(SOCK_NOSPACE, &sock->flags);
+ sk_clear_nospace(sk);
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (skwq_has_sleeper(wq))
@@ -100,7 +100,7 @@ static int smc_tx_wait(struct smc_sock *smc, int flags)
}
if (!timeo) {
/* ensure EPOLLOUT is subsequently generated */
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
rc = -EAGAIN;
break;
}
@@ -111,7 +111,7 @@ static int smc_tx_wait(struct smc_sock *smc, int flags)
sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
if (atomic_read(&conn->sndbuf_space) && !conn->urg_tx_pend)
break; /* at least 1 byte of free & no urgent data */
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
sk_wait_event(sk, &timeo,
READ_ONCE(sk->sk_err) ||
(READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN) ||
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 50e5e7f5b762d..2d8cdee0798d5 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -792,11 +792,11 @@ static int svc_udp_has_wspace(struct svc_xprt *xprt)
* Set the SOCK_NOSPACE flag before checking the available
* sock space.
*/
- set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
+ sk_set_nospace(svsk->sk_sk);
required = atomic_read(&svsk->sk_xprt.xpt_reserved) + serv->sv_max_mesg;
if (required*2 > sock_wspace(svsk->sk_sk))
return 0;
- clear_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
+ sk_clear_nospace(svsk->sk_sk);
return 1;
}
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 7f60723fa64d8..b97c70c12f627 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -858,7 +858,7 @@ static int xs_nospace(struct rpc_rqst *req, struct sock_xprt *transport)
if (xprt_connected(xprt)) {
/* wait for more buffer space */
set_bit(XPRT_SOCK_NOSPACE, &transport->sock_state);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
sk->sk_write_pending++;
xprt_wait_for_buffer_space(xprt);
} else
@@ -1615,7 +1615,7 @@ static void xs_write_space(struct sock *sk)
if (!sk->sk_socket)
return;
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
if (unlikely(!(xprt = xprt_from_sock(sk))))
return;
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index d1ad31986cf2c..312e51270f293 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -966,7 +966,7 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,
continue;
wait_for_sndbuf:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
wait_for_memory:
ret = sk_stream_wait_memory(sk, &timeo);
if (ret) {
|
| 3/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 11220 output: 26 thoughts: 710 Thoughts: **Fuzzing Evaluation: A Deep Dive** Okay, so I've got a patch series here, and the question is whether it justifies a syzkaller fuzzing run. Let's break this down systematically, keeping in mind the architecture is AMD64 and that the changes are already committed at HEAD. My triage philosophy is going to be my guiding star here: reachability is the primary concern. I'm not blindly accepting "no functional change" or "refactoring" claims; I'm going to look under the hood. Any new or modified assertions within reachable code *demand* fuzzing. And, of course, any modifications to core subsystems are automatically red flags. Alright, let's dive into the patch itself. Woah, this is extensive – looks like it's deeply touching core networking: `Documentation/networking/net_cachelines/tcp_sock.rst`, `drivers/block/drbd/drbd_worker.c`, `drivers/nvme/host/tcp.c`, `drivers/nvme/target/tcp.c`, `fs/dlm/lowcomms.c`, `include/linux/tcp.h`, `include/net/sock.h`, `include/net/tcp.h`, `net/ceph/messenger.c`, `net/core/sock.c`, `net/core/stream.c`, `net/ipv4/tcp.c`, `net/ipv4/tcp_bpf.c`, `net/ipv4/tcp_input.c`, `net/kcm/kcmsock.c`, `net/mptcp/protocol.c`, `net/mptcp/subflow.c`, `net/rds/tcp_send.c`, `net/smc/af_smc.c`, `net/smc/smc_tx.c`, `net/sunrpc/svcsock.c`, `net/sunrpc/xprtsock.c`, `net/tls/tls_sw.c`. That's a *lot* of ground to cover. Specifically, it looks like they're introducing a `tcp_nospace` field to `struct tcp_sock`, along with helper functions like `sk_set_nospace()`, `sk_clear_nospace()`, `tcp_set_nospace()`, `tcp_clear_nospace()`, and, critically, modifying `tcp_check_space()` to use `READ_ONCE(tcp_sk(sk)->tcp_nospace)` instead of the socket flags check. This change then ripples through a large number of socket-related files across TCP, KCM, MPTCP, TLS and so on. Now, from a safety perspective, I need to evaluate the request. This is benign software maintenance, developer QA, fuzzing triage – the goal is safety, so I can fully address the needs of this inquiry. My next step is to get some more information from the commit and code using `grepper`, `codesearch-dir-index`, `read-file`, or the `set-results` tool. I need to get a better sense of what these changes *really* mean in practice. I need to dig deeper into the actual code modification. Let's see what the commit details and the source files tell me. This definitely warrants a closer look. |
| 4/2 | 2026/09/26 18:43 | tool | grepper |
0mArgs:{
"Expression": "tcp_nospace",
"PathPrefix": "include/"
}Results: {
"Output": "include/linux/tcp.h=197=struct tcp_sock {\n--\ninclude/linux/tcp.h-271-\tu8\tchrono_type;\t/* current chronograph type */\ninclude/linux/tcp.h:272:\tu8\ttcp_nospace;\t/* mirrors SOCK_NOSPACE, must be set whenever\ninclude/linux/tcp.h-273-\t\t\t\t * SOCK_NOSPACE is set.\n--\ninclude/net/tcp.h=794=static inline void tcp_set_nospace(struct sock *sk)\n--\ninclude/net/tcp.h-799-\t\t/* pairs with smp_mb() in tcp_check_space() */\ninclude/net/tcp.h:800:\t\tsmp_store_mb(tcp_sk(sk)-\u003etcp_nospace, 1);\ninclude/net/tcp.h-801-\t}\n--\ninclude/net/tcp.h=804=static inline void tcp_clear_nospace(struct sock *sk)\n--\ninclude/net/tcp.h-806-\tif (sk_is_tcp(sk) \u0026\u0026 !sk_is_mptcp(sk)) {\ninclude/net/tcp.h:807:\t\tWRITE_ONCE(tcp_sk(sk)-\u003etcp_nospace, 0);\ninclude/net/tcp.h-808-\t\t/* pairs with smp_mb__after_atomic() in tcp_set_nospace() */\n--\ninclude/net/tcp.h=813=static inline void tcp_check_space(struct sock *sk)\n--\ninclude/net/tcp.h-817-\ninclude/net/tcp.h:818:\tif (unlikely(READ_ONCE(tcp_sk(sk)-\u003etcp_nospace)))\ninclude/net/tcp.h-819-\t\t__tcp_check_space(sk);\n"
} |
| 5/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13139 output: 36 thoughts: 30 Thoughts: Okay, here's my take on those changes: **Analyzing the Network Core Patchset** Alright, time to dig in. Given the recent flurry of network performance discussions, I figure I need to get a handle on what's actually *changed* at the kernel level. Specifically, I'm going to start by reviewing the patch changes in `net/core/sock.c` and `net/ipv4/tcp_input.c`. These are central to socket operations and TCP data handling, so modifications there are likely to have a cascading impact. I expect to see optimizations, bug fixes, or potentially new features related to things like connection establishment, data throughput, congestion control, or even security. I need to understand the rationale behind each of these changes and whether they are in line with best practices. I'll be looking carefully at the data structures, function calls, and any new locking mechanisms introduced. I'm especially interested in performance-related updates, and will be looking to assess whether the changes introduce any bottlenecks or race conditions. |
| 6/2 | 2026/09/26 18:43 | tool | read-file |
0mArgs:{
"File": "net/core/sock.c",
"FirstLine": 2955,
"LineCount": 45
}Results: {
"Contents": "2955:\t{\n2956:\t\t__sock_kfree_s(sk, mem, size, true);\n2957:\t}\n2958:\tEXPORT_SYMBOL(sock_kzfree_s);\n2959:\t\n2960:\t/**\n2961:\t *\tsk_set_nospace - tell the transport a writer is waiting for space\n2962:\t *\t@sk: socket\n2963:\t *\n2964:\t *\tMust be called before the final check of the available send space,\n2965:\t *\tso that the transport can not miss the request and forget to call\n2966:\t *\tsk-\u003esk_write_space() once space is available again.\n2967:\t */\n2968:\tvoid sk_set_nospace(struct sock *sk)\n2969:\t{\n2970:\t\tstruct socket *sock = sk-\u003esk_socket;\n2971:\t\n2972:\t\tif (!sock)\n2973:\t\t\treturn;\n2974:\t\t/* Set SOCK_NOSPACE before tp-\u003etcp_nospace (paired with\n2975:\t\t * sk_clear_nospace() clearing tp-\u003etcp_nospace before SOCK_NOSPACE)\n2976:\t\t * so a concurrent clear cannot leave SOCK_NOSPACE set with\n2977:\t\t * tp-\u003etcp_nospace cleared.\n2978:\t\t */\n2979:\t\tset_bit(SOCK_NOSPACE, \u0026sock-\u003eflags);\n2980:\t\ttcp_set_nospace(sk);\n2981:\t}\n2982:\tEXPORT_SYMBOL(sk_set_nospace);\n2983:\t\n2984:\t/**\n2985:\t *\tsk_clear_nospace - tell the transport no writer is waiting for space\n2986:\t *\t@sk: socket\n2987:\t *\n2988:\t *\tCalled from -\u003esk_write_space() handlers, once send space has been\n2989:\t *\tmade available to writers.\n2990:\t */\n2991:\tvoid sk_clear_nospace(struct sock *sk)\n2992:\t{\n2993:\t\tstruct socket *sock = sk-\u003esk_socket;\n2994:\t\n2995:\t\tif (!sock)\n2996:\t\t\treturn;\n2997:\t\ttcp_clear_nospace(sk);\n2998:\t\tclear_bit(SOCK_NOSPACE, \u0026sock-\u003eflags);\n2999:\t}\n"
} |
| 7/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14089 output: 39 thoughts: 18 Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own: **Analyzing `net/ipv4/tcp_input.c`** Alright, given what we've been discussing, it's time to dig into the heart of the matter. We need to dissect `net/ipv4/tcp_input.c`. That file is absolutely critical; it's where the rubber meets the road for incoming TCP traffic in the IPv4 stack. I want to see how the kernel handles received segments. I'm especially curious about the interactions with congestion control, retransmission logic, and of course, how it handles the various TCP flags. It's the central point for everything from basic ACK processing to more complex tasks like window scaling and selective ACKs. We need to analyze the error handling and security aspects that file provides, as well. |
| 8/2 | 2026/09/26 18:43 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp_input.c",
"FirstLine": 6090,
"LineCount": 30
}Results: {
"Contents": "6090:\t * 1) Freeing skbs in rtx queues (after tp-\u003esnd_una has advanced)\n6091:\t * 2) Sent skbs from output queue (and thus advancing tp-\u003esnd_nxt)\n6092:\t *\n6093:\t * We might be able to generate EPOLLOUT to the application if:\n6094:\t * 1) Space consumed in output/rtx queues is below sk-\u003esk_sndbuf/2\n6095:\t * 2) notsent amount (tp-\u003ewrite_seq - tp-\u003esnd_nxt) became\n6096:\t * small enough that tcp_stream_memory_free() decides it\n6097:\t * is time to generate EPOLLOUT.\n6098:\t */\n6099:\tvoid __tcp_check_space(struct sock *sk)\n6100:\t{\n6101:\t\tstruct socket *sock = sk-\u003esk_socket;\n6102:\t\n6103:\t\t/* tp-\u003etcp_nospace is only a hint, SOCK_NOSPACE is authoritative. */\n6104:\t\tif (!sock || !test_bit(SOCK_NOSPACE, \u0026sock-\u003eflags))\n6105:\t\t\treturn;\n6106:\t\n6107:\t\ttcp_new_space(sk);\n6108:\t\tif (!test_bit(SOCK_NOSPACE, \u0026sock-\u003eflags))\n6109:\t\t\ttcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);\n6110:\t}\n6111:\t\n6112:\tstatic inline void tcp_data_snd_check(struct sock *sk)\n6113:\t{\n6114:\t\ttcp_push_pending_frames(sk);\n6115:\t\ttcp_check_space(sk);\n6116:\t}\n6117:\t\n6118:\t/*\n6119:\t * Check if sending an ack is needed.\n"
} |
| 9/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14844 output: 39 thoughts: 37 Thoughts: Okay, let's dive into this. Here's how I'd approach this task, as if these were my internal thoughts: **Analyzing MPTCP Subflow and Protocol Behavior** Right, so we need to understand how the changes we're looking at impact MPTCP. My initial instinct is to go straight to the core: `net/mptcp/subflow.c` and `net/mptcp/protocol.c`. That's where the heart of the subflow management and the overall MPTCP protocol implementation will reside. By examining these two, we should be able to get a pretty clear picture of how whatever the changes are, are affecting the established behaviour. It's the most efficient way to start, as they are the foundational pieces. Let's see what we find. |
| 10/2 | 2026/09/26 18:43 | tool | read-file |
0mArgs:{
"File": "net/mptcp/subflow.c",
"FirstLine": 1995,
"LineCount": 25
}Results: {
"Contents": "1995:\t\tctx = subflow_create_ctx(sk, GFP_KERNEL);\n1996:\t\tif (!ctx) {\n1997:\t\t\terr = -ENOMEM;\n1998:\t\t\tgoto out;\n1999:\t\t}\n2000:\t\n2001:\t\tpr_debug(\"subflow=%p, family=%d\\n\", ctx, sk-\u003esk_family);\n2002:\t\n2003:\t\ttp-\u003eis_mptcp = 1;\n2004:\t\t/* Subflows share the MPTCP socket, and thus its SOCK_NOSPACE bit,\n2005:\t\t * which tcp_check_space() can not mirror. Pin the mirror so that\n2006:\t\t * __tcp_check_space() always tests the shared bit.\n2007:\t\t */\n2008:\t\ttp-\u003etcp_nospace = 1;\n2009:\t\tctx-\u003eicsk_af_ops = icsk-\u003eicsk_af_ops;\n2010:\t\ticsk-\u003eicsk_af_ops = subflow_default_af_ops(sk);\n2011:\t\tctx-\u003etcp_state_change = sk-\u003esk_state_change;\n2012:\t\tctx-\u003etcp_error_report = sk-\u003esk_error_report;\n2013:\t\n2014:\t\tWARN_ON_ONCE(sk-\u003esk_data_ready != sock_def_readable);\n2015:\t\tWARN_ON_ONCE(sk-\u003esk_write_space != sk_stream_write_space);\n2016:\t\n2017:\t\tsk-\u003esk_data_ready = subflow_data_ready;\n2018:\t\tsk-\u003esk_write_space = subflow_write_space;\n2019:\t\tsk-\u003esk_state_change = subflow_state_change;\n"
} |
| 11/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15569 output: 25 thoughts: 637 Thoughts: **My Assessment of the TCP/Socket Write Space Optimization Patch** Okay, so this patch is a significant optimization and refactoring concerning TCP and socket write space notifications. My initial impression is that it's going to be pretty impactful given the scope of the change. The problem they're addressing is the cache line bouncing caused by dereferencing `sk->sk_socket` every time there's an ACK or space check. A good fix. The introduction of `tcp_nospace` within `struct tcp_sock`, and the associated helper functions (`sk_set_nospace()`, `sk_clear_nospace()`) is a clever way to avoid that and seems pretty clean, although of course, it touches a lot of code, and that's something to examine very carefully. This touches core socket routines like `sock_wait_for_wmem`, and `sock_alloc_send_pskb`, all the stream routines (`sk_stream_write_space`, `sk_stream_wait_memory`), TCP routines (`tcp_poll`, `tcp_sendmsg_locked`, `tcp_struct_check`, `__tcp_check_space`), and even downstream subsystems like KCM, MPTCP, TLS, Ceph, SMC, SunRPC, DRBD, and NVMe-TCP. That's a lot of surface area! It's introducing new synchronization and memory ordering barriers. I see `smp_mb__after_atomic()`, `smp_store_mb(tcp_sk(sk)->tcp_nospace, 1)`, `smp_mb__before_atomic()`, and all those memory barrier primitives. I also see `READ_ONCE` and `WRITE_ONCE` and lockless reads/writes to `tcp_nospace`. So, there's definitely a concurrency aspect to consider. Plus, it looks like there are cacheline assertions. Clearly, there's a lot of work in this patch, and a lot of subtle concurrency issues that could arise. Considering my area of expertise, I see that this modification falls right into Section 3: Core Subsystems and Refactorings. Memory management, synchronization, core networking, and reachable code. Standard TCP sockets, MPTCP, TLS, and SMC are all directly involved. Given that these are highly reachable from userspace fuzzing, *WorthFuzzing = true* seems like the correct call! Now, the important part: setting up the fuzzing environment. I need to figure out the enabling configurations. I'm going to need `INET` (or `NET`) for the core TCP/IP code. Then, `MPTCP` for MPTCP. I'll need to dig into the `Kconfig` files for MPTCP, IPv4, TLS, SMC, and others to see the exact dependencies. The important thing is to distinguish between what enables the *core* change and what's required for the additional subsystems. Grepping for the relevant config requirements within those Kconfig files is the next step. |
| 12/2 | 2026/09/26 18:43 | tool | grepper |
0mArgs:{
"Expression": "config INET",
"PathPrefix": "net/"
}Results: {
"Output": "net/Kconfig=98=config NET_HANDSHAKE_KUNIT_TEST\n--\nnet/Kconfig-112-\nnet/Kconfig:113:config INET\nnet/Kconfig-114-\tbool \"TCP/IP networking\"\n--\nnet/ipv4/Kconfig=330=config NET_FOU_IP_TUNNELS\n--\nnet/ipv4/Kconfig-338-\nnet/ipv4/Kconfig:339:config INET_AH\nnet/ipv4/Kconfig-340-\ttristate \"IP: AH transformation\"\n--\nnet/ipv4/Kconfig-353-\nnet/ipv4/Kconfig:354:config INET_ESP\nnet/ipv4/Kconfig-355-\ttristate \"IP: ESP transformation\"\n--\nnet/ipv4/Kconfig-368-\nnet/ipv4/Kconfig:369:config INET_ESP_OFFLOAD\nnet/ipv4/Kconfig-370-\ttristate \"IP: ESP transformation offload\"\n--\nnet/ipv4/Kconfig-381-\nnet/ipv4/Kconfig:382:config INET_ESPINTCP\nnet/ipv4/Kconfig-383-\tbool \"IP: ESP in TCP encapsulation (RFC 8229)\"\n--\nnet/ipv4/Kconfig-393-\nnet/ipv4/Kconfig:394:config INET_IPCOMP\nnet/ipv4/Kconfig-395-\ttristate \"IP: IPComp transformation\"\n--\nnet/ipv4/Kconfig-403-\nnet/ipv4/Kconfig:404:config INET_TABLE_PERTURB_ORDER\nnet/ipv4/Kconfig-405-\tint \"INET: Source port perturbation table size (as power of 2)\" if EXPERT\n--\nnet/ipv4/Kconfig-413-\nnet/ipv4/Kconfig:414:config INET_XFRM_TUNNEL\nnet/ipv4/Kconfig-415-\ttristate\n--\nnet/ipv4/Kconfig-418-\nnet/ipv4/Kconfig:419:config INET_TUNNEL\nnet/ipv4/Kconfig-420-\ttristate\n--\nnet/ipv4/Kconfig-422-\nnet/ipv4/Kconfig:423:config INET_DIAG\nnet/ipv4/Kconfig-424-\ttristate \"INET: socket monitoring interface\"\n--\nnet/ipv4/Kconfig-434-\nnet/ipv4/Kconfig:435:config INET_TCP_DIAG\nnet/ipv4/Kconfig-436-\tdepends on INET_DIAG\n--\nnet/ipv4/Kconfig-438-\nnet/ipv4/Kconfig:439:config INET_UDP_DIAG\nnet/ipv4/Kconfig-440-\ttristate \"UDP: socket monitoring interface\"\n--\nnet/ipv4/Kconfig-446-\nnet/ipv4/Kconfig:447:config INET_RAW_DIAG\nnet/ipv4/Kconfig-448-\ttristate \"RAW: socket monitoring interface\"\n--\nnet/ipv4/Kconfig-454-\nnet/ipv4/Kconfig:455:config INET_DIAG_DESTROY\nnet/ipv4/Kconfig-456-\tbool \"INET: allow privileged process to administratively close sockets\"\n--\nnet/ipv6/Kconfig=39=config IPV6_OPTIMISTIC_DAD\n--\nnet/ipv6/Kconfig-46-\nnet/ipv6/Kconfig:47:config INET6_AH\nnet/ipv6/Kconfig-48-\ttristate \"IPv6: AH transformation\"\n--\nnet/ipv6/Kconfig-61-\nnet/ipv6/Kconfig:62:config INET6_ESP\nnet/ipv6/Kconfig-63-\ttristate \"IPv6: ESP transformation\"\n--\nnet/ipv6/Kconfig-76-\nnet/ipv6/Kconfig:77:config INET6_ESP_OFFLOAD\nnet/ipv6/Kconfig-78-\ttristate \"IPv6: ESP transformation offload\"\n--\nnet/ipv6/Kconfig-89-\nnet/ipv6/Kconfig:90:config INET6_ESPINTCP\nnet/ipv6/Kconfig-91-\tbool \"IPv6: ESP in TCP encapsulation (RFC 8229)\"\n--\nnet/ipv6/Kconfig-101-\nnet/ipv6/Kconfig:102:config INET6_IPCOMP\nnet/ipv6/Kconfig-103-\ttristate \"IPv6: IPComp transformation\"\n--\nnet/ipv6/Kconfig=120=config IPV6_ILA\n--\nnet/ipv6/Kconfig-140-\nnet/ipv6/Kconfig:141:config INET6_XFRM_TUNNEL\nnet/ipv6/Kconfig-142-\ttristate\n--\nnet/ipv6/Kconfig-145-\nnet/ipv6/Kconfig:146:config INET6_TUNNEL\nnet/ipv6/Kconfig-147-\ttristate\n--\nnet/mptcp/Kconfig=14=if MPTCP\nnet/mptcp/Kconfig-15-\nnet/mptcp/Kconfig:16:config INET_MPTCP_DIAG\nnet/mptcp/Kconfig-17-\tdepends on INET_DIAG\n--\nnet/psp/Kconfig-4-#\nnet/psp/Kconfig:5:config INET_PSP\nnet/psp/Kconfig-6-\tbool \"PSP Security Protocol support\"\n--\nnet/sctp/Kconfig=68=endchoice\nnet/sctp/Kconfig-69-\nnet/sctp/Kconfig:70:config INET_SCTP_DIAG\nnet/sctp/Kconfig-71-\tdepends on INET_DIAG\n"
} |
| 13/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18382 output: 30 thoughts: 14 Thoughts: Here's a summary of my thought process, as requested: **Navigating the MPTCP Configuration Landscape** Okay, so I need to get a handle on the MultiPath TCP configuration options. Where would those be defined? Obviously, the kernel's Kconfig files are the place to go. Let's see...I'll check the relevant directory. Specifically, I should be looking at `net/mptcp/Kconfig`. That should give me the entry point I need to understand what's configurable, what dependencies there might be, and the default states for all the MPTCP features. Time to dig in and see what's what. This `Kconfig` file should give me a solid overview of the MPTCP configuration space. |
| 14/2 | 2026/09/26 18:43 | tool | grepper |
0mArgs:{
"Expression": "config MPTCP",
"PathPrefix": "net/mptcp/"
}Results: {
"Output": "net/mptcp/Kconfig-1-\nnet/mptcp/Kconfig:2:config MPTCP\nnet/mptcp/Kconfig-3-\tbool \"MPTCP: Multipath TCP\"\n--\nnet/mptcp/Kconfig=16=config INET_MPTCP_DIAG\n--\nnet/mptcp/Kconfig-19-\nnet/mptcp/Kconfig:20:config MPTCP_IPV6\nnet/mptcp/Kconfig-21-\tbool \"MPTCP: IPv6 support for Multipath TCP\"\n--\nnet/mptcp/Kconfig-24-\nnet/mptcp/Kconfig:25:config MPTCP_KUNIT_TEST\nnet/mptcp/Kconfig-26-\ttristate \"This builds the MPTCP KUnit tests\" if !KUNIT_ALL_TESTS\n"
} |
| 15/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18807 output: 29 thoughts: 85 Thoughts: Here's my understanding of the situation, tailored for my fellow expert: **Investigating Recent Network Infrastructure Changes** Okay, so the core of the recent work seems to be a significant revamp of the foundational TCP and socket infrastructure within the `INET` module. That's where the heavy lifting is happening. It appears they are also making targeted adjustments for MPTCP specifically, with dedicated sections in `net/mptcp/subflow.c` and header file changes in `include/net/tcp.h` – namely around the functions `sk_is_mptcp(sk)` and `tp->tcp_nospace = 1`. The fact that `sk_is_mptcp` is being used catches my eye. Time to dig deeper into what this `sk_is_mptcp` function actually does. I'm guessing it will be a key indicator for checking for MPTCP sockets. This whole area deserves a more detailed review. |
| 16/2 | 2026/09/26 18:43 | tool | grepper |
0mArgs:{
"Expression": "sk_is_mptcp",
"PathPrefix": "include/"
}Results: {
"Output": "include/net/mptcp.h=130=void mptcp_init(void);\ninclude/net/mptcp.h-131-\ninclude/net/mptcp.h:132:static inline bool sk_is_mptcp(const struct sock *sk)\ninclude/net/mptcp.h-133-{\n--\ninclude/net/mptcp.h-136-\ninclude/net/mptcp.h:137:static inline bool rsk_is_mptcp(const struct request_sock *req)\ninclude/net/mptcp.h-138-{\n--\ninclude/net/mptcp.h=236=static inline void mptcp_init(void)\n--\ninclude/net/mptcp.h-239-\ninclude/net/mptcp.h:240:static inline bool sk_is_mptcp(const struct sock *sk)\ninclude/net/mptcp.h-241-{\n--\ninclude/net/mptcp.h-244-\ninclude/net/mptcp.h:245:static inline bool rsk_is_mptcp(const struct request_sock *req)\ninclude/net/mptcp.h-246-{\n--\ninclude/net/tcp.h=804=static inline void tcp_clear_nospace(struct sock *sk)\ninclude/net/tcp.h-805-{\ninclude/net/tcp.h:806:\tif (sk_is_tcp(sk) \u0026\u0026 !sk_is_mptcp(sk)) {\ninclude/net/tcp.h-807-\t\tWRITE_ONCE(tcp_sk(sk)-\u003etcp_nospace, 0);\n--\ninclude/net/tcp.h=1984=static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd)\n--\ninclude/net/tcp.h-1988-\t/* mptcp hooks are only on the slow path */\ninclude/net/tcp.h:1989:\tif (sk_is_mptcp((struct sock *)tp))\ninclude/net/tcp.h-1990-\t\treturn;\n"
} |
| 17/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19680 output: 31 thoughts: 83 Thoughts: Okay, let's get down to brass tacks. **Investigating MPTCP Kernel Configuration Dependencies** Alright, I need to understand the dependencies for `net/mptcp/Kconfig`. First, confirm that `config MPTCP` relies on `INET`. Yup, as expected, it's built on that fundamental `INET` layer, which is essentially the bedrock of TCP. Now, what's the story with `TCP_BPF`? I'll need to check how `net/ipv4/tcp_bpf.c` is being compiled. Let's see what's actually depending on it, so I can understand the configuration path. |
| 18/2 | 2026/09/26 18:43 | tool | grepper |
0mArgs:{
"Expression": "tcp_bpf\\.o",
"PathPrefix": "net/ipv4/"
}Results: {
"Output": "net/ipv4/Makefile=62=obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o\nnet/ipv4/Makefile:63:obj-$(CONFIG_NET_SOCK_MSG) += tcp_bpf.o\nnet/ipv4/Makefile-64-obj-$(CONFIG_BPF_SYSCALL) += udp_bpf.o\n"
} |
| 19/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20039 output: 28 thoughts: 11 Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience, and written in the first person: **Diving into Network Socket Messaging** Alright, time to dig into this. My initial thought is to zero in on `NET_SOCK_MSG`. This suggests a specific area of interest: network socket messaging. This could be anything from examining the implementation of a particular message type, debugging a socket communication issue, or perhaps even profiling the overhead of different message passing strategies. My expertise immediately tells me I need to look for where `NET_SOCK_MSG` is defined, how it's used, and what context it's relevant to. The possibilities are vast! |
| 20/2 | 2026/09/26 18:43 | tool | grepper |
0mArgs:{
"Expression": "config NET_SOCK_MSG",
"PathPrefix": "net/"
}Results: {
"Output": "net/Kconfig=474=config NET_SELFTESTS\n--\nnet/Kconfig-477-\nnet/Kconfig:478:config NET_SOCK_MSG\nnet/Kconfig-479-\tbool\n"
} |
| 21/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20291 output: 26 thoughts: 13 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Analyzing the Selection of `NET_SOCK_MSG`** Alright, let's dive in. My immediate thought is, "What precisely triggered the selection of `NET_SOCK_MSG`?" I need to understand the context. This isn't just a random event; it's a specific signal, and I need to trace back the execution path to pinpoint the root cause. My brain is already starting to formulate a mental map of potential code locations: the networking stack, the socket creation/manipulation routines, the relevant interrupt handlers (if applicable), and any user-space processes interacting with the socket. I'm thinking about the data structures involved, specifically the socket structures, any associated message queues, and the internal state of the networking subsystem. Does this selection relate to a specific socket operation – `send`, `recv`, `accept`, `connect` – or is it something more general like a socket event? I'm already mentally constructing queries to run through the code, searching for references to the `NET_SOCK_MSG` symbol and its related constants or macros. I'm also considering the potential layers of abstraction. Is this a raw socket, a TCP socket, a UDP socket, or something else entirely? The type of socket dramatically influences the selection process. I need to keep the various protocol details in mind so I do not miss any relevant details. I also need to make sure I note if this is a user-mode or kernel-mode event. In addition, I will be searching for the conditions that result in this particular message. Is it related to buffering, flow control, or congestion? Is there a race condition? Is the system under heavy load? These external factors can drastically change the system. |
| 22/2 | 2026/09/26 18:43 | tool | grepper |
0mArgs:{
"Expression": "select NET_SOCK_MSG",
"PathPrefix": ""
}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=360=config BPF_STREAM_PARSER\n--\nnet/Kconfig-365-\tselect STREAM_PARSER\nnet/Kconfig:366:\tselect NET_SOCK_MSG\nnet/Kconfig-367-\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"
} |
| 23/2 | 2026/09/26 18:43 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21099 output: 27 thoughts: 1054 Thoughts: **Focusing on Socket Space Management**
Okay, so I'm diving into this code with `BPF_SYSCALL`, `TLS`, `MPTCP`, and `INET` as potential areas of interest. The `INET` (and `MPTCP`) subsystem seems to be the core here. Now, I need to pinpoint the critical functions that have been modified or introduced.
Looking at the code, I see a number of symbols popping up: `sk_set_nospace`, `sk_clear_nospace` in `net/core/sock.c`, the static inlines `tcp_set_nospace`, `tcp_clear_nospace`, and `tcp_check_space` in `include/net/tcp.h`, and `__tcp_check_space` in `net/ipv4/tcp_input.c`. There's also `tcp_poll`, `tcp_sendmsg_locked` in `net/ipv4/tcp.c`, `sk_stream_write_space`, `sk_stream_wait_memory` in `net/core/stream.c`, `mptcp_sendmsg`, `mptcp_check_writeable` in `net/mptcp/protocol.c`, and `subflow_ulp_init` in `net/mptcp/subflow.c`.
Now, according to the rule, I need to be careful not to dilute my focus with ubiquitous functions. I need to target the specific feature logic and entry points. So, I need to filter.
Let's evaluate each function's relevance. `sk_set_nospace` and `sk_clear_nospace` are definitely not ubiquitous; they are tied to socket space exhaustion and availability respectively. `__tcp_check_space` seems important because it's the core function altered in `net/ipv4/tcp_input.c`. What about `sk_stream_write_space`, `sk_stream_wait_memory`, `mptcp_check_writeable`, and `subflow_ulp_init`? They might be important. Finally `tcp_bpf_sendmsg`.
Let me examine `__tcp_check_space`.
```c
void __tcp_check_space(struct sock *sk)
{
struct socket *sock = sk->sk_socket;
/* tp->tcp_nospace is only a hint, SOCK_NOSPACE is authoritative. */
if (!sock || !test_bit(SOCK_NOSPACE, &sock->flags))
return;
tcp_new_space(sk);
if (!test_bit(SOCK_NOSPACE, &sock->flags))
tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);
}
```
Okay, it seems that this function checks for socket space and then calls `tcp_new_space`. It looks like it is checking the `SOCK_NOSPACE` flag. But where is `__tcp_check_space` called from? Looking at `include/net/tcp.h`, I find:
```c
static inline void tcp_check_space(struct sock *sk)
{
/* pairs with tcp_poll() */
smp_mb();
if (unlikely(READ_ONCE(tcp_sk(sk)->tcp_nospace)))
__tcp_check_space(sk);
}
```
So `__tcp_check_space` is called by the inline function `tcp_check_space`. Now I need to see where `tcp_check_space` is called. Let's grep for that.
|
| 24/2 | 2026/09/26 18:44 | tool | grepper |
0mArgs:{
"Expression": "tcp_check_space",
"PathPrefix": "net/"
}Results: {
"Output": "net/ceph/messenger.c=364=static void ceph_sock_write_space(struct sock *sk)\n--\nnet/ceph/messenger.c-371-\t * doesn't get called again until ceph_con_v[12]_try_write() fills\nnet/ceph/messenger.c:372:\t * the socket buffer. See net/ipv4/tcp_input.c:tcp_check_space()\nnet/ceph/messenger.c-373-\t * and net/core/stream.c:sk_stream_write_space().\n--\nnet/core/stream.c=121=int sk_stream_wait_memory(struct sock *sk, long *timeo_p)\n--\nnet/core/stream.c-176-\t * be generated later.\nnet/core/stream.c:177:\t * When TCP receives ACK packets that make room, tcp_check_space()\nnet/core/stream.c-178-\t * only calls tcp_new_space() if SOCK_NOSPACE is set.\n--\nnet/ipv4/tcp_input.c=6075=static void tcp_new_space(struct sock *sk)\n--\nnet/ipv4/tcp_input.c-6098- */\nnet/ipv4/tcp_input.c:6099:void __tcp_check_space(struct sock *sk)\nnet/ipv4/tcp_input.c-6100-{\n--\nnet/ipv4/tcp_input.c=6112=static inline void tcp_data_snd_check(struct sock *sk)\n--\nnet/ipv4/tcp_input.c-6114-\ttcp_push_pending_frames(sk);\nnet/ipv4/tcp_input.c:6115:\ttcp_check_space(sk);\nnet/ipv4/tcp_input.c-6116-}\n--\nnet/ipv4/tcp_output.c=83=static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/tcp_output.c-102-\t\t tcp_skb_pcount(skb));\nnet/ipv4/tcp_output.c:103:\ttcp_check_space(sk);\nnet/ipv4/tcp_output.c-104-}\n--\nnet/mptcp/subflow.c=1980=static int subflow_ulp_init(struct sock *sk)\n--\nnet/mptcp/subflow.c-2004-\t/* Subflows share the MPTCP socket, and thus its SOCK_NOSPACE bit,\nnet/mptcp/subflow.c:2005:\t * which tcp_check_space() can not mirror. Pin the mirror so that\nnet/mptcp/subflow.c:2006:\t * __tcp_check_space() always tests the shared bit.\nnet/mptcp/subflow.c-2007-\t */\n--\nnet/smc/smc_tx.c=41=static void smc_tx_write_space(struct sock *sk)\n--\nnet/smc/smc_tx.c-64-/* Wakeup sndbuf producers that blocked with smc_tx_wait().\nnet/smc/smc_tx.c:65: * Cf. tcp_data_snd_check()=\u003etcp_check_space()=\u003etcp_new_space().\nnet/smc/smc_tx.c-66- */\n"
} |
| 25/2 | 2026/09/26 18:44 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23850 output: 205 thoughts: 1820 Thoughts: **Analysis of TCP Write Space Tracking Refactor** Okay, let's break this down. I see we're looking at a significant refactor in how the Linux kernel tracks and manages write space for TCP sockets. My initial thought is to dive into the core functions and understand the flow of control and synchronization mechanisms. I'm focusing on `tcp_data_snd_check` and `tcp_event_new_data_sent`, because these are the starting points. I see that the introduction of `tcp_nospace` is a key indicator of socket capacity exhaustion. When `tcp_check_space()` gets triggered, and if `tcp_nospace` is set, `__tcp_check_space()` is called. This function dives into the socket's `flags` for the `SOCK_NOSPACE` flag, and then into `tcp_new_space(sk)` to call `sk->sk_write_space(sk)`. The most common implementation of this, of course, is `sk_stream_write_space()`. But, importantly, I see that this is a socket family specific hook, so we also need to consider `lowcomms_write_space`, `nvme_tcp_write_space`, `ceph_sock_write_space`, and `subflow_write_space` too. Inside of `sk_stream_write_space()`, `sk_clear_nospace(sk)` gets called. On the flip side, `sk_set_nospace(sk)` gets called from applications that block on space via `tcp_sendmsg_locked()`, or within `tcp_poll()`, or if the application calls `sk_stream_wait_memory()`. So, the new critical functions are those that directly implement the "nospace" management: `sk_set_nospace`, `sk_clear_nospace`, `__tcp_check_space`, `sk_stream_wait_memory`, and `sk_stream_write_space`. We also need to keep `mptcp_check_writeable` and `subflow_ulp_init` in mind because the changes also touch MPTCP code. I need to quickly scan to see if other functions are modified. It's a quick sanity check to see if the changes are highly localized or far reaching. I see functions touched in `drbd`, `lowcomms`, `ceph`, `kcm`, `rds`, `smc`, `sunrpc`, and `tls`. This implies we need to consider various network subsystems. Now, which of those functions are the most important focus symbols? The core of the new logic is in `sk_set_nospace`, `sk_clear_nospace`, and `__tcp_check_space`. These are the crucial functions that implement the tracking of socket "nospace" and "write space". `sk_stream_wait_memory` and `sk_stream_write_space` are also key, as they are part of the socket write path. It looks like `tcp_sendmsg_locked` is very broad, as it is used in any TCP transmit. That function does call `sk_set_nospace`, but `sk_set_nospace` is much more focused. So, let's focus on `sk_set_nospace`, `sk_clear_nospace`, `__tcp_check_space`, `sk_stream_wait_memory`, `sk_stream_write_space`, `mptcp_check_writeable`, and `subflow_ulp_init` to start. I need to confirm the relevant configurations. `INET` (IPv4/TCP) is a given, and `MPTCP` is also relevant because of the `subflow_ulp_init` and `mptcp_check_writeable` modifications. Are there other configs? Not likely, the core changes are most directly impacted by `INET` and `MPTCP`. The MPTCP protocol can be built without specific hardware, and `INET` is the base network stack. Now, let's double-check the reasoning. The patch is refactoring TCP write space tracking, using `tcp_nospace`, `sk_set_nospace()`, and `sk_clear_nospace()` with memory ordering to mirror `SOCK_NOSPACE`. This impacts synchronization and flow control, making it highly reachable from user space and a good candidate for fuzzing. My primary focus will be on the following functions: `sk_set_nospace`, `sk_clear_nospace`, `__tcp_check_space`, `sk_stream_wait_memory`, `sk_stream_write_space`, `mptcp_check_writeable`, and `subflow_ulp_init`. These are all present and accessible in |
| 26/2 | 2026/09/26 18:44 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"INET",
"MPTCP"
],
"FocusSymbols": [
"sk_set_nospace",
"sk_clear_nospace",
"__tcp_check_space",
"sk_stream_wait_memory",
"sk_stream_write_space",
"mptcp_check_writeable",
"subflow_ulp_init"
],
"Reasoning": "The patch modifies core networking flow control and write-space notification logic by introducing tcp_nospace in struct tcp_sock to mirror SOCK_NOSPACE, adding memory barriers (smp_store_mb, smp_mb__before/after_atomic) and helpers sk_set_nospace() and sk_clear_nospace(). These changes affect reachable TCP, MPTCP, socket wait/wake paths and are prone to race conditions or lost wakeups under concurrent traffic.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"INET",
"MPTCP"
],
"FocusSymbols": [
"sk_set_nospace",
"sk_clear_nospace",
"__tcp_check_space",
"sk_stream_wait_memory",
"sk_stream_write_space",
"mptcp_check_writeable",
"subflow_ulp_init"
],
"Reasoning": "The patch modifies core networking flow control and write-space notification logic by introducing tcp_nospace in struct tcp_sock to mirror SOCK_NOSPACE, adding memory barriers (smp_store_mb, smp_mb__before/after_atomic) and helpers sk_set_nospace() and sk_clear_nospace(). These changes affect reachable TCP, MPTCP, socket wait/wake paths and are prone to race conditions or lost wakeups under concurrent traffic.",
"WorthFuzzing": true
} |
| 27/1 | 2026/09/26 18:44 | action | If |
2mArgs:{
"WorthFuzzing": true
}Results: null |
| 28/2 | 2026/09/26 18:44 | agent | kmsan-evaluator |
2mModel:core Args: null Results: {
"KMSANReasoning": "The patch introduces a cache field `tcp_nospace` in `struct tcp_sock` mirroring `SOCK_NOSPACE` on `sk-\u003esk_socket-\u003eflags`, and wraps setting/clearing of this flag with `sk_set_nospace()` and `sk_clear_nospace()` across socket callers (TCP, MPTCP, DLM, NVMe-oF, RDS, SMC, SUNRPC, TLS).\n\n1. `struct tcp_sock` is zero-initialized on allocation via `sk_alloc()`, where `want_init_on_alloc()` triggers `sk_prot_clear_nulls()` clearing the object. For cloned child sockets, `sock_copy()` replicates the zeroed state from the parent socket, and MPTCP subflows explicitly initialize `tp-\u003etcp_nospace = 1` in `subflow_ulp_init()`. The field is always properly initialized before any read.\n2. `tcp_nospace` is an internal kernel-only field within `struct tcp_sock` and is not part of user-facing structures (such as `struct tcp_info` in `include/uapi/linux/tcp.h`). No padding or structure bytes are copied to user space.\n3. No buffer bounds, length calculations, or allocations with uninitialized memory are modified.\n\nAny potential bugs from this patch (such as race conditions, memory ordering, or NULL pointer dereferences) fall under concurrency issues or standard functional errors, which are not detected by KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 8fd6a816640b16f6d1066b4da2c1e4ff561e8025
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Sep 26 18:43:11 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/networking/net_cachelines/tcp_sock.rst b/Documentation/networking/net_cachelines/tcp_sock.rst
index 0f6088c4ab8bb..103328dc409e4 100644
--- a/Documentation/networking/net_cachelines/tcp_sock.rst
+++ b/Documentation/networking/net_cachelines/tcp_sock.rst
@@ -50,6 +50,7 @@ u8:1 tcp_usec_ts read_mostly read_m
u32 chrono_start read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)
u32[3] chrono_stat read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)
u8:2 chrono_type read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_validate,tcp_send_syn_data)
+u8 tcp_nospace read_mostly read_mostly tcp_check_space(tx);tcp_check_space(rx)
u8:1 rate_app_limited read_write tcp_rate_gen
u8:1 fastopen_connect
u8:1 fastopen_no_cookie
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index 0697f99fed18d..8e50131b5a569 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -635,8 +635,7 @@ static int make_resync_request(struct drbd_peer_device *const peer_device, int c
int sndbuf = sk->sk_sndbuf;
if (queued > sndbuf / 2) {
requeue = 1;
- if (sk->sk_socket)
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
}
} else
requeue = 1;
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 921934028e0b2..b853ca2d598fa 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1133,7 +1133,7 @@ static void nvme_tcp_write_space(struct sock *sk)
read_lock_bh(&sk->sk_callback_lock);
queue = sk->sk_user_data;
if (likely(queue && sk_stream_is_writeable(sk))) {
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
/* Ensure pending TLS partial records are retried */
if (nvme_tcp_queue_tls(queue))
queue->write_space(sk);
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index e598101752620..c38ea3501ea5d 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1686,7 +1686,7 @@ static void nvmet_tcp_write_space(struct sock *sk)
}
if (sk_stream_is_writeable(sk)) {
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
queue_work_on(queue_cpu(queue), nvmet_tcp_wq, &queue->io_work);
}
out:
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 2aff1c7c17de4..6aa68a24acab5 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -519,13 +519,11 @@ static void lowcomms_write_space(struct sock *sk)
{
struct connection *con = sock2con(sk);
- clear_bit(SOCK_NOSPACE, &con->sock->flags);
+ sk_clear_nospace(sk);
spin_lock_bh(&con->writequeue_lock);
- if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) {
+ if (test_and_clear_bit(CF_APP_LIMITED, &con->flags))
con->sock->sk->sk_write_pending--;
- clear_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags);
- }
lowcomms_queue_swork(con);
spin_unlock_bh(&con->writequeue_lock);
@@ -1391,12 +1389,12 @@ static int send_to_sock(struct connection *con)
if (ret == -EAGAIN || ret == 0) {
lock_sock(con->sock->sk);
spin_lock_bh(&con->writequeue_lock);
- if (test_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags) &&
+ if (test_bit(SOCK_NOSPACE, &con->sock->flags) &&
!test_and_set_bit(CF_APP_LIMITED, &con->flags)) {
/* Notify TCP that we're limited by the
* application window size.
*/
- set_bit(SOCK_NOSPACE, &con->sock->sk->sk_socket->flags);
+ sk_set_nospace(con->sock->sk);
con->sock->sk->sk_write_pending++;
clear_bit(CF_SEND_PENDING, &con->flags);
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 6a8c77719322f..e4d1720f49f08 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -269,6 +269,9 @@ struct tcp_sock {
*/
u32 snd_sml; /* Last byte of the most recently transmitted small packet */
u8 chrono_type; /* current chronograph type */
+ u8 tcp_nospace; /* mirrors SOCK_NOSPACE, must be set whenever
+ * SOCK_NOSPACE is set.
+ */
u32 chrono_start; /* Start time in jiffies of a TCP chrono */
u32 chrono_stat[3]; /* Time in jiffies for chrono_stat stats */
u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
diff --git a/include/net/sock.h b/include/net/sock.h
index 60ea55dc18854..f4dd2e1051713 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1129,6 +1129,8 @@ static inline void sk_forward_alloc_add(struct sock *sk, int val)
}
void sk_stream_write_space(struct sock *sk);
+void sk_set_nospace(struct sock *sk);
+void sk_clear_nospace(struct sock *sk);
/* OOB backlog add */
static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 5e5f5f9b89a38..3389c51790e6b 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -783,14 +783,42 @@ void tcp_done_with_error(struct sock *sk, int err);
void tcp_reset(struct sock *sk, struct sk_buff *skb);
void tcp_fin(struct sock *sk);
void __tcp_check_space(struct sock *sk);
+
+/* Mirror of SOCK_NOSPACE in tcp_sock, maintained by sk_set_nospace()
+ * and sk_clear_nospace().
+ *
+ * MPTCP subflows share the parent socket, and thus its SOCK_NOSPACE bit.
+ * Keep their mirror always set (see subflow_ulp_init()) so that they
+ * always reach __tcp_check_space() and behave as before.
+ */
+static inline void tcp_set_nospace(struct sock *sk)
+{
+ if (sk_is_tcp(sk)) {
+ /* pairs with smp_mb__before_atomic() in tcp_clear_nospace() */
+ smp_mb__after_atomic();
+ /* pairs with smp_mb() in tcp_check_space() */
+ smp_store_mb(tcp_sk(sk)->tcp_nospace, 1);
+ }
+}
+
+static inline void tcp_clear_nospace(struct sock *sk)
+{
+ if (sk_is_tcp(sk) && !sk_is_mptcp(sk)) {
+ WRITE_ONCE(tcp_sk(sk)->tcp_nospace, 0);
+ /* pairs with smp_mb__after_atomic() in tcp_set_nospace() */
+ smp_mb__before_atomic();
+ }
+}
+
static inline void tcp_check_space(struct sock *sk)
{
/* pairs with tcp_poll() */
smp_mb();
- if (sk->sk_socket && test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
+ if (unlikely(READ_ONCE(tcp_sk(sk)->tcp_nospace)))
__tcp_check_space(sk);
}
+
void tcp_sack_compress_send_ack(struct sock *sk);
static inline void tcp_cleanup_skb(struct sk_buff *skb)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 212e7797f9e48..cc7db8c61db37 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -375,7 +375,7 @@ static void ceph_sock_write_space(struct sock *sk)
if (ceph_con_flag_test(con, CEPH_CON_F_WRITE_PENDING)) {
if (sk_stream_is_writeable(sk)) {
dout("%s %p queueing write work\n", __func__, con);
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
queue_con(con);
}
} else {
diff --git a/net/core/sock.c b/net/core/sock.c
index 2948dffcc3e1b..946f614f665b3 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2957,6 +2957,48 @@ void sock_kzfree_s(struct sock *sk, void *mem, int size)
}
EXPORT_SYMBOL(sock_kzfree_s);
+/**
+ * sk_set_nospace - tell the transport a writer is waiting for space
+ * @sk: socket
+ *
+ * Must be called before the final check of the available send space,
+ * so that the transport can not miss the request and forget to call
+ * sk->sk_write_space() once space is available again.
+ */
+void sk_set_nospace(struct sock *sk)
+{
+ struct socket *sock = sk->sk_socket;
+
+ if (!sock)
+ return;
+ /* Set SOCK_NOSPACE before tp->tcp_nospace (paired with
+ * sk_clear_nospace() clearing tp->tcp_nospace before SOCK_NOSPACE)
+ * so a concurrent clear cannot leave SOCK_NOSPACE set with
+ * tp->tcp_nospace cleared.
+ */
+ set_bit(SOCK_NOSPACE, &sock->flags);
+ tcp_set_nospace(sk);
+}
+EXPORT_SYMBOL(sk_set_nospace);
+
+/**
+ * sk_clear_nospace - tell the transport no writer is waiting for space
+ * @sk: socket
+ *
+ * Called from ->sk_write_space() handlers, once send space has been
+ * made available to writers.
+ */
+void sk_clear_nospace(struct sock *sk)
+{
+ struct socket *sock = sk->sk_socket;
+
+ if (!sock)
+ return;
+ tcp_clear_nospace(sk);
+ clear_bit(SOCK_NOSPACE, &sock->flags);
+}
+EXPORT_SYMBOL(sk_clear_nospace);
+
/* It is almost wait_for_tcp_memory minus release_sock/lock_sock.
I think, these locks should be removed for datagram sockets.
*/
@@ -2970,7 +3012,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)
break;
if (signal_pending(current))
break;
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
if (refcount_read(&sk->sk_wmem_alloc) < READ_ONCE(sk->sk_sndbuf))
break;
@@ -3011,7 +3053,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
break;
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
err = -EAGAIN;
if (!timeo)
goto failure;
diff --git a/net/core/stream.c b/net/core/stream.c
index 2d748581862d0..a853b60afdc35 100644
--- a/net/core/stream.c
+++ b/net/core/stream.c
@@ -37,7 +37,7 @@ void sk_stream_write_space(struct sock *sk)
struct socket_wq *wq;
if (__sk_stream_is_writeable(sk, 1) && sock) {
- clear_bit(SOCK_NOSPACE, &sock->flags);
+ sk_clear_nospace(sk);
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
@@ -143,7 +143,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
if (sk_stream_memory_free(sk) && !vm_wait)
break;
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
sk->sk_write_pending++;
ret = sk_wait_event(sk, ¤t_timeo, READ_ONCE(sk->sk_err) ||
(READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN) ||
@@ -177,7 +177,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
* When TCP receives ACK packets that make room, tcp_check_space()
* only calls tcp_new_space() if SOCK_NOSPACE is set.
*/
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
err = -EAGAIN;
goto out;
do_interrupted:
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3ac4856852794..f44cbd3e76178 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -607,7 +607,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
mask |= EPOLLOUT | EPOLLWRNORM;
} else { /* send SIGIO later */
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
/* Race breaker. If space is freed after
* wspace test but before the flags are set,
@@ -1398,7 +1398,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
continue;
wait_for_space:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
tcp_remove_empty_skb(sk);
if (copied)
tcp_push(sk, flags & ~MSG_MORE, mss_now,
@@ -5242,6 +5242,7 @@ static void __init tcp_struct_check(void)
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, first_tx_mstamp);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, delivered_mstamp);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, snd_sml);
+ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, tcp_nospace);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, chrono_start);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, chrono_stat);
CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_tx, write_seq);
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 2e234d155b5e6..64d74d92af52d 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -602,7 +602,7 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
goto out_err;
continue;
wait_for_sndbuf:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
wait_for_memory:
err = sk_stream_wait_memory(sk, &timeo);
if (err) {
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 892ff256e2352..cdea30d07fe2c 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6098,8 +6098,14 @@ static void tcp_new_space(struct sock *sk)
*/
void __tcp_check_space(struct sock *sk)
{
+ struct socket *sock = sk->sk_socket;
+
+ /* tp->tcp_nospace is only a hint, SOCK_NOSPACE is authoritative. */
+ if (!sock || !test_bit(SOCK_NOSPACE, &sock->flags))
+ return;
+
tcp_new_space(sk);
- if (!test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
+ if (!test_bit(SOCK_NOSPACE, &sock->flags))
tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);
}
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 71af69d442f21..b29c0ed9caf52 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -735,7 +735,7 @@ static void kcm_tx_work(struct work_struct *w)
/* Primarily for SOCK_SEQPACKET sockets */
if (likely(sk->sk_socket) &&
test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
sk->sk_write_space(sk);
}
@@ -779,7 +779,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
/* Call the sk_stream functions to manage the sndbuf mem. */
if (!sk_stream_memory_free(sk)) {
kcm_push(kcm);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
err = sk_stream_wait_memory(sk, &timeo);
if (err)
goto out_error;
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index e89a69ab927c9..74b1a51207287 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2106,7 +2106,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
continue;
wait_for_memory:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
__mptcp_push_pending(sk, msg->msg_flags);
ret = sk_stream_wait_memory(sk, &timeo);
if (ret)
@@ -4472,7 +4472,7 @@ static __poll_t mptcp_check_writeable(struct mptcp_sock *msk)
if (__mptcp_stream_is_writeable(sk, 1))
return EPOLLOUT | EPOLLWRNORM;
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
smp_mb__after_atomic(); /* NOSPACE is changed by mptcp_write_space() */
if (__mptcp_stream_is_writeable(sk, 1))
return EPOLLOUT | EPOLLWRNORM;
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index f0a6725d2c376..e297c88be503b 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -2001,6 +2001,11 @@ static int subflow_ulp_init(struct sock *sk)
pr_debug("subflow=%p, family=%d\n", ctx, sk->sk_family);
tp->is_mptcp = 1;
+ /* Subflows share the MPTCP socket, and thus its SOCK_NOSPACE bit,
+ * which tcp_check_space() can not mirror. Pin the mirror so that
+ * __tcp_check_space() always tests the shared bit.
+ */
+ tp->tcp_nospace = 1;
ctx->icsk_af_ops = icsk->icsk_af_ops;
icsk->icsk_af_ops = subflow_default_af_ops(sk);
ctx->tcp_state_change = sk->sk_state_change;
diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
index 7c52acc749cf4..824222c475119 100644
--- a/net/rds/tcp_send.c
+++ b/net/rds/tcp_send.c
@@ -100,7 +100,7 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
if (hdr_off < sizeof(struct rds_header)) {
/* see rds_tcp_write_space() */
- set_bit(SOCK_NOSPACE, &tc->t_sock->sk->sk_socket->flags);
+ sk_set_nospace(tc->t_sock->sk);
ret = rds_tcp_sendmsg(tc->t_sock,
(void *)&rm->m_inc.i_hdr + hdr_off,
@@ -221,6 +221,5 @@ void rds_tcp_write_space(struct sock *sk)
*/
write_space(sk);
- if (sk->sk_socket)
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
}
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index e9f93b3ab435b..4f2afbbdef2d7 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2919,7 +2919,7 @@ __poll_t smc_poll(struct file *file, struct socket *sock,
mask |= EPOLLOUT | EPOLLWRNORM;
} else {
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
if (sk->sk_state != SMC_INIT) {
/* Race breaker the same way as tcp_poll(). */
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index 3144b4b1fe290..52e5395484fd3 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -48,7 +48,7 @@ static void smc_tx_write_space(struct sock *sk)
if (atomic_read(&smc->conn.sndbuf_space) && sock) {
if (test_bit(SOCK_NOSPACE, &sock->flags))
SMC_STAT_RMB_TX_FULL(smc, !smc->conn.lnk);
- clear_bit(SOCK_NOSPACE, &sock->flags);
+ sk_clear_nospace(sk);
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (skwq_has_sleeper(wq))
@@ -100,7 +100,7 @@ static int smc_tx_wait(struct smc_sock *smc, int flags)
}
if (!timeo) {
/* ensure EPOLLOUT is subsequently generated */
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
rc = -EAGAIN;
break;
}
@@ -111,7 +111,7 @@ static int smc_tx_wait(struct smc_sock *smc, int flags)
sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
if (atomic_read(&conn->sndbuf_space) && !conn->urg_tx_pend)
break; /* at least 1 byte of free & no urgent data */
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
sk_wait_event(sk, &timeo,
READ_ONCE(sk->sk_err) ||
(READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN) ||
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 50e5e7f5b762d..2d8cdee0798d5 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -792,11 +792,11 @@ static int svc_udp_has_wspace(struct svc_xprt *xprt)
* Set the SOCK_NOSPACE flag before checking the available
* sock space.
*/
- set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
+ sk_set_nospace(svsk->sk_sk);
required = atomic_read(&svsk->sk_xprt.xpt_reserved) + serv->sv_max_mesg;
if (required*2 > sock_wspace(svsk->sk_sk))
return 0;
- clear_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
+ sk_clear_nospace(svsk->sk_sk);
return 1;
}
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 7f60723fa64d8..b97c70c12f627 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -858,7 +858,7 @@ static int xs_nospace(struct rpc_rqst *req, struct sock_xprt *transport)
if (xprt_connected(xprt)) {
/* wait for more buffer space */
set_bit(XPRT_SOCK_NOSPACE, &transport->sock_state);
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
sk->sk_write_pending++;
xprt_wait_for_buffer_space(xprt);
} else
@@ -1615,7 +1615,7 @@ static void xs_write_space(struct sock *sk)
if (!sk->sk_socket)
return;
- clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_clear_nospace(sk);
if (unlikely(!(xprt = xprt_from_sock(sk))))
return;
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index d1ad31986cf2c..312e51270f293 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -966,7 +966,7 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,
continue;
wait_for_sndbuf:
- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ sk_set_nospace(sk);
wait_for_memory:
ret = sk_stream_wait_memory(sk, &timeo);
if (ret) {
|
| 29/3 | 2026/09/26 18:44 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 10432 output: 18 thoughts: 726 Thoughts: **KMSAN Fuzzing Session Justification** Okay, so I need to decide if this patch series warrants a dedicated KMSAN fuzzing session. Let's break this down systematically. I know KMSAN is all about detecting reads of *uninitialized* memory, both on the stack, heap, and page allocations, and also kernel-to-user information leaks. This is different from KASAN which handles out-of-bounds accesses, use-after-frees, and the like. This also isn't about lockdep which catches deadlocks. The instructions tell me to set `NeedsKMSAN=true` *only* if I see: kernel structures going to userspace with potentially uninitialized fields, logic branching based on uninitialized variables, complex data structure allocations where uninitialized fields *could* be read later in the code path, or if bounds checks allow access to uninitialized bytes of existing buffers. Conversely, I should set `NeedsKMSAN=false` if the changes primarily concern things like out-of-bounds, overflows, null pointer dereferences, locking deadlocks, use-after-frees or the introduced stack/heap structures are fully zeroed/initialized. Now, let's examine the patch itself. It's a series of seemingly simple changes, mostly replacing calls to `set_bit` and `clear_bit` on `sk->sk_socket->flags` with functions like `sk_set_nospace` and `sk_clear_nospace`. The change in `include/linux/tcp.h` introduces `u8 tcp_nospace` to `struct tcp_sock`. The key question is: where is this `tcp_sock` allocated and initialized? This is the crucial point for KMSAN. If `tcp_sock` isn't properly initialized when allocated, there's a risk of uninitialized memory usage. I know in Linux networking, `tcp_sock` is typically allocated using slab or kmalloc, often through `sk_alloc()`. I need to figure out if `sk_alloc` or the functions that initialize `tcp_sock` (e.g., `tcp_init_sock`, `tcp_v4_init_sock`) zero the memory. I should grep for `sk_alloc` or the init functions to understand the memory initialization behavior. If it does zero the memory, it won't justify a KMSAN session. |
| 30/3 | 2026/09/26 18:44 | tool | grepper |
0mArgs:{
"Expression": "sk_alloc\\("
}Results: {
"Output": "\nFull output is too long, showing 500 out of 716 lines.\nUse more precise expression if possible.\n\ncrypto/af_alg.c=464=int af_alg_accept(struct sock *sk, struct socket *newsock,\n--\ncrypto/af_alg.c-479-\ncrypto/af_alg.c:480:\tsk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, \u0026alg_proto, arg-\u003ekern);\ncrypto/af_alg.c-481-\terr = -ENOMEM;\n--\ncrypto/af_alg.c=559=static int alg_create(struct net *net, struct socket *sock, int protocol,\n--\ncrypto/af_alg.c-573-\terr = -ENOMEM;\ncrypto/af_alg.c:574:\tsk = sk_alloc(net, PF_ALG, GFP_KERNEL, \u0026alg_proto, kern);\ncrypto/af_alg.c-575-\tif (!sk)\n--\ndrivers/dma/bestcomm/ata.c=54=bcom_ata_init(int queue_len, int maxbufsize)\n--\ndrivers/dma/bestcomm/ata.c-62-\ndrivers/dma/bestcomm/ata.c:63:\ttsk = bcom_task_alloc(queue_len, sizeof(struct bcom_ata_bd), 0);\ndrivers/dma/bestcomm/ata.c-64-\tif (!tsk)\n--\ndrivers/dma/bestcomm/bestcomm.c=46=struct bcom_task *\ndrivers/dma/bestcomm/bestcomm.c:47:bcom_task_alloc(int bd_count, int bd_size, int priv_size)\ndrivers/dma/bestcomm/bestcomm.c-48-{\n--\ndrivers/dma/bestcomm/fec.c=81=bcom_fec_rx_init(int queue_len, phys_addr_t fifo, int maxbufsize)\n--\ndrivers/dma/bestcomm/fec.c-85-\ndrivers/dma/bestcomm/fec.c:86:\ttsk = bcom_task_alloc(queue_len, sizeof(struct bcom_fec_bd),\ndrivers/dma/bestcomm/fec.c-87-\t\t\t\tsizeof(struct bcom_fec_priv));\n--\ndrivers/dma/bestcomm/fec.c=183=bcom_fec_tx_init(int queue_len, phys_addr_t fifo)\n--\ndrivers/dma/bestcomm/fec.c-187-\ndrivers/dma/bestcomm/fec.c:188:\ttsk = bcom_task_alloc(queue_len, sizeof(struct bcom_fec_bd),\ndrivers/dma/bestcomm/fec.c-189-\t\t\t\tsizeof(struct bcom_fec_priv));\n--\ndrivers/dma/bestcomm/gen_bd.c=85=bcom_gen_bd_rx_init(int queue_len, phys_addr_t fifo,\n--\ndrivers/dma/bestcomm/gen_bd.c-90-\ndrivers/dma/bestcomm/gen_bd.c:91:\ttsk = bcom_task_alloc(queue_len, sizeof(struct bcom_gen_bd),\ndrivers/dma/bestcomm/gen_bd.c-92-\t\t\tsizeof(struct bcom_gen_bd_priv));\n--\ndrivers/dma/bestcomm/gen_bd.c=170=bcom_gen_bd_tx_init(int queue_len, phys_addr_t fifo,\n--\ndrivers/dma/bestcomm/gen_bd.c-175-\ndrivers/dma/bestcomm/gen_bd.c:176:\ttsk = bcom_task_alloc(queue_len, sizeof(struct bcom_gen_bd),\ndrivers/dma/bestcomm/gen_bd.c-177-\t\t\tsizeof(struct bcom_gen_bd_priv));\n--\ndrivers/gpu/drm/exynos/exynos_drm_ipp.c=258=static inline struct exynos_drm_ipp_task *\ndrivers/gpu/drm/exynos/exynos_drm_ipp.c:259:\t\t\texynos_drm_ipp_task_alloc(struct exynos_drm_ipp *ipp)\ndrivers/gpu/drm/exynos/exynos_drm_ipp.c-260-{\n--\ndrivers/gpu/drm/exynos/exynos_drm_ipp.c=872=int exynos_drm_ipp_commit_ioctl(struct drm_device *dev, void *data,\n--\ndrivers/gpu/drm/exynos/exynos_drm_ipp.c-891-\ndrivers/gpu/drm/exynos/exynos_drm_ipp.c:892:\ttask = exynos_drm_ipp_task_alloc(ipp);\ndrivers/gpu/drm/exynos/exynos_drm_ipp.c-893-\tif (!task)\n--\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c=137=static int nfp_release_mask_id(struct nfp_app *app, u8 mask_id)\n--\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c-160-\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c:161:static int nfp_mask_alloc(struct nfp_app *app, u8 *mask_id)\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c-162-{\n--\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c=207=nfp_add_mask_table(struct nfp_app *app, char *mask_data, u32 mask_len)\n--\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c-213-\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c:214:\tif (nfp_mask_alloc(app, \u0026mask_id))\ndrivers/net/ethernet/netronome/nfp/flower/metadata.c-215-\t\treturn -ENOENT;\n--\ndrivers/net/ppp/pppoe.c=511=static int pppoe_create(struct net *net, struct socket *sock, int kern)\n--\ndrivers/net/ppp/pppoe.c-514-\ndrivers/net/ppp/pppoe.c:515:\tsk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, \u0026pppoe_sk_proto, kern);\ndrivers/net/ppp/pppoe.c-516-\tif (!sk)\n--\ndrivers/net/ppp/pptp.c=542=static int pptp_create(struct net *net, struct socket *sock, int kern)\n--\ndrivers/net/ppp/pptp.c-548-\ndrivers/net/ppp/pptp.c:549:\tsk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, \u0026pptp_sk_proto, kern);\ndrivers/net/ppp/pptp.c-550-\tif (!sk)\n--\ndrivers/net/tap.c=446=static int tap_open(struct inode *inode, struct file *file)\n--\ndrivers/net/tap.c-458-\terr = -ENOMEM;\ndrivers/net/tap.c:459:\tq = (struct tap_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,\ndrivers/net/tap.c-460-\t\t\t\t\t \u0026tap_proto, 0);\n--\ndrivers/net/tun.c=3544=static int tun_chr_open(struct inode *inode, struct file * file)\n--\ndrivers/net/tun.c-3548-\ndrivers/net/tun.c:3549:\ttfile = (struct tun_file *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,\ndrivers/net/tun.c-3550-\t\t\t\t\t \u0026tun_proto, 0);\n--\ndrivers/s390/block/dasd.c=240=static int dasd_state_known_to_basic(struct dasd_device *device)\n--\ndrivers/s390/block/dasd.c-246-\tif (block) {\ndrivers/s390/block/dasd.c:247:\t\trc = dasd_gendisk_alloc(block);\ndrivers/s390/block/dasd.c-248-\t\tif (rc)\n--\ndrivers/s390/block/dasd_genhd.c=40=static int dasd_name_format(char *prefix, int index, char *buf, int buflen)\n--\ndrivers/s390/block/dasd_genhd.c-66- */\ndrivers/s390/block/dasd_genhd.c:67:int dasd_gendisk_alloc(struct dasd_block *block)\ndrivers/s390/block/dasd_genhd.c-68-{\n--\ndrivers/s390/block/dasd_int.h=1075=void dasd_gendisk_exit(void);\ndrivers/s390/block/dasd_int.h:1076:int dasd_gendisk_alloc(struct dasd_block *);\ndrivers/s390/block/dasd_int.h-1077-void dasd_gendisk_free(struct dasd_block *);\n--\ndrivers/xen/pvcalls-front.c=825=int pvcalls_front_accept(struct socket *sock, struct socket *newsock,\n--\ndrivers/xen/pvcalls-front.c-954-\tmap2-\u003esock = newsock;\ndrivers/xen/pvcalls-front.c:955:\tnewsock-\u003esk = sk_alloc(sock_net(sock-\u003esk), PF_INET, GFP_KERNEL, \u0026pvcalls_proto, false);\ndrivers/xen/pvcalls-front.c-956-\tif (!newsock-\u003esk) {\n--\nfs/xfs/xfs_dquot.c=342=STATIC int\nfs/xfs/xfs_dquot.c:343:xfs_dquot_disk_alloc(\nfs/xfs/xfs_dquot.c-344-\tstruct xfs_dquot\t*dqp,\n--\nfs/xfs/xfs_dquot.c=703=xfs_qm_dqread(\n--\nfs/xfs/xfs_dquot.c-719-\tif (error == -ENOENT \u0026\u0026 can_alloc)\nfs/xfs/xfs_dquot.c:720:\t\terror = xfs_dquot_disk_alloc(dqp, \u0026bp);\nfs/xfs/xfs_dquot.c-721-\tif (error)\n--\ninclude/linux/cgroup.h=897=static inline void cgroup_account_cputime_field(struct task_struct *task,\n--\ninclude/linux/cgroup.h-908-\ninclude/linux/cgroup.h:909:void cgroup_sk_alloc(struct sock_cgroup_data *skcd);\ninclude/linux/cgroup.h-910-void cgroup_sk_clone(struct sock_cgroup_data *skcd);\n--\ninclude/linux/cgroup.h=913=static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)\n--\ninclude/linux/cgroup.h-919-\ninclude/linux/cgroup.h:920:static inline void cgroup_sk_alloc(struct sock_cgroup_data *skcd) {}\ninclude/linux/cgroup.h-921-static inline void cgroup_sk_clone(struct sock_cgroup_data *skcd) {}\n--\ninclude/linux/fsl/bestcomm/bestcomm_priv.h=91=struct bcom_task_header {\n--\ninclude/linux/fsl/bestcomm/bestcomm_priv.h-235-\ninclude/linux/fsl/bestcomm/bestcomm_priv.h:236:extern struct bcom_task *bcom_task_alloc(int bd_count, int bd_size, int priv_size);\ninclude/linux/fsl/bestcomm/bestcomm_priv.h-237-extern void bcom_task_free(struct bcom_task *tsk);\n--\ninclude/linux/memcontrol.h=1633=extern struct static_key_false memcg_sockets_enabled_key;\n--\ninclude/linux/memcontrol.h-1635-\ninclude/linux/memcontrol.h:1636:void mem_cgroup_sk_alloc(struct sock *sk);\ninclude/linux/memcontrol.h-1637-void mem_cgroup_sk_free(struct sock *sk);\n--\ninclude/linux/memcontrol.h=1683=static inline int shrinker_id(struct shrinker *shrinker)\n--\ninclude/linux/memcontrol.h-1689-\ninclude/linux/memcontrol.h:1690:static inline void mem_cgroup_sk_alloc(struct sock *sk)\ninclude/linux/memcontrol.h-1691-{\n--\ninclude/linux/security.h=497=int security_file_truncate(struct file *file);\ninclude/linux/security.h:498:int security_task_alloc(struct task_struct *task, u64 clone_flags);\ninclude/linux/security.h-499-void security_task_free(struct task_struct *task);\n--\ninclude/linux/security.h=1236=static inline int security_file_truncate(struct file *file)\n--\ninclude/linux/security.h-1240-\ninclude/linux/security.h:1241:static inline int security_task_alloc(struct task_struct *task,\ninclude/linux/security.h-1242-\t\t\t\t u64 clone_flags)\n--\ninclude/linux/security.h=1687=int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);\ninclude/linux/security.h:1688:int security_sk_alloc(struct sock *sk, int family, gfp_t priority);\ninclude/linux/security.h-1689-void security_sk_free(struct sock *sk);\n--\ninclude/linux/security.h=1837=static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)\n--\ninclude/linux/security.h-1841-\ninclude/linux/security.h:1842:static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)\ninclude/linux/security.h-1843-{\n--\ninclude/linux/smp.h=234=static inline int get_boot_cpu_id(void)\n--\ninclude/linux/smp.h-241-#if defined(CONFIG_PREEMPTION) \u0026\u0026 defined(CONFIG_SMP)\ninclude/linux/smp.h:242:int smp_task_ipi_mask_alloc(struct task_struct *task);\ninclude/linux/smp.h-243-void smp_task_ipi_mask_free(struct task_struct *task);\ninclude/linux/smp.h-244-#else\ninclude/linux/smp.h:245:static inline int smp_task_ipi_mask_alloc(struct task_struct *task)\ninclude/linux/smp.h-246-{\n--\ninclude/net/inet_sock.h=391=static inline unsigned int __inet_ehashfn(const __be32 laddr,\n--\ninclude/net/inet_sock.h-402-\ninclude/net/inet_sock.h:403:struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,\ninclude/net/inet_sock.h-404-\t\t\t\t struct sock *sk_listener,\n--\ninclude/net/inet_timewait_sock.h=104=void inet_twsk_bind_unhash(struct inet_timewait_sock *tw,\n--\ninclude/net/inet_timewait_sock.h-106-\ninclude/net/inet_timewait_sock.h:107:struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,\ninclude/net/inet_timewait_sock.h-108-\t\t\t\t\t struct inet_timewait_death_row *dr,\n--\ninclude/net/llc_conn.h=88=static __inline__ char llc_backlog_type(struct sk_buff *skb)\n--\ninclude/net/llc_conn.h-92-\ninclude/net/llc_conn.h:93:struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority,\ninclude/net/llc_conn.h-94-\t\t\t struct proto *prot, int kern);\n--\ninclude/net/mptcp.h=216=int mptcp_subflow_init_cookie_req(struct request_sock *req,\n--\ninclude/net/mptcp.h-218-\t\t\t\t struct sk_buff *skb);\ninclude/net/mptcp.h:219:struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_ops *ops,\ninclude/net/mptcp.h-220-\t\t\t\t\t struct sock *sk_listener,\n--\ninclude/net/mptcp.h=294=static inline int mptcp_subflow_init_cookie_req(struct request_sock *req,\n--\ninclude/net/mptcp.h-300-\ninclude/net/mptcp.h:301:static inline struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_ops *ops,\ninclude/net/mptcp.h-302-\t\t\t\t\t\t\t struct sock *sk_listener,\n--\ninclude/net/sock.h=1833=static inline bool sock_allow_reclassification(const struct sock *csk)\n--\ninclude/net/sock.h-1840-\ninclude/net/sock.h:1841:struct sock *sk_alloc(struct net *net, int family, gfp_t priority,\ninclude/net/sock.h-1842-\t\t struct proto *prot, int kern);\n--\ninclude/net/tcp.h=593=struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb);\ninclude/net/tcp.h:594:struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,\ninclude/net/tcp.h-595-\t\t\t\t\t struct sock *sk, struct sk_buff *skb,\n--\nkernel/cgroup/cgroup.c=7468=int cgroup_parse_float(const char *input, unsigned dec_shift, s64 *v)\n--\nkernel/cgroup/cgroup.c-7493-\nkernel/cgroup/cgroup.c:7494:void cgroup_sk_alloc(struct sock_cgroup_data *skcd)\nkernel/cgroup/cgroup.c-7495-{\n--\nkernel/fork.c=915=static struct task_struct *dup_task_struct(struct task_struct *orig, int node)\n--\nkernel/fork.c-938-\nkernel/fork.c:939:\terr = smp_task_ipi_mask_alloc(tsk);\nkernel/fork.c-940-\tif (err)\n--\nkernel/fork.c=2012=__latent_entropy struct task_struct *copy_process(\n--\nkernel/fork.c-2291-\tshm_init_task(p);\nkernel/fork.c:2292:\tretval = security_task_alloc(p, clone_flags);\nkernel/fork.c-2293-\tif (retval)\n--\nkernel/smp.c=836=static DEFINE_STATIC_KEY_FALSE(ipi_mask_inlined);\n--\nkernel/smp.c-839-\nkernel/smp.c:840:int smp_task_ipi_mask_alloc(struct task_struct *task)\nkernel/smp.c-841-{\n--\nmm/memcontrol-v1.c=1965=static int memcg_update_tcp_max(struct mem_cgroup *memcg, unsigned long max)\n--\nmm/memcontrol-v1.c-1978-\t\t * update. This is what guarantees that the socket activation\nmm/memcontrol-v1.c:1979:\t\t * function is the last one to run. See mem_cgroup_sk_alloc()\nmm/memcontrol-v1.c-1980-\t\t * for details, and note that we don't mark any socket as\n--\nmm/memcontrol-v1.c-1987-\t\t *\nmm/memcontrol-v1.c:1988:\t\t * We never race with the readers in mem_cgroup_sk_alloc(),\nmm/memcontrol-v1.c-1989-\t\t * because when this value change, the code to process it is not\n--\nmm/memcontrol.c=5563=EXPORT_SYMBOL(memcg_sockets_enabled_key);\nmm/memcontrol.c-5564-\nmm/memcontrol.c:5565:void mem_cgroup_sk_alloc(struct sock *sk)\nmm/memcontrol.c-5566-{\n--\nnet/atm/common.c=139=int vcc_create(struct net *net, struct socket *sock, int protocol, int family, int kern)\n--\nnet/atm/common.c-146-\t\treturn -EINVAL;\nnet/atm/common.c:147:\tsk = sk_alloc(net, family, GFP_KERNEL, \u0026vcc_proto, kern);\nnet/atm/common.c-148-\tif (!sk)\n--\nnet/bluetooth/af_bluetooth.c=143=struct sock *bt_sock_alloc(struct net *net, struct socket *sock,\n--\nnet/bluetooth/af_bluetooth.c-147-\nnet/bluetooth/af_bluetooth.c:148:\tsk = sk_alloc(net, PF_BLUETOOTH, prio, prot, kern);\nnet/bluetooth/af_bluetooth.c-149-\tif (!sk)\n--\nnet/bpf/test_run.c=1035=int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,\n--\nnet/bpf/test_run.c-1105-\nnet/bpf/test_run.c:1106:\tsk = sk_alloc(net, AF_UNSPEC, GFP_USER, \u0026bpf_dummy_proto, 1);\nnet/bpf/test_run.c-1107-\tif (!sk) {\n--\nnet/can/af_can.c=114=static int can_create(struct net *net, struct socket *sock, int protocol,\n--\nnet/can/af_can.c-157-\nnet/can/af_can.c:158:\tsk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp-\u003eprot, kern);\nnet/can/af_can.c-159-\tif (!sk) {\n--\nnet/core/filter.c=12505=__bpf_kfunc int bpf_sk_assign_tcp_reqsk(struct __sk_buff *s, struct sock *sk,\n--\nnet/core/filter.c-12569-\nnet/core/filter.c:12570:\treq = inet_reqsk_alloc(ops, sk, false);\nnet/core/filter.c-12571-\tif (!req)\n--\nnet/core/sock.c=2238=static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,\n--\nnet/core/sock.c-2254-\tif (sk != NULL) {\nnet/core/sock.c:2255:\t\tif (security_sk_alloc(sk, family, priority))\nnet/core/sock.c-2256-\t\t\tgoto out_free;\n--\nnet/core/sock.c=2274=static void sk_prot_free(struct proto *prot, struct sock *sk)\n--\nnet/core/sock.c-2302- */\nnet/core/sock.c:2303:struct sock *sk_alloc(struct net *net, int family, gfp_t priority,\nnet/core/sock.c-2304-\t\t struct proto *prot, int kern)\n--\nnet/core/sock.c-2335-\nnet/core/sock.c:2336:\t\tmem_cgroup_sk_alloc(sk);\nnet/core/sock.c:2337:\t\tcgroup_sk_alloc(\u0026sk-\u003esk_cgrp_data);\nnet/core/sock.c-2338-\t\tsock_update_classid(\u0026sk-\u003esk_cgrp_data);\n--\nnet/ieee802154/socket.c=1016=static int ieee802154_create(struct net *net, struct socket *sock,\n--\nnet/ieee802154/socket.c-1044-\trc = -ENOMEM;\nnet/ieee802154/socket.c:1045:\tsk = sk_alloc(net, PF_IEEE802154, GFP_KERNEL, proto, kern);\nnet/ieee802154/socket.c-1046-\tif (!sk)\n--\nnet/ipv4/af_inet.c=259=static int inet_create(struct net *net, struct socket *sock, int protocol,\n--\nnet/ipv4/af_inet.c-332-\terr = -ENOMEM;\nnet/ipv4/af_inet.c:333:\tsk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot, kern);\nnet/ipv4/af_inet.c-334-\tif (!sk)\n--\nnet/ipv4/af_inet.c=760=void __inet_accept(struct socket *sock, struct socket *newsock, struct sock *newsk)\n--\nnet/ipv4/af_inet.c-762-\tif (mem_cgroup_sockets_enabled) {\nnet/ipv4/af_inet.c:763:\t\tmem_cgroup_sk_alloc(newsk);\nnet/ipv4/af_inet.c-764-\t\t__sk_charge(newsk, GFP_KERNEL);\n--\nnet/ipv4/inet_connection_sock.c=850=reqsk_alloc_noprof(const struct request_sock_ops *ops, struct sock *sk_listener,\n--\nnet/ipv4/inet_connection_sock.c-878-}\nnet/ipv4/inet_connection_sock.c:879:#define reqsk_alloc(...)\talloc_hooks(reqsk_alloc_noprof(__VA_ARGS__))\nnet/ipv4/inet_connection_sock.c-880-\nnet/ipv4/inet_connection_sock.c:881:struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,\nnet/ipv4/inet_connection_sock.c-882-\t\t\t\t struct sock *sk_listener,\n--\nnet/ipv4/inet_connection_sock.c-884-{\nnet/ipv4/inet_connection_sock.c:885:\tstruct request_sock *req = reqsk_alloc(ops, sk_listener,\nnet/ipv4/inet_connection_sock.c-886-\t\t\t\t\t attach_listener);\n--\nnet/ipv4/inet_timewait_sock.c=163=static void tw_timer_handler(struct timer_list *t)\n--\nnet/ipv4/inet_timewait_sock.c-169-\nnet/ipv4/inet_timewait_sock.c:170:struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,\nnet/ipv4/inet_timewait_sock.c-171-\t\t\t\t\t struct inet_timewait_death_row *dr,\n--\nnet/ipv4/syncookies.c=302=struct request_sock *cookie_bpf_check(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/syncookies.c-317-\nnet/ipv4/syncookies.c:318:struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,\nnet/ipv4/syncookies.c-319-\t\t\t\t\t struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/syncookies.c-327-\tif (sk_is_mptcp(sk))\nnet/ipv4/syncookies.c:328:\t\treq = mptcp_subflow_reqsk_alloc(ops, sk, false);\nnet/ipv4/syncookies.c-329-\telse\nnet/ipv4/syncookies.c:330:\t\treq = inet_reqsk_alloc(ops, sk, false);\nnet/ipv4/syncookies.c-331-\n--\nnet/ipv4/syncookies.c=358=static struct request_sock *cookie_tcp_check(struct net *net, struct sock *sk,\n--\nnet/ipv4/syncookies.c-394-\nnet/ipv4/syncookies.c:395:\treturn cookie_tcp_reqsk_alloc(\u0026tcp_request_sock_ops, sk, skb,\nnet/ipv4/syncookies.c-396-\t\t\t\t \u0026tcp_opt, mss, tsoff);\n--\nnet/ipv4/tcp.c=402=void tcp_md5_destruct_sock(struct sock *sk)\n--\nnet/ipv4/tcp.c-417- * NOTE: A lot of things set to zero explicitly by call to\nnet/ipv4/tcp.c:418: * sk_alloc() so need not be done here.\nnet/ipv4/tcp.c-419- */\n--\nnet/ipv4/tcp_input.c=7622=int tcp_conn_request(struct request_sock_ops *rsk_ops,\n--\nnet/ipv4/tcp_input.c-7662-\nnet/ipv4/tcp_input.c:7663:\treq = inet_reqsk_alloc(rsk_ops, sk, !want_cookie);\nnet/ipv4/tcp_input.c-7664-\tif (!req)\n--\nnet/ipv4/tcp_ipv4.c=2385=static void tcp4_destruct_sock(struct sock *sk)\n--\nnet/ipv4/tcp_ipv4.c-2393-/* NOTE: A lot of things set to zero explicitly by call to\nnet/ipv4/tcp_ipv4.c:2394: * sk_alloc() so need not be done here.\nnet/ipv4/tcp_ipv4.c-2395- */\n--\nnet/ipv4/tcp_minisocks.c=326=void tcp_time_wait(struct sock *sk, int state, int timeo)\n--\nnet/ipv4/tcp_minisocks.c-332-\nnet/ipv4/tcp_minisocks.c:333:\ttw = inet_twsk_alloc(sk, \u0026net-\u003eipv4.tcp_death_row, state);\nnet/ipv4/tcp_minisocks.c-334-\n--\nnet/ipv6/af_inet6.c=105=static int inet6_create(struct net *net, struct socket *sock, int protocol,\n--\nnet/ipv6/af_inet6.c-177-\terr = -ENOBUFS;\nnet/ipv6/af_inet6.c:178:\tsk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot, kern);\nnet/ipv6/af_inet6.c-179-\tif (!sk)\n--\nnet/ipv6/syncookies.c=131=static struct request_sock *cookie_tcp_check(struct net *net, struct sock *sk,\n--\nnet/ipv6/syncookies.c-167-\nnet/ipv6/syncookies.c:168:\treturn cookie_tcp_reqsk_alloc(\u0026tcp6_request_sock_ops, sk, skb,\nnet/ipv6/syncookies.c-169-\t\t\t\t \u0026tcp_opt, mss, tsoff);\n--\nnet/ipv6/tcp_ipv6.c=2066=static void tcp6_destruct_sock(struct sock *sk)\n--\nnet/ipv6/tcp_ipv6.c-2074-/* NOTE: A lot of things set to zero explicitly by call to\nnet/ipv6/tcp_ipv6.c:2075: * sk_alloc() so need not be done here.\nnet/ipv6/tcp_ipv6.c-2076- */\n--\nnet/iucv/af_iucv.c=477=static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio, int kern)\n--\nnet/iucv/af_iucv.c-481-\nnet/iucv/af_iucv.c:482:\tsk = sk_alloc(\u0026init_net, PF_IUCV, prio, \u0026iucv_proto, kern);\nnet/iucv/af_iucv.c-483-\tif (!sk)\n--\nnet/kcm/kcmsock.c=1528=static struct file *kcm_clone(struct socket *osock)\n--\nnet/kcm/kcmsock.c-1541-\nnet/kcm/kcmsock.c:1542:\tnewsk = sk_alloc(sock_net(osock-\u003esk), PF_KCM, GFP_KERNEL,\nnet/kcm/kcmsock.c-1543-\t\t\t \u0026kcm_proto, false);\n--\nnet/kcm/kcmsock.c=1789=static int kcm_create(struct net *net, struct socket *sock,\n--\nnet/kcm/kcmsock.c-1809-\nnet/kcm/kcmsock.c:1810:\tsk = sk_alloc(net, PF_KCM, GFP_KERNEL, \u0026kcm_proto, kern);\nnet/kcm/kcmsock.c-1811-\tif (!sk)\n--\nnet/key/af_key.c=138=static int pfkey_create(struct net *net, struct socket *sock, int protocol,\n--\nnet/key/af_key.c-151-\nnet/key/af_key.c:152:\tsk = sk_alloc(net, PF_KEY, GFP_KERNEL, \u0026key_proto, kern);\nnet/key/af_key.c-153-\tif (sk == NULL)\n--\nnet/l2tp/l2tp_ppp.c=470=static int pppol2tp_create(struct net *net, struct socket *sock, int kern)\n--\nnet/l2tp/l2tp_ppp.c-474-\nnet/l2tp/l2tp_ppp.c:475:\tsk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, \u0026pppol2tp_sk_proto, kern);\nnet/l2tp/l2tp_ppp.c-476-\tif (!sk)\n--\nnet/llc/af_llc.c=166=static int llc_ui_create(struct net *net, struct socket *sock, int protocol,\n--\nnet/llc/af_llc.c-179-\t\trc = -ENOMEM;\nnet/llc/af_llc.c:180:\t\tsk = llc_sk_alloc(net, PF_LLC, GFP_KERNEL, \u0026llc_proto, kern);\nnet/llc/af_llc.c-181-\t\tif (sk) {\n--\nnet/llc/llc_conn.c=753=static struct sock *llc_create_incoming_sock(struct sock *sk,\n--\nnet/llc/llc_conn.c-757-{\nnet/llc/llc_conn.c:758:\tstruct sock *newsk = llc_sk_alloc(sock_net(sk), sk-\u003esk_family, GFP_ATOMIC,\nnet/llc/llc_conn.c-759-\t\t\t\t\t sk-\u003esk_prot, 0);\n--\nnet/llc/llc_conn.c=884=static void llc_sk_init(struct sock *sk)\n--\nnet/llc/llc_conn.c-922- */\nnet/llc/llc_conn.c:923:struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority, struct proto *prot, int kern)\nnet/llc/llc_conn.c-924-{\nnet/llc/llc_conn.c:925:\tstruct sock *sk = sk_alloc(net, family, priority, prot, kern);\nnet/llc/llc_conn.c-926-\n--\nnet/mctp/af_mctp.c=799=static int mctp_pf_create(struct net *net, struct socket *sock,\n--\nnet/mctp/af_mctp.c-819-\nnet/mctp/af_mctp.c:820:\tsk = sk_alloc(net, PF_MCTP, GFP_KERNEL, proto, kern);\nnet/mctp/af_mctp.c-821-\tif (!sk)\n--\nnet/mptcp/subflow.c=732=static void subflow_v6_req_destructor(struct request_sock *req)\n--\nnet/mptcp/subflow.c-738-\nnet/mptcp/subflow.c:739:struct request_sock *mptcp_subflow_reqsk_alloc(const struct request_sock_ops *ops,\nnet/mptcp/subflow.c-740-\t\t\t\t\t struct sock *sk_listener,\n--\nnet/mptcp/subflow.c-749-\nnet/mptcp/subflow.c:750:\treturn inet_reqsk_alloc(ops, sk_listener, attach_listener);\nnet/mptcp/subflow.c-751-}\n--\nnet/netlink/af_netlink.c=616=static int __netlink_create(struct net *net, struct socket *sock,\n--\nnet/netlink/af_netlink.c-623-\nnet/netlink/af_netlink.c:624:\tsk = sk_alloc(net, PF_NETLINK, GFP_KERNEL, \u0026netlink_proto, kern);\nnet/netlink/af_netlink.c-625-\tif (!sk)\n--\nnet/nfc/llcp_sock.c=984=struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp, int kern)\n--\nnet/nfc/llcp_sock.c-988-\nnet/nfc/llcp_sock.c:989:\tsk = sk_alloc(\u0026init_net, PF_NFC, gfp, \u0026llcp_sock_proto, kern);\nnet/nfc/llcp_sock.c-990-\tif (!sk)\n--\nnet/nfc/rawsock.c=334=static int rawsock_create(struct net *net, struct socket *sock,\n--\nnet/nfc/rawsock.c-351-\nnet/nfc/rawsock.c:352:\tsk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto-\u003eproto, kern);\nnet/nfc/rawsock.c-353-\tif (!sk)\n--\nnet/openvswitch/flow_table.c=956=void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow)\n--\nnet/openvswitch/flow_table.c-964-\nnet/openvswitch/flow_table.c:965:static struct sw_flow_mask *mask_alloc(void)\nnet/openvswitch/flow_table.c-966-{\n--\nnet/openvswitch/flow_table.c=1006=static int flow_mask_insert(struct flow_table *tbl, struct sw_flow *flow,\n--\nnet/openvswitch/flow_table.c-1013-\t\t/* Allocate a new mask if none exists. */\nnet/openvswitch/flow_table.c:1014:\t\tmask = mask_alloc();\nnet/openvswitch/flow_table.c-1015-\t\tif (!mask)\n\n"
} |
| 31/3 | 2026/09/26 18:44 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 22116 output: 36 thoughts: 93 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience: **Investigating TCP Socket Initialization in the Linux Kernel** Alright, I'm diving into this TCP socket initialization code. I immediately picked up on a recurring comment in `net/ipv4/tcp.c`, `net/ipv4/tcp_ipv4.c`, and `net/ipv6/tcp_ipv6.c`—that "A lot of things [are] set to zero explicitly by a call to `sk_alloc()` so [they] need not be done here." That's a classic hint about memory management and initialization optimization, and it triggers a specific question in my mind: just *how* is that `sk_alloc()` call setting things to zero? My next step is clear. I need to understand what `sk_prot_alloc` is doing within `net/core/sock.c`, as `sk_alloc` presumably calls it. I'll need to confirm exactly what's being initialized and, critically, what's *not* being initialized by the kernel during socket creation. I want to identify the performance implications of this approach. Any further investigation would involve looking at how the `sock` struct is defined, how `sk_prot_alloc` actually allocates the memory, and what other data members are zeroed, and how that impacts latency at socket creation. This seems like a reasonable place to start digging deeper into the TCP implementation details. |
| 32/3 | 2026/09/26 18:44 | tool | read-file |
0mArgs:{
"File": "net/core/sock.c",
"FirstLine": 2238,
"LineCount": 40
}Results: {
"Contents": "2238:\tstatic struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,\n2239:\t\t\tint family)\n2240:\t{\n2241:\t\tstruct sock *sk;\n2242:\t\tstruct kmem_cache *slab;\n2243:\t\n2244:\t\tslab = prot-\u003eslab;\n2245:\t\tif (slab != NULL) {\n2246:\t\t\tsk = kmem_cache_alloc(slab, priority \u0026 ~__GFP_ZERO);\n2247:\t\t\tif (!sk)\n2248:\t\t\t\treturn sk;\n2249:\t\t\tif (want_init_on_alloc(priority))\n2250:\t\t\t\tsk_prot_clear_nulls(sk, prot-\u003eobj_size);\n2251:\t\t} else\n2252:\t\t\tsk = kmalloc(prot-\u003eobj_size, priority);\n2253:\t\n2254:\t\tif (sk != NULL) {\n2255:\t\t\tif (security_sk_alloc(sk, family, priority))\n2256:\t\t\t\tgoto out_free;\n2257:\t\n2258:\t\t\tif (!try_module_get(prot-\u003eowner))\n2259:\t\t\t\tgoto out_free_sec;\n2260:\t\t}\n2261:\t\n2262:\t\treturn sk;\n2263:\t\n2264:\tout_free_sec:\n2265:\t\tsecurity_sk_free(sk);\n2266:\tout_free:\n2267:\t\tif (slab != NULL)\n2268:\t\t\tkmem_cache_free(slab, sk);\n2269:\t\telse\n2270:\t\t\tkfree(sk);\n2271:\t\treturn NULL;\n2272:\t}\n2273:\t\n2274:\tstatic void sk_prot_free(struct proto *prot, struct sock *sk)\n2275:\t{\n2276:\t\tstruct kmem_cache *slab;\n2277:\t\tstruct module *owner;\n"
} |
| 33/3 | 2026/09/26 18:44 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23095 output: 36 thoughts: 34 Thoughts: Here's a breakdown of my thought process: **Diving into `sk_alloc` in `net/core/sock.c`** Okay, so I'm focusing back on the `sk_alloc` function. I need to refresh my understanding of its complete implementation. I know it's a critical function for socket creation, so I'm specifically targeting lines 2300 to 2340 in `net/core/sock.c`. I need a holistic view and not just fragments. This segment should show me the mechanics. It might be good to review the adjacent lines later, but for now I'm concentrating on this specific block. This should give me a good sense of its behavior. |
| 34/3 | 2026/09/26 18:44 | tool | read-file |
0mArgs:{
"File": "net/core/sock.c",
"FirstLine": 2300,
"LineCount": 40
}Results: {
"Contents": "2300:\t *\t@prot: struct proto associated with this new sock instance\n2301:\t *\t@kern: is this to be a kernel socket?\n2302:\t */\n2303:\tstruct sock *sk_alloc(struct net *net, int family, gfp_t priority,\n2304:\t\t\t struct proto *prot, int kern)\n2305:\t{\n2306:\t\tstruct sock *sk;\n2307:\t\n2308:\t\tsk = sk_prot_alloc(prot, priority | __GFP_ZERO, family);\n2309:\t\tif (sk) {\n2310:\t\t\tsk-\u003esk_family = family;\n2311:\t\t\t/*\n2312:\t\t\t * See comment in struct sock definition to understand\n2313:\t\t\t * why we need sk_prot_creator -acme\n2314:\t\t\t */\n2315:\t\t\tsk-\u003esk_prot = sk-\u003esk_prot_creator = prot;\n2316:\t\n2317:\t\t\tif (READ_ONCE(net-\u003ecore.sysctl_bypass_prot_mem))\n2318:\t\t\t\tsk-\u003esk_bypass_prot_mem = 1;\n2319:\t\n2320:\t\t\tsk-\u003esk_kern_sock = kern;\n2321:\t\t\tsock_lock_init(sk);\n2322:\t\n2323:\t\t\tsk-\u003esk_net_refcnt = kern ? 0 : 1;\n2324:\t\t\tif (likely(sk-\u003esk_net_refcnt)) {\n2325:\t\t\t\tget_net_track(net, \u0026sk-\u003ens_tracker, priority);\n2326:\t\t\t\tsock_inuse_add(net, 1);\n2327:\t\t\t} else {\n2328:\t\t\t\tnet_passive_inc(net);\n2329:\t\t\t\t__netns_tracker_alloc(net, \u0026sk-\u003ens_tracker,\n2330:\t\t\t\t\t\t false, priority);\n2331:\t\t\t}\n2332:\t\n2333:\t\t\tsock_net_set(sk, net);\n2334:\t\t\trefcount_set(\u0026sk-\u003esk_wmem_alloc, SK_WMEM_ALLOC_BIAS);\n2335:\t\n2336:\t\t\tmem_cgroup_sk_alloc(sk);\n2337:\t\t\tcgroup_sk_alloc(\u0026sk-\u003esk_cgrp_data);\n2338:\t\t\tsock_update_classid(\u0026sk-\u003esk_cgrp_data);\n2339:\t\t\tsock_update_netprioidx(\u0026sk-\u003esk_cgrp_data);\n"
} |
| 35/3 | 2026/09/26 18:44 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23985 output: 35 thoughts: 247 Thoughts: **Investigating the Socket Allocation in `sk_prot_alloc`** Okay, let's dive into this `sk_prot_alloc` function. Looking at line 2246, the allocation happens with `kmem_cache_alloc`. But hold on... look at that bitwise AND: `priority & ~__GFP_ZERO`! Why are we stripping the `__GFP_ZERO` flag? That's immediately suspect. Alright, let's get the context; examining lines 2244-2252 clears things up. We check for a `slab`, and if it exists, allocate from the slab with that modified priority. But wait, if we're *not* using `__GFP_ZERO`, how are we ensuring that the `tcp_sock` or other socket-specific fields are initialized? This is a critical point. Is there a constructor associated with this slab? Or, how is `tcp_sock` initialized? I need to check the `tcp_v4_init_sock` function, or the constructor for the `tcp_prot` struct itself. I need to understand this initialization flow, because it's the bit that's missing here. |
| 36/3 | 2026/09/26 18:44 | tool | grepper |
0mArgs:{
"Expression": "\\.slab.*=",
"PathPrefix": "net/ipv4/tcp_ipv4.c"
}Results: {
"Output": "net/ipv4/tcp_ipv4.c=3347=struct proto tcp_prot = {\n--\nnet/ipv4/tcp_ipv4.c-3390-\t\t\t\t\t inet_conn.icsk_inet.sk.sk_freeptr),\nnet/ipv4/tcp_ipv4.c:3391:\t.slab_flags\t\t= SLAB_TYPESAFE_BY_RCU,\nnet/ipv4/tcp_ipv4.c-3392-\t.twsk_prot\t\t= \u0026tcp_timewait_sock_ops,\n"
} |
| 37/3 | 2026/09/26 18:44 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24672 output: 33 thoughts: 28 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Diving into IPv4 TCP Socket Initialization** Okay, time to get to the heart of this. My focus is on understanding the network stack's TCP socket initialization sequence for IPv4. I'm going to pinpoint the `tcp_v4_init_sock` function, specifically within `net/ipv4/tcp_ipv4.c`. I expect to find the core logic responsible for setting up the fundamental data structures and initial parameters for a new TCP connection on an IPv4 network. I’m particularly interested in how the socket structure (`struct sock`) gets populated, how the TCP control block (`struct tcp_sock`) is initialized and the interaction with the IPv4 layer. I’m also looking for any specific IPv4-related options or adjustments made during this process – any hooks into the IP protocol stack, for example, or any IPv4-specific socket options that are handled. I anticipate seeing the configuration of socket options, buffer sizes, and connection state flags. |
| 38/3 | 2026/09/26 18:44 | tool | grepper |
0mArgs:{
"Expression": "tcp_v4_init_sock",
"PathPrefix": "net/ipv4/"
}Results: {
"Output": "net/ipv4/tcp_ipv4.c=2385=static void tcp4_destruct_sock(struct sock *sk)\n--\nnet/ipv4/tcp_ipv4.c-2395- */\nnet/ipv4/tcp_ipv4.c:2396:static int tcp_v4_init_sock(struct sock *sk)\nnet/ipv4/tcp_ipv4.c-2397-{\n--\nnet/ipv4/tcp_ipv4.c=3347=struct proto tcp_prot = {\n--\nnet/ipv4/tcp_ipv4.c-3355-\t.ioctl\t\t\t= tcp_ioctl,\nnet/ipv4/tcp_ipv4.c:3356:\t.init\t\t\t= tcp_v4_init_sock,\nnet/ipv4/tcp_ipv4.c-3357-\t.destroy\t\t= tcp_v4_destroy_sock,\n"
} |
| 39/3 | 2026/09/26 18:44 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25192 output: 40 thoughts: 25 Thoughts: Okay, here's my interpretation of what's going on, thinking through this as I read the code: **Analyzing `net/ipv4/tcp_ipv4.c` Around Line 2396** Alright, I'm heading over to `net/ipv4/tcp_ipv4.c` and specifically focusing around line 2396. I know this area of the code has always been interesting, so I'm paying close attention. I'm probably looking at something related to... (I'll fill in the rest of the thoughts as the code provides further information). |
| 40/3 | 2026/09/26 18:44 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp_ipv4.c",
"FirstLine": 2390,
"LineCount": 40
}Results: {
"Contents": "2390:\t}\n2391:\t#endif\n2392:\t\n2393:\t/* NOTE: A lot of things set to zero explicitly by call to\n2394:\t * sk_alloc() so need not be done here.\n2395:\t */\n2396:\tstatic int tcp_v4_init_sock(struct sock *sk)\n2397:\t{\n2398:\t\tstruct inet_connection_sock *icsk = inet_csk(sk);\n2399:\t\n2400:\t\ttcp_init_sock(sk);\n2401:\t\n2402:\t\ticsk-\u003eicsk_af_ops = \u0026ipv4_specific;\n2403:\t\n2404:\t#if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO)\n2405:\t\ttcp_sk(sk)-\u003eaf_specific = \u0026tcp_sock_ipv4_specific;\n2406:\t\tsk-\u003esk_destruct = tcp4_destruct_sock;\n2407:\t#endif\n2408:\t\n2409:\t\treturn 0;\n2410:\t}\n2411:\t\n2412:\tstatic void tcp_release_user_frags(struct sock *sk)\n2413:\t{\n2414:\t#ifdef CONFIG_PAGE_POOL\n2415:\t\tunsigned long index;\n2416:\t\tvoid *netmem;\n2417:\t\n2418:\t\txa_for_each(\u0026sk-\u003esk_user_frags, index, netmem)\n2419:\t\t\tWARN_ON_ONCE(!napi_pp_put_page((__force netmem_ref)netmem));\n2420:\t#endif\n2421:\t}\n2422:\t\n2423:\tvoid tcp_v4_destroy_sock(struct sock *sk)\n2424:\t{\n2425:\t\tstruct tcp_sock *tp = tcp_sk(sk);\n2426:\t\n2427:\t\ttcp_release_user_frags(sk);\n2428:\t\n2429:\t\txa_destroy(\u0026sk-\u003esk_user_frags);\n"
} |
| 41/3 | 2026/09/26 18:44 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25966 output: 32 thoughts: 11 Thoughts: Okay, let's dive into this. Here's my thought process as I approach the code: **Checking `tcp_init_sock`** Alright, the instruction is clear: I need to take a look at `tcp_init_sock`. This probably means I'm troubleshooting, debugging, or maybe just reviewing this part of the TCP stack. My immediate mental checklist starts: what are the likely areas of concern within this function? I'm anticipating initialization of data structures, setting up socket options, potentially binding to an address, and perhaps some initial state transitions. I'll need to pay close attention to memory allocation, error handling, and any interactions with the lower layers of the network stack. Specifically, I'll be looking for potential race conditions, resource leaks, or inefficient initialization routines. I will begin by examining the function's signature and local variable declarations, and then move methodically through the code, noting important calls to other functions, and looking at how data is passed and handled. I'm keeping an eye out for potential design flaws and areas that might become bottlenecks under heavy load. I want to see if this is handling both IPv4 and IPv6 traffic. I'll probably cross reference this code with other related functions like `tcp_connect` and `tcp_accept` to see how the initial setup affects those operations. Let's see what we've got. |
| 42/3 | 2026/09/26 18:45 | tool | grepper |
0mArgs:{
"Expression": "void tcp_init_sock\\(",
"PathPrefix": "net/ipv4/"
}Results: {
"Output": "net/ipv4/tcp.c=402=void tcp_md5_destruct_sock(struct sock *sk)\n--\nnet/ipv4/tcp.c-419- */\nnet/ipv4/tcp.c:420:void tcp_init_sock(struct sock *sk)\nnet/ipv4/tcp.c-421-{\n"
} |
| 43/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26397 output: 36 thoughts: 20 Thoughts: Okay, let's dive into this. Here's my take on those lines in `net/ipv4/tcp.c`, specifically around line 420: **Analyzing the TCP Source Code** Alright, I'm thinking, let's go straight to the heart of the matter. My mental cursor is already hovering over `net/ipv4/tcp.c`, specifically around line 420. I'm focusing on that section because, based on the context, I suspect it's dealing with a core TCP mechanism. I need to understand what's happening at this point in the code's execution. What decisions are being made? What data structures are in play? Is this related to connection establishment, data transmission, congestion control, or error handling? I need to quickly identify the crucial variables and functions at play in order to understand the flow control. What is the architecture behind this implementation? And how can I apply it to my current concerns? |
| 44/3 | 2026/09/26 18:45 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp.c",
"FirstLine": 415,
"LineCount": 60
}Results: {
"Contents": " 415:\t/* Address-family independent initialization for a tcp_sock.\n 416:\t *\n 417:\t * NOTE: A lot of things set to zero explicitly by call to\n 418:\t * sk_alloc() so need not be done here.\n 419:\t */\n 420:\tvoid tcp_init_sock(struct sock *sk)\n 421:\t{\n 422:\t\tstruct inet_connection_sock *icsk = inet_csk(sk);\n 423:\t\tstruct tcp_sock *tp = tcp_sk(sk);\n 424:\t\tint rto_min_us, rto_max_ms;\n 425:\t\n 426:\t\ttp-\u003eout_of_order_queue = RB_ROOT;\n 427:\t\tsk-\u003etcp_rtx_queue = RB_ROOT;\n 428:\t\ttcp_init_xmit_timers(sk);\n 429:\t\tINIT_LIST_HEAD(\u0026tp-\u003etsq_node);\n 430:\t\tINIT_LIST_HEAD(\u0026tp-\u003etsorted_sent_queue);\n 431:\t\n 432:\t\ticsk-\u003eicsk_rto = TCP_TIMEOUT_INIT;\n 433:\t\n 434:\t\trto_max_ms = READ_ONCE(sock_net(sk)-\u003eipv4.sysctl_tcp_rto_max_ms);\n 435:\t\ticsk-\u003eicsk_rto_max = msecs_to_jiffies(rto_max_ms);\n 436:\t\n 437:\t\trto_min_us = READ_ONCE(sock_net(sk)-\u003eipv4.sysctl_tcp_rto_min_us);\n 438:\t\ticsk-\u003eicsk_rto_min = usecs_to_jiffies(rto_min_us);\n 439:\t\ticsk-\u003eicsk_delack_max = TCP_DELACK_MAX;\n 440:\t\ttp-\u003emdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);\n 441:\t\tminmax_reset(\u0026tp-\u003ertt_min, tcp_jiffies32, ~0U);\n 442:\t\n 443:\t\t/* So many TCP implementations out there (incorrectly) count the\n 444:\t\t * initial SYN frame in their delayed-ACK and congestion control\n 445:\t\t * algorithms that we must have the following bandaid to talk\n 446:\t\t * efficiently to them. -DaveM\n 447:\t\t */\n 448:\t\ttcp_snd_cwnd_set(tp, TCP_INIT_CWND);\n 449:\t\n 450:\t\t/* There's a bubble in the pipe until at least the first ACK. */\n 451:\t\ttp-\u003eapp_limited = ~0U;\n 452:\t\ttp-\u003erate_app_limited = 1;\n 453:\t\n 454:\t\t/* See draft-stevens-tcpca-spec-01 for discussion of the\n 455:\t\t * initialization of these values.\n 456:\t\t */\n 457:\t\ttp-\u003esnd_ssthresh = TCP_INFINITE_SSTHRESH;\n 458:\t\ttp-\u003esnd_cwnd_clamp = ~0;\n 459:\t\ttp-\u003emss_cache = TCP_MSS_DEFAULT;\n 460:\t\n 461:\t\ttp-\u003ereordering = READ_ONCE(sock_net(sk)-\u003eipv4.sysctl_tcp_reordering);\n 462:\t\ttcp_assign_congestion_control(sk);\n 463:\t\n 464:\t\ttp-\u003etsoffset = 0;\n 465:\t\ttp-\u003erack.reo_wnd_steps = 1;\n 466:\t\n 467:\t\tsk-\u003esk_write_space = sk_stream_write_space;\n 468:\t\tsock_set_flag(sk, SOCK_USE_WRITE_QUEUE);\n 469:\t\n 470:\t\ticsk-\u003eicsk_sync_mss = tcp_sync_mss;\n 471:\t\n 472:\t\tWRITE_ONCE(sk-\u003esk_sndbuf, READ_ONCE(sock_net(sk)-\u003eipv4.sysctl_tcp_wmem[1]));\n 473:\t\tWRITE_ONCE(sk-\u003esk_rcvbuf, READ_ONCE(sock_net(sk)-\u003eipv4.sysctl_tcp_rmem[1]));\n 474:\t\ttcp_scaling_ratio_init(sk);\n"
} |
| 45/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27812 output: 22 thoughts: 171 Thoughts: Okay, let me break this down.
**Investigating Socket Memory Allocation and Initialization**
Hold on a second... I need to clarify something in the socket allocation process. I'm seeing a potential initialization discrepancy in how `sk_prot_alloc` manages memory if `prot->slab` isn't null. I need to understand this better. Let's delve into the code for `sk_prot_alloc`:
```c
slab = prot->slab;
if (slab != NULL) {
sk = kmem_cache_alloc(slab, priority & ~__GFP_ZERO);
if (!sk)
return sk;
if (want_init_on_alloc(priority))
sk_prot_clear_nulls(sk, prot->obj_size);
} else
sk = kmalloc(prot->obj_size, priority);
```
Right, it's pretty straightforward, but that `sk_prot_clear_nulls` call has me curious. If a slab is used, we have `kmem_cache_alloc` but initialization is conditional on `want_init_on_alloc` - this requires immediate inspection. Where is this function defined and what exactly does it accomplish? I need to understand how it interacts with the allocation path when using a slab. This could be crucial for performance and security implications regarding uninitialized memory.
|
| 46/3 | 2026/09/26 18:45 | tool | grepper |
0mArgs:{
"Expression": "sk_prot_clear_nulls"
}Results: {
"Output": "include/net/sock.h=1269=struct sk_psock;\n--\ninclude/net/sock.h-1274- */\ninclude/net/sock.h:1275:static inline void sk_prot_clear_nulls(struct sock *sk, int size)\ninclude/net/sock.h-1276-{\n--\nnet/core/sock.c=2238=static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,\n--\nnet/core/sock.c-2249-\t\tif (want_init_on_alloc(priority))\nnet/core/sock.c:2250:\t\t\tsk_prot_clear_nulls(sk, prot-\u003eobj_size);\nnet/core/sock.c-2251-\t} else\n"
} |
| 47/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28515 output: 36 thoughts: 20 Thoughts: Okay, let's dive into this. Here's my take on those lines in `include/net/sock.h`: **Analyzing `include/net/sock.h` Around Line 1275** Alright, I'm heading over to `include/net/sock.h`, specifically around line 1275. Given my experience, I'm expecting to find something fundamental to socket operations there. That location is usually in the heart of the socket structure's definition or related to fundamental socket operations. I imagine there is some critical data structure defining the kernel socket itself, or perhaps a core function pointer or macro definition central to socket creation, handling or destruction. The context here should indicate how the kernel manages network sockets. I anticipate it will reveal a crucial data structure for socket management or fundamental operational logic. |
| 48/3 | 2026/09/26 18:45 | tool | read-file |
0mArgs:{
"File": "include/net/sock.h",
"FirstLine": 1270,
"LineCount": 25
}Results: {
"Contents": "1270:\t\n1271:\t/*\n1272:\t * caches using SLAB_TYPESAFE_BY_RCU should let .next pointer from nulls nodes\n1273:\t * un-modified. Special care is taken when initializing object to zero.\n1274:\t */\n1275:\tstatic inline void sk_prot_clear_nulls(struct sock *sk, int size)\n1276:\t{\n1277:\t\tif (offsetof(struct sock, sk_node.next) != 0)\n1278:\t\t\tmemset(sk, 0, offsetof(struct sock, sk_node.next));\n1279:\t\tmemset(\u0026sk-\u003esk_node.pprev, 0,\n1280:\t\t size - offsetof(struct sock, sk_node.pprev));\n1281:\t}\n1282:\t\n1283:\tstruct proto_accept_arg {\n1284:\t\tint flags;\n1285:\t\tint err;\n1286:\t\tint is_empty;\n1287:\t\tbool kern;\n1288:\t};\n1289:\t\n1290:\t/* Networking protocol blocks we attach to sockets.\n1291:\t * socket layer -\u003e transport layer interface\n1292:\t */\n1293:\tstruct proto {\n1294:\t\tvoid\t\t\t(*close)(struct sock *sk,\n"
} |
| 49/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29113 output: 21 thoughts: 81 Thoughts: Okay, here's my breakdown of what I'm looking at: **Clearing and Initialization Concerns** Alright, so `sk_prot_clear_nulls` is wiping the entire object, the whole shebang – `size` bytes of it, with the exception of `sk_node.next`. That's a pretty aggressive clearing operation. Now, a red flag is starting to wave in my mind: what happens if `want_init_on_alloc(priority)` returns false? Does this clear operation happen regardless? Is that correct? I need to confirm if that's the intended behavior and understand what consequences this might have. This leads to the next question, which is what `want_init_on_alloc` does and how it's defined. Time to look up that function definition and see what it is all about. |
| 50/3 | 2026/09/26 18:45 | tool | grepper |
0mArgs:{
"Expression": "want_init_on_alloc"
}Results: {
"Output": "drivers/infiniband/core/ib_core_uverbs.c=563=__malloc void *_uverbs_alloc(struct uverbs_attr_bundle *bundle, size_t size,\n--\ndrivers/infiniband/core/ib_core_uverbs.c-587-\t\tALIGN(new_used, sizeof(*pbundle-\u003einternal_buffer));\ndrivers/infiniband/core/ib_core_uverbs.c:588:\tif (want_init_on_alloc(flags))\ndrivers/infiniband/core/ib_core_uverbs.c-589-\t\tmemset(res, 0, size);\n--\ninclude/linux/mm.h=4943=DECLARE_STATIC_KEY_MAYBE(CONFIG_INIT_ON_ALLOC_DEFAULT_ON, init_on_alloc);\ninclude/linux/mm.h:4944:static inline bool want_init_on_alloc(gfp_t flags)\ninclude/linux/mm.h-4945-{\n--\nmm/dmapool.c=96=static void pool_check_block(struct dma_pool *pool, struct dma_block *block,\n--\nmm/dmapool.c-116-\nmm/dmapool.c:117:\tif (!want_init_on_alloc(mem_flags))\nmm/dmapool.c-118-\t\tmemset(block, POOL_POISON_ALLOCATED, pool-\u003esize);\n--\nmm/dmapool.c=407=void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,\n--\nmm/dmapool.c-436-\tpool_check_block(pool, block, mem_flags);\nmm/dmapool.c:437:\tif (want_init_on_alloc(mem_flags))\nmm/dmapool.c-438-\t\tmemset(block, 0, pool-\u003esize);\n--\nmm/kfence/core.c=425=static void *kfence_guarded_alloc(struct kmem_cache *cache, size_t size, gfp_t gfp,\n--\nmm/kfence/core.c-506-\t/*\nmm/kfence/core.c:507:\t * We check slab_want_init_on_alloc() ourselves, rather than letting\nmm/kfence/core.c-508-\t * slab do the initialization, as otherwise it might overwrite KFENCE's\n--\nmm/kfence/core.c-510-\t */\nmm/kfence/core.c:511:\tif (unlikely(slab_want_init_on_alloc(gfp, cache)))\nmm/kfence/core.c-512-\t\tmemzero_explicit(addr, size);\n--\nmm/mm_init.c=2534=static void __init report_meminit(void)\n--\nmm/mm_init.c-2545-\tpr_info(\"mem auto-init: stack:%s, heap alloc:%s, heap free:%s\\n\",\nmm/mm_init.c:2546:\t\tstack, str_on_off(want_init_on_alloc(GFP_KERNEL)),\nmm/mm_init.c-2547-\t\tstr_on_off(want_init_on_free()));\n--\nmm/page_alloc.c=1821=inline void post_alloc_hook(struct page *page, unsigned int order,\n--\nmm/page_alloc.c-1824-\tconst bool zero_tags = gfp_flags \u0026 __GFP_ZEROTAGS;\nmm/page_alloc.c:1825:\tbool init = !want_init_on_free() \u0026\u0026 want_init_on_alloc(gfp_flags) \u0026\u0026\nmm/page_alloc.c-1826-\t\t\t!should_skip_init(gfp_flags);\n--\nmm/slab.h=900=static inline void cache_random_seq_destroy(struct kmem_cache *cachep) { }\n--\nmm/slab.h-902-\nmm/slab.h:903:static inline bool slab_want_init_on_alloc(gfp_t flags, struct kmem_cache *c)\nmm/slab.h-904-{\n--\nmm/slub.c=4645=bool slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags, size_t size,\n--\nmm/slub.c-4647-{\nmm/slub.c:4648:\tbool init = slab_want_init_on_alloc(flags, s);\nmm/slub.c-4649-\tunsigned int zero_size = s-\u003eobject_size;\n--\nmm/slub.c=6874=__do_krealloc(const void *p, size_t new_size, unsigned long align, gfp_t flags, int nid, kmalloc_token_t token)\n--\nmm/slub.c-6924-\t/* Zero out spare memory. */\nmm/slub.c:6925:\tif (want_init_on_alloc(flags)) {\nmm/slub.c-6926-\t\tkasan_disable_current();\n--\nmm/vmalloc.c=4025=void *__vmalloc_node_range_noprof(unsigned long size, unsigned long align,\n--\nmm/vmalloc.c-4116-\tkasan_flags |= KASAN_VMALLOC_VM_ALLOC;\nmm/vmalloc.c:4117:\tif (!want_init_on_free() \u0026\u0026 want_init_on_alloc(gfp_mask) \u0026\u0026\nmm/vmalloc.c-4118-\t (gfp_mask \u0026 __GFP_SKIP_ZERO))\n--\nmm/vmalloc.c=4337=void *vrealloc_node_align_noprof(const void *p, size_t size, unsigned long align,\n--\nmm/vmalloc.c-4379-\t\t/* Zero out \"freed\" memory, potentially for future realloc. */\nmm/vmalloc.c:4380:\t\tif (want_init_on_free() || want_init_on_alloc(flags))\nmm/vmalloc.c-4381-\t\t\tmemset((void *)p + size, 0, old_size - size);\n--\nnet/core/sock.c=2238=static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,\n--\nnet/core/sock.c-2248-\t\t\treturn sk;\nnet/core/sock.c:2249:\t\tif (want_init_on_alloc(priority))\nnet/core/sock.c-2250-\t\t\tsk_prot_clear_nulls(sk, prot-\u003eobj_size);\n"
} |
| 51/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 31091 output: 36 thoughts: 20 Thoughts: Here's a first-person summary, tailored for an expert audience, based on the prompt: **Diving into the Memory Management Header** Okay, time to get my hands dirty. Let's see... I'm going to jump into the heart of the matter – `include/linux/mm.h`. That's where all the fundamental memory management structures and definitions reside. I need to pinpoint a specific area, so I'm honing in on line 4943. Hopefully, that's the spot I'm thinking of, or at least a good starting point for my current investigation. Let's see what gems we can unearth there. |
| 52/3 | 2026/09/26 18:45 | tool | read-file |
0mArgs:{
"File": "include/linux/mm.h",
"FirstLine": 4940,
"LineCount": 20
}Results: {
"Contents": "4940:\tstatic inline void kernel_unpoison_pages(struct page *page, int numpages) { }\n4941:\t#endif\n4942:\t\n4943:\tDECLARE_STATIC_KEY_MAYBE(CONFIG_INIT_ON_ALLOC_DEFAULT_ON, init_on_alloc);\n4944:\tstatic inline bool want_init_on_alloc(gfp_t flags)\n4945:\t{\n4946:\t\tif (static_branch_maybe(CONFIG_INIT_ON_ALLOC_DEFAULT_ON,\n4947:\t\t\t\t\t\u0026init_on_alloc))\n4948:\t\t\treturn true;\n4949:\t\treturn flags \u0026 __GFP_ZERO;\n4950:\t}\n4951:\t\n4952:\tDECLARE_STATIC_KEY_MAYBE(CONFIG_INIT_ON_FREE_DEFAULT_ON, init_on_free);\n4953:\tstatic inline bool want_init_on_free(void)\n4954:\t{\n4955:\t\treturn static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON,\n4956:\t\t\t\t\t \u0026init_on_free);\n4957:\t}\n4958:\t\n4959:\textern bool _debug_pagealloc_enabled_early;\n"
} |
| 53/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 31629 output: 20 thoughts: 145 Thoughts: **Analyzing Socket Allocation and Cloning** Okay, let's break down this socket allocation process. I need to understand what's happening under the hood, especially concerning memory initialization and cloning. First, I'm looking at `sk_alloc`, specifically this line: `sk = sk_prot_alloc(prot, priority | __GFP_ZERO, family);`. Ah, right, we're passing in `__GFP_ZERO` along with the priority. That's immediately interesting. Now, let's delve into `sk_prot_alloc`. I can see it checks `if (want_init_on_alloc(priority))`. Since we've included `__GFP_ZERO` in the priority, I know `want_init_on_alloc` will return `true`. And that means `sk_prot_clear_nulls(sk, prot->obj_size);` gets called. Right, that function is going to zero out the entire socket structure, up to `prot->obj_size`. So, the entire struct is being initialized to zero when allocated. Good to know. But now, what happens during socket cloning? Specifically, I'm thinking about the scenario of `sk_clone_lock`. I need to figure out if this initialization behavior is preserved or if there are any potential gotchas there, especially if we're dealing with shared memory. I'll need to check the `sk_clone_lock` implementation itself. I should be able to figure it out by tracing the code. |
| 54/3 | 2026/09/26 18:45 | tool | grepper |
0mArgs:{
"Expression": "sk_clone_lock\\("
}Results: {
"Output": "include/net/inet_connection_sock.h=154=static inline void *inet_csk_ca(const struct sock *sk)\n--\ninclude/net/inet_connection_sock.h-158-\ninclude/net/inet_connection_sock.h:159:struct sock *inet_csk_clone_lock(const struct sock *sk,\ninclude/net/inet_connection_sock.h-160-\t\t\t\t const struct request_sock *req,\n--\ninclude/net/sock.h=1846=struct sock *sk_clone(const struct sock *sk, const gfp_t priority, bool lock);\ninclude/net/sock.h-1847-\ninclude/net/sock.h:1848:static inline struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)\ninclude/net/sock.h-1849-{\n--\nnet/core/sock.c=2210=static void sock_copy(struct sock *nsk, const struct sock *osk)\n--\nnet/core/sock.c-2218-\t * we must check if sk_tx_queue_clear() is called after\nnet/core/sock.c:2219:\t * sock_copy() in sk_clone_lock().\nnet/core/sock.c-2220-\t */\n--\nnet/ipv4/inet_connection_sock.c=1185=static void inet_clone_ulp(const struct request_sock *req, struct sock *newsk,\n--\nnet/ipv4/inet_connection_sock.c-1203- */\nnet/ipv4/inet_connection_sock.c:1204:struct sock *inet_csk_clone_lock(const struct sock *sk,\nnet/ipv4/inet_connection_sock.c-1205-\t\t\t\t const struct request_sock *req,\n--\nnet/ipv4/inet_connection_sock.c-1207-{\nnet/ipv4/inet_connection_sock.c:1208:\tstruct sock *newsk = sk_clone_lock(sk, priority);\nnet/ipv4/inet_connection_sock.c-1209-\tstruct inet_connection_sock *newicsk;\n--\nnet/ipv4/tcp_bpf.c=725=int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore)\n--\nnet/ipv4/tcp_bpf.c-744-\t\t\tWRITE_ONCE(sk-\u003esk_write_space, psock-\u003esaved_write_space);\nnet/ipv4/tcp_bpf.c:745:\t\t\t/* Pairs with lockless read in sk_clone_lock() */\nnet/ipv4/tcp_bpf.c-746-\t\t\tsock_replace_proto(sk, psock-\u003esk_proto);\n--\nnet/ipv4/tcp_bpf.c-757-\nnet/ipv4/tcp_bpf.c:758:\t/* Pairs with lockless read in sk_clone_lock() */\nnet/ipv4/tcp_bpf.c-759-\tsock_replace_proto(sk, \u0026tcp_bpf_prots[family][config]);\n--\nnet/ipv4/tcp_minisocks.c=546=struct sock *tcp_create_openreq_child(const struct sock *sk,\n--\nnet/ipv4/tcp_minisocks.c-549-{\nnet/ipv4/tcp_minisocks.c:550:\tstruct sock *newsk = inet_csk_clone_lock(sk, req, GFP_ATOMIC);\nnet/ipv4/tcp_minisocks.c-551-\tconst struct inet_request_sock *ireq = inet_rsk(req);\n--\nnet/mptcp/protocol.c=3709=struct sock *mptcp_sk_clone_init(const struct sock *sk,\n--\nnet/mptcp/protocol.c-3714-\tstruct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req);\nnet/mptcp/protocol.c:3715:\tstruct sock *nsk = sk_clone_lock(sk, GFP_ATOMIC);\nnet/mptcp/protocol.c-3716-\tstruct mptcp_subflow_context *subflow;\n--\nnet/tls/tls_main.c=1069=static void tls_update(struct sock *sk, struct proto *p,\n--\nnet/tls/tls_main.c-1080-\t} else {\nnet/tls/tls_main.c:1081:\t\t/* Pairs with lockless read in sk_clone_lock(). */\nnet/tls/tls_main.c-1082-\t\tWRITE_ONCE(sk-\u003esk_prot, p);\n"
} |
| 55/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33321 output: 31 thoughts: 19 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Diving into `sk_clone` in `net/core/sock.c`** Alright, let's take a look at the `sk_clone` function within `net/core/sock.c`. My immediate goal is to understand how socket structures are cloned, specifically within the kernel. I'm focusing on this function because understanding its behavior is critical for analyzing connection management, especially when dealing with scenarios like connection duplication or delegation within the networking stack. I need to refresh my memory about how the reference counts are managed during this process, what aspects of the socket are deep-copied versus shallow-copied, and if there are any potential race conditions or locking issues I should be aware of when examining the function. |
| 56/3 | 2026/09/26 18:45 | tool | grepper |
0mArgs:{
"Expression": "sk_clone\\(",
"PathPrefix": "net/core/sock.c"
}Results: {
"Output": "net/core/sock.c=2210=static void sock_copy(struct sock *nsk, const struct sock *osk)\n--\nnet/core/sock.c-2233-\tnsk-\u003esk_security = sptr;\nnet/core/sock.c:2234:\tsecurity_sk_clone(osk, nsk);\nnet/core/sock.c-2235-#endif\n--\nnet/core/sock.c=2445=static void sk_init_common(struct sock *sk)\n--\nnet/core/sock.c-2479- */\nnet/core/sock.c:2480:struct sock *sk_clone(const struct sock *sk, const gfp_t priority,\nnet/core/sock.c-2481-\t\t bool lock)\n--\nnet/core/sock.c-2550-\nnet/core/sock.c:2551:\tcgroup_sk_clone(\u0026newsk-\u003esk_cgrp_data);\nnet/core/sock.c-2552-\n"
} |
| 57/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33808 output: 36 thoughts: 31 Thoughts: Okay, let's dive into this. I'm going to take a look at the `sock_copy` function within `net/core/sock.c`, specifically lines 2210 to 2235. My expertise tells me this is where some core socket operations are likely handled, probably dealing with data transfer between different kernel buffers or userspace and kernel space. I'm expecting to see something related to data copying, either directly or indirectly through some sort of indirect buffer mapping. I'll be looking for any potential optimization tricks, like scatter/gather operations, or possible bottlenecks. I'll also try to infer the context around this function, looking for any conditional calls or error handling that could give me some hints to understand how this is used within the wider socket stack. This is all standard fare, just checking what I'd expect here. |
| 58/3 | 2026/09/26 18:45 | tool | read-file |
0mArgs:{
"File": "net/core/sock.c",
"FirstLine": 2210,
"LineCount": 30
}Results: {
"Contents": "2210:\tstatic void sock_copy(struct sock *nsk, const struct sock *osk)\n2211:\t{\n2212:\t\tconst struct proto *prot = READ_ONCE(osk-\u003esk_prot);\n2213:\t#ifdef CONFIG_SECURITY_NETWORK\n2214:\t\tvoid *sptr = nsk-\u003esk_security;\n2215:\t#endif\n2216:\t\n2217:\t\t/* If we move sk_tx_queue_mapping out of the private section,\n2218:\t\t * we must check if sk_tx_queue_clear() is called after\n2219:\t\t * sock_copy() in sk_clone_lock().\n2220:\t\t */\n2221:\t\tBUILD_BUG_ON(offsetof(struct sock, sk_tx_queue_mapping) \u003c\n2222:\t\t\t offsetof(struct sock, sk_dontcopy_begin) ||\n2223:\t\t\t offsetof(struct sock, sk_tx_queue_mapping) \u003e=\n2224:\t\t\t offsetof(struct sock, sk_dontcopy_end));\n2225:\t\n2226:\t\tmemcpy(nsk, osk, offsetof(struct sock, sk_dontcopy_begin));\n2227:\t\n2228:\t\tunsafe_memcpy(\u0026nsk-\u003esk_dontcopy_end, \u0026osk-\u003esk_dontcopy_end,\n2229:\t\t\t prot-\u003eobj_size - offsetof(struct sock, sk_dontcopy_end),\n2230:\t\t\t /* alloc is larger than struct, see sk_prot_alloc() */);\n2231:\t\n2232:\t#ifdef CONFIG_SECURITY_NETWORK\n2233:\t\tnsk-\u003esk_security = sptr;\n2234:\t\tsecurity_sk_clone(osk, nsk);\n2235:\t#endif\n2236:\t}\n2237:\t\n2238:\tstatic struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,\n2239:\t\t\tint family)\n"
} |
| 59/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34575 output: 33 thoughts: 16 Thoughts: Okay, let's dive into this `tcp_create_openreq_child` function. I need to understand what's happening here. The name itself suggests we're dealing with creating a child request related to a TCP connection's opening phase. That's a critical point for any TCP implementation. I'm going to have to understand how this fits into the overall handshake process. I need to quickly recall the typical TCP handshake sequence. It's the SYN, SYN-ACK, ACK dance, right? So, this function is likely involved in either handling the SYN packet, generating the SYN-ACK, or managing the state transition of the connection during this establishment phase. My gut tells me this is probably on the server-side, handling an incoming SYN, but I need to confirm that. The "openreq" part... is that a data structure, a flag, or a concept related to the new connection request? I need to analyze how this `child` component connects to the *parent* connection object. What is the `child` representing? Is it an established socket or a placeholder? The keyword here is to understand the state transition and what this function is contributing to a given open connection. What is the scope of this function? Does it handle specific error conditions? Are there any resource limitations imposed in this method? I need to look closely at memory allocation. Memory leaks are a significant problem and must be fully analyzed! I'll be looking for references to connection queues, listen sockets, and how the connection details are being passed between processes or threads. Is this thread-safe? Concurrent connections are important and need to be considered. |
| 60/3 | 2026/09/26 18:45 | tool | grepper |
0mArgs:{
"Expression": "tcp_create_openreq_child",
"PathPrefix": "net/ipv4/"
}Results: {
"Output": "net/ipv4/inet_connection_sock.c=1294=void inet_csk_prepare_for_destroy_sock(struct sock *sk)\n--\nnet/ipv4/inet_connection_sock.c-1302-/* This function allows to force a closure of a socket after the call to\nnet/ipv4/inet_connection_sock.c:1303: * tcp_create_openreq_child().\nnet/ipv4/inet_connection_sock.c-1304- */\n--\nnet/ipv4/tcp_ao.c=918=void tcp_ao_syncookie(struct sock *sk, const struct sk_buff *skb,\n--\nnet/ipv4/tcp_ao.c-927-\t/* treq-\u003eaf_specific is used to perform TCP_AO lookup\nnet/ipv4/tcp_ao.c:928:\t * in tcp_create_openreq_child().\nnet/ipv4/tcp_ao.c-929-\t */\n--\nnet/ipv4/tcp_fastopen.c=257=void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/tcp_fastopen.c-268-\ttcp_cleanup_skb(skb);\nnet/ipv4/tcp_fastopen.c:269:\t/* segs_in has been initialized to 1 in tcp_create_openreq_child().\nnet/ipv4/tcp_fastopen.c-270-\t * Hence, reset segs_in to 0 before calling tcp_segs_in()\n--\nnet/ipv4/tcp_ipv4.c=491=int tcp_v4_err(struct sk_buff *skb, u32 info)\n--\nnet/ipv4/tcp_ipv4.c-552-\ttp = tcp_sk(sk);\nnet/ipv4/tcp_ipv4.c:553:\t/* XXX (TFO) - tp-\u003esnd_una should be ISN (tcp_create_openreq_child() */\nnet/ipv4/tcp_ipv4.c-554-\tfastopen = rcu_dereference(tp-\u003efastopen_rsk);\n--\nnet/ipv4/tcp_ipv4.c=1674=struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,\n--\nnet/ipv4/tcp_ipv4.c-1696-\nnet/ipv4/tcp_ipv4.c:1697:\tnewsk = tcp_create_openreq_child(sk, req, skb);\nnet/ipv4/tcp_ipv4.c-1698-\tif (!newsk)\n--\nnet/ipv4/tcp_minisocks.c=525=static void smc_check_reset_syn_req(const struct tcp_sock *oldtp,\n--\nnet/ipv4/tcp_minisocks.c-545- */\nnet/ipv4/tcp_minisocks.c:546:struct sock *tcp_create_openreq_child(const struct sock *sk,\nnet/ipv4/tcp_minisocks.c-547-\t\t\t\t struct request_sock *req,\n"
} |
| 61/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35777 output: 40 thoughts: 29 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Diving into `tcp_create_openreq_child`** Right, let's take a closer look at `tcp_create_openreq_child`. I want to drill into that function in `net/ipv4/tcp_minisocks.c`. It's where the rubber meets the road, so to speak, in handling the creation of the child socket associated with an accepted connection. I'm keen to examine the nuances of this process—specifically how the open request is handled to prepare for a new, accepted connection. I'm thinking about the memory allocation, the initialization of the socket structure, and any potential race conditions during that critical creation phase. I'm hoping to refresh my memory on the handling of the open request on this socket. And also, since I'm going through this section of the code, I will make sure I don't miss anything. |
| 62/3 | 2026/09/26 18:45 | tool | read-file |
0mArgs:{
"File": "net/ipv4/tcp_minisocks.c",
"FirstLine": 546,
"LineCount": 50
}Results: {
"Contents": " 546:\tstruct sock *tcp_create_openreq_child(const struct sock *sk,\n 547:\t\t\t\t\t struct request_sock *req,\n 548:\t\t\t\t\t struct sk_buff *skb)\n 549:\t{\n 550:\t\tstruct sock *newsk = inet_csk_clone_lock(sk, req, GFP_ATOMIC);\n 551:\t\tconst struct inet_request_sock *ireq = inet_rsk(req);\n 552:\t\tstruct tcp_request_sock *treq = tcp_rsk(req);\n 553:\t\tstruct inet_connection_sock *newicsk;\n 554:\t\tconst struct tcp_sock *oldtp;\n 555:\t\tstruct tcp_sock *newtp;\n 556:\t\tu32 seq;\n 557:\t\n 558:\t\tif (!newsk)\n 559:\t\t\treturn NULL;\n 560:\t\n 561:\t\tnewicsk = inet_csk(newsk);\n 562:\t\tnewtp = tcp_sk(newsk);\n 563:\t\toldtp = tcp_sk(sk);\n 564:\t\n 565:\t\tsmc_check_reset_syn_req(oldtp, req, newtp);\n 566:\t\n 567:\t\t/* Now setup tcp_sock */\n 568:\t\tnewtp-\u003epred_flags = 0;\n 569:\t\n 570:\t\tseq = treq-\u003ercv_isn + 1;\n 571:\t\tnewtp-\u003ercv_wup = seq;\n 572:\t\tWRITE_ONCE(newtp-\u003ecopied_seq, seq);\n 573:\t\tWRITE_ONCE(newtp-\u003ercv_nxt, seq);\n 574:\t\tnewtp-\u003esegs_in = 1;\n 575:\t\n 576:\t\tseq = treq-\u003esnt_isn + 1;\n 577:\t\tnewtp-\u003esnd_sml = newtp-\u003esnd_una = seq;\n 578:\t\tWRITE_ONCE(newtp-\u003esnd_nxt, seq);\n 579:\t\tnewtp-\u003esnd_up = seq;\n 580:\t\n 581:\t\tINIT_LIST_HEAD(\u0026newtp-\u003etsq_node);\n 582:\t\tINIT_LIST_HEAD(\u0026newtp-\u003etsorted_sent_queue);\n 583:\t\n 584:\t\ttcp_init_wl(newtp, treq-\u003ercv_isn);\n 585:\t\n 586:\t\tminmax_reset(\u0026newtp-\u003ertt_min, tcp_jiffies32, ~0U);\n 587:\t\tnewicsk-\u003eicsk_ack.lrcvtime = tcp_jiffies32;\n 588:\t\n 589:\t\tnewtp-\u003elsndtime = tcp_jiffies32;\n 590:\t\tnewsk-\u003esk_txhash = READ_ONCE(treq-\u003etxhash);\n 591:\t\tnewtp-\u003etotal_retrans = req-\u003enum_retrans;\n 592:\t\n 593:\t\ttcp_init_xmit_timers(newsk);\n 594:\t\tWRITE_ONCE(newtp-\u003ewrite_seq, newtp-\u003epushed_seq = treq-\u003esnt_isn + 1);\n 595:\t\n"
} |
| 63/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36920 output: 36 thoughts: 115 Thoughts: Okay, let's break this down. **Diving into the Socket Cloning Process** Right, so I'm digging into `inet_csk_clone_lock(sk, req, GFP_ATOMIC)`. It's pretty clear that it's all about cloning a socket. The core of this seems to be the `sk_clone_lock(sk, priority)` function. Ah, here it is: `sock_copy(newsk, sk)` is the key function called here. Hold on a second, where's `newsk` allocated? Yes, I've got it, in `sock_copy`, that new socket (`nsk`) is allocated using `sk_prot_alloc`. I should check that logic. Ok. Let's make sure I understand the `sk_clone` call in `net/core/sock.c` lines 2480-2520, as it will probably shed some light on this cloning operation and ensure there aren't any gotchas I'm missing. |
| 64/3 | 2026/09/26 18:45 | tool | read-file |
0mArgs:{
"File": "net/core/sock.c",
"FirstLine": 2480,
"LineCount": 40
}Results: {
"Contents": "2480:\tstruct sock *sk_clone(const struct sock *sk, const gfp_t priority,\n2481:\t\t\t bool lock)\n2482:\t{\n2483:\t\tstruct proto *prot = READ_ONCE(sk-\u003esk_prot);\n2484:\t\tstruct sk_filter *filter;\n2485:\t\tbool is_charged = true;\n2486:\t\tstruct sock *newsk;\n2487:\t\n2488:\t\tnewsk = sk_prot_alloc(prot, priority, sk-\u003esk_family);\n2489:\t\tif (!newsk)\n2490:\t\t\tgoto out;\n2491:\t\n2492:\t\tsock_copy(newsk, sk);\n2493:\t\n2494:\t\tnewsk-\u003esk_prot_creator = prot;\n2495:\t#ifdef CONFIG_BPF_SYSCALL\n2496:\t\tRCU_INIT_POINTER(newsk-\u003esk_bpf_storage, NULL);\n2497:\t#endif\n2498:\t#if IS_ENABLED(CONFIG_INET_PSP)\n2499:\t\tRCU_INIT_POINTER(newsk-\u003epsp_assoc, NULL);\n2500:\t#endif\n2501:\t\n2502:\t\t/* SANITY */\n2503:\t\tif (likely(newsk-\u003esk_net_refcnt)) {\n2504:\t\t\tget_net_track(sock_net(newsk), \u0026newsk-\u003ens_tracker, priority);\n2505:\t\t\tsock_inuse_add(sock_net(newsk), 1);\n2506:\t\t} else {\n2507:\t\t\t/* Kernel sockets are not elevating the struct net refcount.\n2508:\t\t\t * Instead, use a tracker to more easily detect if a layer\n2509:\t\t\t * is not properly dismantling its kernel sockets at netns\n2510:\t\t\t * destroy time.\n2511:\t\t\t */\n2512:\t\t\tnet_passive_inc(sock_net(newsk));\n2513:\t\t\t__netns_tracker_alloc(sock_net(newsk), \u0026newsk-\u003ens_tracker,\n2514:\t\t\t\t\t false, priority);\n2515:\t\t}\n2516:\t\n2517:\t\tsk_node_init(\u0026newsk-\u003esk_node);\n2518:\t\tsock_lock_init(newsk);\n2519:\t\n"
} |
| 65/3 | 2026/09/26 18:45 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37924 output: 19 thoughts: 381 Thoughts: **Analyzing the Socket Cloning Process** Okay, so I'm digging into this `sk_clone` function, and my first question is about the `sk_prot_alloc` call. Specifically, what's being passed as the `priority` argument? That's the initial point. Then, looking at `inet_csk_clone_lock`, I see `GFP_ATOMIC` used. Hmm, does `GFP_ATOMIC` include `__GFP_ZERO`? Nope, not at all! It's `(__GFP_HIGH|__GFP_KSWAPD_RECLAIM)`. Good to clarify that. But, back to `sk_clone`. What follows the allocation? Ah, right, `sock_copy(newsk, sk)`. Okay, let's zoom in on `sock_copy`. There's this `memcpy` operation. It copies part of the `struct sock`, up to `sk_dontcopy_begin`, and then there's an `unsafe_memcpy` for the rest. Interesting. Now, my mind shifts to those `sk_dontcopy_begin` and `sk_dontcopy_end` members. What's actually in that memory region between those points? That's the crux of the matter. Gotta check where those fields are located within the `struct sock` definition itself. This'll tell me what's being selectively *not* copied during the clone. |
| 66/3 | 2026/09/26 18:46 | tool | grepper |
0mArgs:{
"Expression": "sk_dontcopy_"
}Results: {
"Output": "include/net/sock.h=365=struct sock {\n--\ninclude/net/sock.h-378-\ninclude/net/sock.h:379:#define sk_dontcopy_begin\t__sk_common.skc_dontcopy_begin\ninclude/net/sock.h:380:#define sk_dontcopy_end\t\t__sk_common.skc_dontcopy_end\ninclude/net/sock.h-381-#define sk_hash\t\t\t__sk_common.skc_hash\n--\nnet/core/sock.c=2185=static inline void sock_lock_init(struct sock *sk)\n--\nnet/core/sock.c-2207- * even temporarily, because of RCU lookups. sk_node should also be left as is.\nnet/core/sock.c:2208: * We must not copy fields between sk_dontcopy_begin and sk_dontcopy_end\nnet/core/sock.c-2209- */\nnet/core/sock.c=2210=static void sock_copy(struct sock *nsk, const struct sock *osk)\n--\nnet/core/sock.c-2221-\tBUILD_BUG_ON(offsetof(struct sock, sk_tx_queue_mapping) \u003c\nnet/core/sock.c:2222:\t\t offsetof(struct sock, sk_dontcopy_begin) ||\nnet/core/sock.c-2223-\t\t offsetof(struct sock, sk_tx_queue_mapping) \u003e=\nnet/core/sock.c:2224:\t\t offsetof(struct sock, sk_dontcopy_end));\nnet/core/sock.c-2225-\nnet/core/sock.c:2226:\tmemcpy(nsk, osk, offsetof(struct sock, sk_dontcopy_begin));\nnet/core/sock.c-2227-\nnet/core/sock.c:2228:\tunsafe_memcpy(\u0026nsk-\u003esk_dontcopy_end, \u0026osk-\u003esk_dontcopy_end,\nnet/core/sock.c:2229:\t\t prot-\u003eobj_size - offsetof(struct sock, sk_dontcopy_end),\nnet/core/sock.c-2230-\t\t /* alloc is larger than struct, see sk_prot_alloc() */);\n--\nnet/ipv4/inet_connection_sock.c=913=static struct request_sock *inet_reqsk_clone(struct request_sock *req,\n--\nnet/ipv4/inet_connection_sock.c-931-\tmemcpy(nreq_sk, req_sk,\nnet/ipv4/inet_connection_sock.c:932:\t offsetof(struct sock, sk_dontcopy_begin));\nnet/ipv4/inet_connection_sock.c:933:\tunsafe_memcpy(\u0026nreq_sk-\u003esk_dontcopy_end, \u0026req_sk-\u003esk_dontcopy_end,\nnet/ipv4/inet_connection_sock.c:934:\t\t req-\u003ersk_ops-\u003eobj_size - offsetof(struct sock, sk_dontcopy_end),\nnet/ipv4/inet_connection_sock.c-935-\t\t /* alloc is larger than struct, see above */);\n"
} |
| 67/3 | 2026/09/26 18:46 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39429 output: 20 thoughts: 1536 Thoughts: **Analyzing the TCP NOSPACE Patch** Okay, let's break this down. My initial thought process was: `sk_dontcopy_begin` and `sk_dontcopy_end` are only used for node hash and node linkage fields. Everything *after* that up to `prot->obj_size` is copied with `unsafe_memcpy`. That's where things get interesting. TCP sockets extend far past that "don't copy" region. Then, I remembered `sock_copy` – the parent's data is copied to the child. The parent (listening socket) was created using `sk_alloc` with `__GFP_ZERO`. Because of `want_init_on_alloc`, `sk_prot_clear_nulls` zeroed the entire object. So, the listening socket's `tcp_nospace` is initialized to *zero*. When a child socket is cloned via `sock_copy`, that zero value gets copied over! But... then I thought about MPTCP subflows. They *share* the same underlying socket and hence the same `SOCK_NOSPACE` bit. That's where this patch gets interesting. The added code in `subflow_ulp_init` sets `tp->tcp_nospace = 1` for the subflow, which is used within the context of MPTCP. This makes me consider: what are the implications of setting `tcp_nospace` in the subflow? Will that correctly reflect when the underlying socket *actually* has space? Let's look at the patch as a whole. Currently, in TCP, `SOCK_NOSPACE` bit is set in the socket flags when the socket is in a "no space" situation. `tcp_check_space(sk)` checks this flag. The problem this addresses is that `sk->sk_socket` dereference in `tcp_check_space` could cause a cacheline miss, or point to a detached/NULL socket. The solution? They introduce a `u8 tcp_nospace` field *inside* the `tcp_sock` structure, specifically in the TX cacheline. This is a good location, making it likely that it's in the same cacheline as relevant transmit data like `snd_sml` and `chrono_type`. They also add helper functions `sk_set_nospace` and `sk_clear_nospace` which abstract the setting and clearing of both the `SOCK_NOSPACE` flag on the socket *and* the new `tcp_nospace` field in the TCP socket structure. The patch modifies the logic of `tcp_check_space`. Critically, it checks the `tcp_nospace` flag *first*, and *only* if that's set does it then check the `SOCK_NOSPACE` bit on the socket itself. There are also memory barriers now to ensure the `tcp_nospace` flag is visible across CPUs. Also, the callers of `tcp_check_space` must be considered. The key is the `tcp_nospace` flag acts as a local cache of the socket's `SOCK_NOSPACE` flag for better performance, while also mitigating potential cacheline misses or null pointer dereferences on the socket pointer. MPTCP uses this flag to prevent mirroring, because it can't always reflect the socket flag. The usage of memory barriers ensures the correct synchronization between the cacheline flag and the socket flag. I now need to verify that `tcp_check_space` is *only* called with TCP sockets, even after this change. |
| 68/3 | 2026/09/26 18:46 | tool | grepper |
0mArgs:{
"Expression": "tcp_check_space\\("
}Results: {
"Output": "Documentation/networking/net_cachelines/tcp_sock.rst=52=u8:2 chrono_type read_write tcp_chrono_start/stop(tcp_write_xmit,tcp_cwnd_vali...\nDocumentation/networking/net_cachelines/tcp_sock.rst:53:u8 tcp_nospace read_mostly read_mostly tcp_check_space(tx);tcp_check_space(rx)\nDocumentation/networking/net_cachelines/tcp_sock.rst-54-u8:1 rate_app_limited read_write tcp_rate_gen\n--\ninclude/net/tcp.h=784=void tcp_fin(struct sock *sk);\ninclude/net/tcp.h:785:void __tcp_check_space(struct sock *sk);\ninclude/net/tcp.h-786-\n--\ninclude/net/tcp.h-791- * Keep their mirror always set (see subflow_ulp_init()) so that they\ninclude/net/tcp.h:792: * always reach __tcp_check_space() and behave as before.\ninclude/net/tcp.h-793- */\ninclude/net/tcp.h=794=static inline void tcp_set_nospace(struct sock *sk)\n--\ninclude/net/tcp.h-798-\t\tsmp_mb__after_atomic();\ninclude/net/tcp.h:799:\t\t/* pairs with smp_mb() in tcp_check_space() */\ninclude/net/tcp.h-800-\t\tsmp_store_mb(tcp_sk(sk)-\u003etcp_nospace, 1);\n--\ninclude/net/tcp.h=804=static inline void tcp_clear_nospace(struct sock *sk)\n--\ninclude/net/tcp.h-812-\ninclude/net/tcp.h:813:static inline void tcp_check_space(struct sock *sk)\ninclude/net/tcp.h-814-{\n--\ninclude/net/tcp.h-818-\tif (unlikely(READ_ONCE(tcp_sk(sk)-\u003etcp_nospace)))\ninclude/net/tcp.h:819:\t\t__tcp_check_space(sk);\ninclude/net/tcp.h-820-}\n--\nnet/ceph/messenger.c=364=static void ceph_sock_write_space(struct sock *sk)\n--\nnet/ceph/messenger.c-371-\t * doesn't get called again until ceph_con_v[12]_try_write() fills\nnet/ceph/messenger.c:372:\t * the socket buffer. See net/ipv4/tcp_input.c:tcp_check_space()\nnet/ceph/messenger.c-373-\t * and net/core/stream.c:sk_stream_write_space().\n--\nnet/core/stream.c=121=int sk_stream_wait_memory(struct sock *sk, long *timeo_p)\n--\nnet/core/stream.c-176-\t * be generated later.\nnet/core/stream.c:177:\t * When TCP receives ACK packets that make room, tcp_check_space()\nnet/core/stream.c-178-\t * only calls tcp_new_space() if SOCK_NOSPACE is set.\n--\nnet/ipv4/tcp_input.c=6075=static void tcp_new_space(struct sock *sk)\n--\nnet/ipv4/tcp_input.c-6098- */\nnet/ipv4/tcp_input.c:6099:void __tcp_check_space(struct sock *sk)\nnet/ipv4/tcp_input.c-6100-{\n--\nnet/ipv4/tcp_input.c=6112=static inline void tcp_data_snd_check(struct sock *sk)\n--\nnet/ipv4/tcp_input.c-6114-\ttcp_push_pending_frames(sk);\nnet/ipv4/tcp_input.c:6115:\ttcp_check_space(sk);\nnet/ipv4/tcp_input.c-6116-}\n--\nnet/ipv4/tcp_output.c=83=static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/tcp_output.c-102-\t\t tcp_skb_pcount(skb));\nnet/ipv4/tcp_output.c:103:\ttcp_check_space(sk);\nnet/ipv4/tcp_output.c-104-}\n--\nnet/mptcp/subflow.c=1980=static int subflow_ulp_init(struct sock *sk)\n--\nnet/mptcp/subflow.c-2004-\t/* Subflows share the MPTCP socket, and thus its SOCK_NOSPACE bit,\nnet/mptcp/subflow.c:2005:\t * which tcp_check_space() can not mirror. Pin the mirror so that\nnet/mptcp/subflow.c:2006:\t * __tcp_check_space() always tests the shared bit.\nnet/mptcp/subflow.c-2007-\t */\n--\nnet/smc/smc_tx.c=41=static void smc_tx_write_space(struct sock *sk)\n--\nnet/smc/smc_tx.c-64-/* Wakeup sndbuf producers that blocked with smc_tx_wait().\nnet/smc/smc_tx.c:65: * Cf. tcp_data_snd_check()=\u003etcp_check_space()=\u003etcp_new_space().\nnet/smc/smc_tx.c-66- */\n"
} |
| 69/3 | 2026/09/26 18:46 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43190 output: 19 thoughts: 135 Thoughts: **My Analysis of the `tcp_check_space()` Function** Okay, so I'm digging into this `tcp_check_space()` function, trying to understand its usage within the TCP stack. My initial observation is that it seems to be exclusively called within the TCP module itself, specifically in two functions: `tcp_data_snd_check()` (found in `tcp_input.c`) and `tcp_event_new_data_sent()` (within `tcp_output.c`). The key here is that both these callers pass a TCP socket (`sock`) as an argument. I also see that they're both checking `tcp_sk(sk)->tcp_nospace` before invoking it, which is the immediate pre-requisite. This got me thinking, what if the `sk` being passed isn't actually a TCP socket? I mean, we're assuming it is, but is there a check for that? That leads me to examine how the system knows it is a TCP socket, and I'm reminded of `sk_is_tcp(sk)`. This seems like the obvious place to investigate next. I'm noting that the `tcp_set_nospace` and `tcp_clear_nospace` functions also use `sk_is_tcp(sk)` which suggests some sort of crucial type-checking is going on. I'm going to track down that definition next and make sure that it all makes sense. |
| 70/3 | 2026/09/26 18:46 | tool | grepper |
0mArgs:{
"Expression": "sk_is_tcp"
}Results: {
"Output": "drivers/block/nbd.c=1213=static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,\n--\ndrivers/block/nbd.c-1222-\ndrivers/block/nbd.c:1223:\tif (!sk_is_tcp(sock-\u003esk) \u0026\u0026\ndrivers/block/nbd.c-1224-\t !sk_is_stream_unix(sock-\u003esk)) {\n--\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c=16=static bool dr_mask_is_l3_base_set(struct mlx5dr_match_spec *spec)\n--\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c-21-\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c:22:static bool dr_mask_is_tcp_udp_base_set(struct mlx5dr_match_spec *spec)\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c-23-{\n--\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c=33=static bool dr_mask_is_ipv4_5_tuple_set(struct mlx5dr_match_spec *spec)\n--\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c-35-\treturn (dr_mask_is_l3_base_set(spec) ||\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c:36:\t\tdr_mask_is_tcp_udp_base_set(spec) ||\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c-37-\t\tdr_mask_is_ipv4_set(spec));\n--\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c=50=static bool dr_mask_is_ipv4_ihl_set(struct mlx5dr_match_spec *spec)\n--\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c-66-\tdr_mask_is_l3_base_set(\u0026(_spec)) || \\\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c:67:\tdr_mask_is_tcp_udp_base_set(\u0026(_spec)) || \\\ndrivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_matcher.c-68-\tdr_mask_is_ttl_set(\u0026(_spec)) || \\\n--\ndrivers/scsi/iscsi_tcp.c=664=iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,\n--\ndrivers/scsi/iscsi_tcp.c-683-\terr = -EINVAL;\ndrivers/scsi/iscsi_tcp.c:684:\tif (!sk_is_tcp(sock-\u003esk))\ndrivers/scsi/iscsi_tcp.c-685-\t\tgoto free_socket;\n--\ninclude/net/ip.h=582=static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,\n--\ninclude/net/ip.h-595-\t\t */\ninclude/net/ip.h:596:\t\tif (sk_is_tcp(sk)) {\ninclude/net/ip.h-597-\t\t\tsock_owned_by_me(sk);\n--\ninclude/net/sock.h=2962=static inline bool sk_is_inet(const struct sock *sk)\n--\ninclude/net/sock.h-2968-\ninclude/net/sock.h:2969:static inline bool sk_is_tcp(const struct sock *sk)\ninclude/net/sock.h-2970-{\n--\ninclude/net/tcp.h=794=static inline void tcp_set_nospace(struct sock *sk)\ninclude/net/tcp.h-795-{\ninclude/net/tcp.h:796:\tif (sk_is_tcp(sk)) {\ninclude/net/tcp.h-797-\t\t/* pairs with smp_mb__before_atomic() in tcp_clear_nospace() */\n--\ninclude/net/tcp.h=804=static inline void tcp_clear_nospace(struct sock *sk)\ninclude/net/tcp.h-805-{\ninclude/net/tcp.h:806:\tif (sk_is_tcp(sk) \u0026\u0026 !sk_is_mptcp(sk)) {\ninclude/net/tcp.h-807-\t\tWRITE_ONCE(tcp_sk(sk)-\u003etcp_nospace, 0);\n--\nnet/core/filter.c=5653=static int sol_tcp_sockopt(struct sock *sk, int optname,\n--\nnet/core/filter.c-5656-{\nnet/core/filter.c:5657:\tif (!sk_is_tcp(sk))\nnet/core/filter.c-5658-\t\treturn -EINVAL;\n--\nnet/core/filter.c=7735=BPF_CALL_1(bpf_tcp_sock, struct sock *, sk)\nnet/core/filter.c-7736-{\nnet/core/filter.c:7737:\tif (sk_fullsock(sk) \u0026\u0026 sk_is_tcp(sk))\nnet/core/filter.c-7738-\t\treturn (unsigned long)sk;\n--\nnet/core/filter.c=11978=BPF_CALL_3(bpf_sk_lookup_assign, struct bpf_sk_lookup_kern *, ctx,\n--\nnet/core/filter.c-11985-\t\treturn -ESOCKTNOSUPPORT; /* reject non-RCU freed sockets */\nnet/core/filter.c:11986:\tif (unlikely(sk \u0026\u0026 sk_is_tcp(sk) \u0026\u0026 sk-\u003esk_state != TCP_LISTEN))\nnet/core/filter.c-11987-\t\treturn -ESOCKTNOSUPPORT; /* only accept TCP socket in LISTEN */\n--\nnet/core/filter.c=12219=BPF_CALL_1(bpf_skc_to_tcp_sock, struct sock *, sk)\nnet/core/filter.c-12220-{\nnet/core/filter.c:12221:\tif (sk \u0026\u0026 sk_fullsock(sk) \u0026\u0026 sk_is_tcp(sk))\nnet/core/filter.c-12222-\t\treturn (unsigned long)sk;\n--\nnet/core/skbuff.c=3314=static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset,\n--\nnet/core/skbuff.c-3316-{\nnet/core/skbuff.c:3317:\tint more_hint = sk_is_tcp(sk) ? MSG_MORE : 0;\nnet/core/skbuff.c-3318-\tunsigned int orig_len = len;\n--\nnet/core/skbuff.c=5586=static void __skb_complete_tx_timestamp(struct sk_buff *skb,\n--\nnet/core/skbuff.c-5604-\t\tserr-\u003eee.ee_data = skb_shinfo(skb)-\u003etskey;\nnet/core/skbuff.c:5605:\t\tif (sk_is_tcp(sk))\nnet/core/skbuff.c-5606-\t\t\tserr-\u003eee.ee_data -= atomic_read(\u0026sk-\u003esk_tskey);\n--\nnet/core/skbuff.c=5713=void __skb_tstamp_tx(struct sk_buff *orig_skb,\n--\nnet/core/skbuff.c-5743-\t\tif ((tsflags \u0026 SOF_TIMESTAMPING_OPT_STATS) \u0026\u0026\nnet/core/skbuff.c:5744:\t\t sk_is_tcp(sk)) {\nnet/core/skbuff.c-5745-\t\t\tskb = tcp_get_timestamping_opt_stats(sk, orig_skb,\n--\nnet/core/skmsg.c=1143=int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)\n--\nnet/core/skmsg.c-1156-\nnet/core/skmsg.c:1157:\tif (sk_is_tcp(sk)) {\nnet/core/skmsg.c-1158-\t\tpsock-\u003estrp.cb.read_sock = tcp_bpf_strp_read_sock;\n--\nnet/core/sock.c=892=int sock_set_timestamping(struct sock *sk, int optname,\n--\nnet/core/sock.c-906-\t !(sk-\u003esk_tsflags \u0026 SOF_TIMESTAMPING_OPT_ID)) {\nnet/core/sock.c:907:\t\tif (sk_is_tcp(sk)) {\nnet/core/sock.c-908-\t\t\tif ((1 \u003c\u003c sk-\u003esk_state) \u0026\n--\nnet/core/sock.c=1087=sock_devmem_dontneed(struct sock *sk, sockptr_t optval, unsigned int optlen)\n--\nnet/core/sock.c-1093-\nnet/core/sock.c:1094:\tif (!sk_is_tcp(sk))\nnet/core/sock.c-1095-\t\treturn -EBADF;\n--\nnet/core/sock.c=1195=int sk_setsockopt(struct sock *sk, int level, int optname,\n--\nnet/core/sock.c-1275-\tcase SO_TXREHASH:\nnet/core/sock.c:1276:\t\tif (!sk_is_tcp(sk))\nnet/core/sock.c-1277-\t\t\treturn -EOPNOTSUPP;\n--\nnet/core/sock.c-1467-\nnet/core/sock.c:1468:\t\tif (sk_is_tcp(sk) \u0026\u0026\nnet/core/sock.c-1469-\t\t !sockopt_ns_capable(sock_net(sk)-\u003euser_ns, CAP_NET_ADMIN)) {\n--\nnet/core/sock.c-1598-\t\tif (sk-\u003esk_family == PF_INET || sk-\u003esk_family == PF_INET6) {\nnet/core/sock.c:1599:\t\t\tif (!(sk_is_tcp(sk) ||\nnet/core/sock.c-1600-\t\t\t (sk-\u003esk_type == SOCK_DGRAM \u0026\u0026\n--\nnet/core/sock.c=1732=int sk_getsockopt(struct sock *sk, int level, int optname,\n--\nnet/core/sock.c-2155-\tcase SO_TXREHASH:\nnet/core/sock.c:2156:\t\tif (!sk_is_tcp(sk))\nnet/core/sock.c-2157-\t\t\treturn -EOPNOTSUPP;\n--\nnet/core/sock.c=2622=static u32 sk_dst_gso_max_size(struct sock *sk, const struct net_device *dev)\n--\nnet/core/sock.c-2633-\t\t\tREAD_ONCE(dev-\u003egso_ipv4_max_size);\nnet/core/sock.c:2634:\tif (max_size \u003e GSO_LEGACY_MAX_SIZE \u0026\u0026 !sk_is_tcp(sk))\nnet/core/sock.c-2635-\t\tmax_size = GSO_LEGACY_MAX_SIZE;\n--\nnet/core/sock.c=2640=void sk_setup_caps(struct sock *sk, struct dst_entry *dst)\n--\nnet/core/sock.c-2647-\tsk-\u003esk_route_caps = dev-\u003efeatures;\nnet/core/sock.c:2648:\tif (sk_is_tcp(sk)) {\nnet/core/sock.c-2649-\t\tstruct inet_connection_sock *icsk = inet_csk(sk);\n--\nnet/core/sock.c=3078=int __sock_cmsg_send(struct sock *sk, struct cmsghdr *cmsg,\n--\nnet/core/sock.c-3143-\tcase SCM_TS_OPT_ID:\nnet/core/sock.c:3144:\t\tif (sk_is_tcp(sk))\nnet/core/sock.c-3145-\t\t\treturn -EINVAL;\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-305-\tif (stream_parser \u0026\u0026 stream_verdict \u0026\u0026 !psock-\u003esaved_data_ready) {\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);\n--\nnet/core/sock_map.c=528=static bool sock_map_redirect_allowed(const struct sock *sk)\nnet/core/sock_map.c-529-{\nnet/core/sock_map.c:530:\tif (sk_is_tcp(sk))\nnet/core/sock_map.c-531-\t\treturn sk-\u003esk_state != TCP_LISTEN;\n--\nnet/core/sock_map.c=541=static bool sock_map_sk_state_allowed(const struct sock *sk)\nnet/core/sock_map.c-542-{\nnet/core/sock_map.c:543:\tif (sk_is_tcp(sk))\nnet/core/sock_map.c-544-\t\treturn (1 \u003c\u003c sk-\u003esk_state) \u0026 (TCPF_ESTABLISHED | TCPF_LISTEN);\n--\nnet/core/sock_map.c=675=BPF_CALL_4(bpf_msg_redirect_map, struct sk_msg *, msg,\n--\nnet/core/sock_map.c-685-\t\treturn SK_DROP;\nnet/core/sock_map.c:686:\tif (!(flags \u0026 BPF_F_INGRESS) \u0026\u0026 !sk_is_tcp(sk))\nnet/core/sock_map.c-687-\t\treturn SK_DROP;\n--\nnet/core/sock_map.c=1281=BPF_CALL_4(bpf_msg_redirect_hash, struct sk_msg *, msg,\n--\nnet/core/sock_map.c-1291-\t\treturn SK_DROP;\nnet/core/sock_map.c:1292:\tif (!(flags \u0026 BPF_F_INGRESS) \u0026\u0026 !sk_is_tcp(sk))\nnet/core/sock_map.c-1293-\t\treturn SK_DROP;\n--\nnet/ipv4/ip_output.c=1399=struct sk_buff *__ip_make_skb(struct sock *sk,\n--\nnet/ipv4/ip_output.c-1475-\tskb-\u003emark = cork-\u003emark;\nnet/ipv4/ip_output.c:1476:\tif (sk_is_tcp(sk))\nnet/ipv4/ip_output.c-1477-\t\tskb_set_delivery_time(skb, cork-\u003etransmit_time, SKB_CLOCK_MONOTONIC);\n--\nnet/ipv4/tcp_bpf.c=15=void tcp_eat_skb(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/tcp_bpf.c-19-\nnet/ipv4/tcp_bpf.c:20:\tif (!skb || !skb-\u003elen || !sk_is_tcp(sk))\nnet/ipv4/tcp_bpf.c-21-\t\treturn;\n--\nnet/ipv6/ip6_output.c=1926=struct sk_buff *__ip6_make_skb(struct sock *sk,\n--\nnet/ipv6/ip6_output.c-1985-\tskb-\u003emark = cork-\u003ebase.mark;\nnet/ipv6/ip6_output.c:1986:\tif (sk_is_tcp(sk))\nnet/ipv6/ip6_output.c-1987-\t\tskb_set_delivery_time(skb, cork-\u003ebase.transmit_time, SKB_CLOCK_MONOTONIC);\n--\nnet/mptcp/bpf.c=15=struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)\nnet/mptcp/bpf.c-16-{\nnet/mptcp/bpf.c:17:\tif (sk \u0026\u0026 sk_fullsock(sk) \u0026\u0026 sk_is_tcp(sk) \u0026\u0026 sk_is_mptcp(sk))\nnet/mptcp/bpf.c-18-\t\treturn mptcp_sk(mptcp_subflow_ctx(sk)-\u003econn);\n--\nnet/psp/psp_nl.c=672=int psp_assoc_device_get_locked(const struct genl_split_ops *ops,\n--\nnet/psp/psp_nl.c-687-\nnet/psp/psp_nl.c:688:\tif (!sk_is_tcp(socket-\u003esk)) {\nnet/psp/psp_nl.c-689-\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n--\nnet/sched/sch_fq.c=337=static bool fq_fastpath_check(const struct Qdisc *sch, struct sk_buff *skb,\n--\nnet/sched/sch_fq.c-368-\tsk = skb-\u003esk;\nnet/sched/sch_fq.c:369:\tif (sk \u0026\u0026 sk_fullsock(sk) \u0026\u0026 !sk_is_tcp(sk) \u0026\u0026\nnet/sched/sch_fq.c-370-\t sk-\u003esk_max_pacing_rate != ~0UL)\n--\nsecurity/apparmor/lsm.c=1465=static int apparmor_socket_sendmsg(struct socket *sock,\n--\nsecurity/apparmor/lsm.c-1476-\tif ((msg-\u003emsg_flags \u0026 MSG_FASTOPEN) \u0026\u0026 msg-\u003emsg_name \u0026\u0026\nsecurity/apparmor/lsm.c:1477:\t (sk_is_tcp(sock-\u003esk) ||\nsecurity/apparmor/lsm.c-1478-\t (sk_is_inet(sock-\u003esk) \u0026\u0026 sock-\u003esk-\u003esk_type == SOCK_STREAM \u0026\u0026\n--\nsecurity/landlock/net.c=327=static int hook_socket_bind(struct socket *const sock,\n--\nsecurity/landlock/net.c-331-\nsecurity/landlock/net.c:332:\tif (sk_is_tcp(sock-\u003esk))\nsecurity/landlock/net.c-333-\t\taccess_request = LANDLOCK_ACCESS_NET_BIND_TCP;\n--\nsecurity/landlock/net.c=343=static int hook_socket_connect(struct socket *const sock,\n--\nsecurity/landlock/net.c-349-\nsecurity/landlock/net.c:350:\tif (sk_is_tcp(sock-\u003esk))\nsecurity/landlock/net.c-351-\t\taccess_request = LANDLOCK_ACCESS_NET_CONNECT_TCP;\n--\nsecurity/landlock/net.c=372=static int hook_socket_sendmsg(struct socket *const sock,\n--\nsecurity/landlock/net.c-379-\nsecurity/landlock/net.c:380:\tif ((msg-\u003emsg_flags \u0026 MSG_FASTOPEN) \u0026\u0026 address \u0026\u0026 sk_is_tcp(sock-\u003esk)) {\nsecurity/landlock/net.c-381-\t\tret = current_check_access_socket(\n--\nsecurity/selinux/hooks.c=5273=static int selinux_socket_sendmsg(struct socket *sock, struct msghdr *msg,\n--\nsecurity/selinux/hooks.c-5284-\tif (addr \u0026\u0026 (msg-\u003emsg_flags \u0026 MSG_FASTOPEN) \u0026\u0026\nsecurity/selinux/hooks.c:5285:\t (sk_is_tcp(sock-\u003esk) ||\nsecurity/selinux/hooks.c-5286-\t (sk_is_inet(sock-\u003esk) \u0026\u0026 sock-\u003esk-\u003esk_type == SOCK_STREAM \u0026\u0026\n--\ntools/testing/selftests/bpf/progs/setget_sockopt.c=83=struct loop_ctx {\n--\ntools/testing/selftests/bpf/progs/setget_sockopt.c-87-\ntools/testing/selftests/bpf/progs/setget_sockopt.c:88:static bool sk_is_tcp(struct sock *sk)\ntools/testing/selftests/bpf/progs/setget_sockopt.c-89-{\n--\ntools/testing/selftests/bpf/progs/setget_sockopt.c=96=static int bpf_test_sockopt_flip(void *ctx, struct sock *sk,\n--\ntools/testing/selftests/bpf/progs/setget_sockopt.c-103-\ntools/testing/selftests/bpf/progs/setget_sockopt.c:104:\tif (opt == SO_TXREHASH \u0026\u0026 !sk_is_tcp(sk))\ntools/testing/selftests/bpf/progs/setget_sockopt.c-105-\t\treturn 0;\n"
} |
| 71/3 | 2026/09/26 18:46 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49192 output: 36 thoughts: 29 Thoughts: Okay, let's break this down. **Diving into the `sk_is_tcp` Function** Right, I'm digging into this `sk_is_tcp` macro. My initial thought is to check it out in `include/net/sock.h`, lines 2969 onwards. It's obviously a key indicator for TCP sockets, a fairly fundamental function when it comes to any sort of network socket manipulation. The name is pretty self-explanatory, but I always want to see the implementation details to know *exactly* how the kernel is determining TCP-ness. Just because something is named "is_tcp" doesn't mean it's necessarily efficient or the best way to determine the protocol type of a socket. I'm hoping to see a clean, direct check against a specific socket type or flags – ideally, something that's optimized for performance, considering this is likely used frequently within the networking stack. I'll be looking for any hints about potential optimizations or interesting edge cases. Maybe there's some bit twiddling or clever use of pre-computed values. Let's see what they've cooked up... |
| 72/3 | 2026/09/26 18:46 | tool | read-file |
0mArgs:{
"File": "include/net/sock.h",
"FirstLine": 2965,
"LineCount": 20
}Results: {
"Contents": "2965:\t\n2966:\t\treturn family == AF_INET || family == AF_INET6;\n2967:\t}\n2968:\t\n2969:\tstatic inline bool sk_is_tcp(const struct sock *sk)\n2970:\t{\n2971:\t\treturn sk_is_inet(sk) \u0026\u0026\n2972:\t\t sk-\u003esk_type == SOCK_STREAM \u0026\u0026\n2973:\t\t sk-\u003esk_protocol == IPPROTO_TCP;\n2974:\t}\n2975:\t\n2976:\tstatic inline bool sk_is_udp(const struct sock *sk)\n2977:\t{\n2978:\t\treturn sk_is_inet(sk) \u0026\u0026\n2979:\t\t sk-\u003esk_type == SOCK_DGRAM \u0026\u0026\n2980:\t\t sk-\u003esk_protocol == IPPROTO_UDP;\n2981:\t}\n2982:\t\n2983:\tstatic inline bool sk_is_unix(const struct sock *sk)\n2984:\t{\n"
} |
| 73/3 | 2026/09/26 18:46 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49785 output: 30 thoughts: 1239 Thoughts: **Analyzing the Patch for Potential Issues**
Okay, so `sk_is_tcp(sk)` confirms that a full TCP socket (IPv4 or IPv6, stream-based) is a `struct tcp_sock`. Now, my focus shifts to potential risks within this patch. I need to meticulously examine every file touched to look for uninitialized memory accesses, exposure of uninitialized data to userspace, or even just general reads of uninitialized memory. Let's go line-by-line:
1. `Documentation/networking/net_cachelines/tcp_sock.rst`: Docs, no code. Safe.
2. `drivers/block/drbd/drbd_worker.c`: `sk_set_nospace(sk)` replaces the old `if (sk->sk_socket) set_bit(SOCK_NOSPACE, &sk->sk_socket->flags)`. Inside `sk_set_nospace(sk)` it checks `sk->sk_socket`, sets `SOCK_NOSPACE`, and calls `tcp_set_nospace(sk)`. Looks fine, standard replacement.
3. `drivers/nvme/host/tcp.c` and
4. `drivers/nvme/target/tcp.c`: `sk_clear_nospace(sk)` replaces `clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags)`. Same as above, just clearing the flag.
5. `fs/dlm/lowcomms.c`: Both `sk_clear_nospace(sk)` and `sk_set_nospace(con->sock->sk)` are present. No immediate red flags here. Just setting and clearing the nospace flag.
6. `include/linux/tcp.h`: `u8 tcp_nospace;` added to `struct tcp_sock`. This is the core change, and I need to make sure this is correctly initialized and handled throughout. This is the new member in `struct tcp_sock`, and needs to be accounted for.
7. `include/net/sock.h`: Declarations of `sk_set_nospace` and `sk_clear_nospace`. Declarations, no risk here.
8. `include/net/tcp.h`: `tcp_set_nospace`, `tcp_clear_nospace`, and `tcp_check_space`. These are function definitions. I need to see how they're *used*, but definitions themselves are just fine.
9. `net/ceph/messenger.c`: `sk_clear_nospace(sk)`. Clears the no space flag.
10. `net/core/sock.c`: Definitions of `sk_set_nospace` and `sk_clear_nospace`, plus callers in `sock_wait_for_wmem`, `sock_alloc_send_pskb`. Good to see the definitions, now I need to verify that callers are doing it safely.
11. `net/core/stream.c`: `sk_clear_nospace` in `sk_stream_write_space`, `sk_set_nospace` in `sk_stream_wait_memory`. More use cases.
12. `net/ipv4/tcp.c`: `sk_set_nospace` in `tcp_poll`, `tcp_sendmsg_locked`, assertion in `tcp_struct_check`. More TCP-specific interactions. The assertion in `tcp_struct_check` is important, though I'll need to see the context to really assess it.
13. `net/ipv4/tcp_bpf.c`: `sk_set_nospace` in `tcp_bpf_sendmsg`. BPF interaction, still setting no space.
14. `net/ipv4/tcp_input.c`: `__tcp_check_space`. Here's the most interesting part:
```c
void __tcp_check_space(struct sock *sk)
{
struct socket *sock = sk->sk_socket;
/* tp->tcp_nospace is only a hint, SOCK_NOSPACE is authoritative. */
if (!sock || !test_bit(SOCK_NOSPACE, &sock->flags))
return;
tcp_new_space(sk);
if (!test_bit(SOCK_NOSPACE, &sock->flags))
tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);
}
```
The code explicitly states that `tp->tcp_nospace` is *only a hint*. `SOCK_N
|
| 74/3 | 2026/09/26 18:46 | tool | grepper |
0mArgs:{
"Expression": "tcp_get_info",
"PathPrefix": "net/ipv4/"
}Results: {
"Output": "net/ipv4/tcp.c=4174=int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,\n--\nnet/ipv4/tcp.c-4185-\nnet/ipv4/tcp.c:4186:static void tcp_get_info_chrono_stats(const struct tcp_sock *tp,\nnet/ipv4/tcp.c-4187-\t\t\t\t struct tcp_info *info)\n--\nnet/ipv4/tcp.c-4211-/* Return information about state of tcp endpoint in API format. */\nnet/ipv4/tcp.c:4212:void tcp_get_info(struct sock *sk, struct tcp_info *info)\nnet/ipv4/tcp.c-4213-{\n--\nnet/ipv4/tcp.c-4311-\tinfo-\u003etcpi_notsent_bytes = max_t(int, 0, tp-\u003ewrite_seq - tp-\u003esnd_nxt);\nnet/ipv4/tcp.c:4312:\ttcp_get_info_chrono_stats(tp, info);\nnet/ipv4/tcp.c-4313-\n--\nnet/ipv4/tcp.c-4364-}\nnet/ipv4/tcp.c:4365:EXPORT_SYMBOL_GPL(tcp_get_info);\nnet/ipv4/tcp.c-4366-\n--\nnet/ipv4/tcp.c=4411=struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk,\n--\nnet/ipv4/tcp.c-4424-\nnet/ipv4/tcp.c:4425:\ttcp_get_info_chrono_stats(tp, \u0026info);\nnet/ipv4/tcp.c-4426-\tnla_put_u64_64bit(stats, TCP_NLA_BUSY,\n--\nnet/ipv4/tcp.c=4483=int do_tcp_getsockopt(struct sock *sk, int level,\n--\nnet/ipv4/tcp.c-4547-\nnet/ipv4/tcp.c:4548:\t\ttcp_get_info(sk, \u0026info);\nnet/ipv4/tcp.c-4549-\n--\nnet/ipv4/tcp_dctcp.c=127=__bpf_kfunc static void dctcp_update_alpha(struct sock *sk, u32 flags)\n--\nnet/ipv4/tcp_dctcp.c-164-\t\t}\nnet/ipv4/tcp_dctcp.c:165:\t\t/* dctcp_alpha can be read from dctcp_get_info() without\nnet/ipv4/tcp_dctcp.c-166-\t\t * synchro, so we ask compiler to not use dctcp_alpha\n--\nnet/ipv4/tcp_dctcp.c=212=__bpf_kfunc static void dctcp_cwnd_event_tx_start(struct sock *sk)\n--\nnet/ipv4/tcp_dctcp.c-218-\nnet/ipv4/tcp_dctcp.c:219:static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr,\nnet/ipv4/tcp_dctcp.c-220-\t\t\t union tcp_cc_info *info)\n--\nnet/ipv4/tcp_dctcp.c=255=static struct tcp_congestion_ops dctcp __read_mostly = {\n--\nnet/ipv4/tcp_dctcp.c-263-\t.set_state\t= dctcp_state,\nnet/ipv4/tcp_dctcp.c:264:\t.get_info\t= dctcp_get_info,\nnet/ipv4/tcp_dctcp.c-265-\t.flags\t\t= TCP_CONG_NEEDS_ECN,\n--\nnet/ipv4/tcp_dctcp.c=270=static struct tcp_congestion_ops dctcp_reno __read_mostly = {\n--\nnet/ipv4/tcp_dctcp.c-273-\t.undo_cwnd\t= tcp_reno_undo_cwnd,\nnet/ipv4/tcp_dctcp.c:274:\t.get_info\t= dctcp_get_info,\nnet/ipv4/tcp_dctcp.c-275-\t.owner\t\t= THIS_MODULE,\n--\nnet/ipv4/tcp_diag.c=21=static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,\n--\nnet/ipv4/tcp_diag.c-36-\tif (info)\nnet/ipv4/tcp_diag.c:37:\t\ttcp_get_info(sk, info);\nnet/ipv4/tcp_diag.c-38-}\n"
} |
| 75/3 | 2026/09/26 18:46 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53286 output: 21 thoughts: 442 Thoughts: **Analyzing the Potential Impact of a Kernel Structure Change** Okay, so `tcp_nospace` isn't making its way into the `tcp_info` structure, which is good. That's the user-space ABI, and we don't want to break compatibility. I need to make sure this doesn't introduce ABI breakages. `tcp_info` is in `include/uapi/linux/tcp.h` - I'm familiar with it. And `struct tcp_sock` is purely internal, residing in `include/linux/tcp.h`, so it *should* be fine, but I need to be *sure*. The question now is, could a change to `struct tcp_sock`, even if it's internal, cause problems? Let's quickly check the relevant diff in `include/linux/tcp.h`. Ah, here it is: `tcp_nospace` is being added. Interesting. Looking at the surrounding code, I see that previously, `chrono_type` was followed by `chrono_start`, with a 3-byte padding space in-between, because of alignment requirements. Now, the `tcp_nospace` field (1 byte) is inserted between them. So we now have a 2-byte padding. I need to confirm that neither `tcp_sock` nor any portion of it are copied directly to user space. It *should* be that only the selected fields are extracted into the `tcp_info` structure, but I need to make sure. Now, I also need to check how `struct tcp_sock` is allocated. Is it allocated anywhere other than `sk_alloc`? That's the other potential pitfall. I'll search for where `sizeof(struct tcp_sock)` is used to ensure it's not being placed anywhere that relies on an exact layout. |
| 76/3 | 2026/09/26 18:46 | tool | grepper |
0mArgs:{
"Expression": "sizeof\\(struct tcp_sock\\)"
}Results: {
"Output": "net/ipv4/tcp_ipv4.c=3347=struct proto tcp_prot = {\n--\nnet/ipv4/tcp_ipv4.c-3387-\t.max_header\t\t= MAX_TCP_HEADER,\nnet/ipv4/tcp_ipv4.c:3388:\t.obj_size\t\t= sizeof(struct tcp_sock),\nnet/ipv4/tcp_ipv4.c-3389-\t.freeptr_offset\t\t= offsetof(struct tcp_sock,\n"
} |
| 77/3 | 2026/09/26 18:46 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 54280 output: 360 thoughts: 2075 Thoughts: **Analysis of Potential Uninitialized Memory in TCP NOSPACE Handling** Okay, let's break this down. My primary concern is always uninitialized memory, and I need to be *sure* this change doesn't introduce any. The starting point is, of course, that `.obj_size = sizeof(struct tcp_sock)` in TCP and its variants ensures the structure is allocated and initialized to zero. `sk_alloc()` with `__GFP_ZERO` guarantees that. Furthermore, if the allocation uses slab or kmalloc, `want_init_on_alloc(priority)` is true, and `sk_prot_clear_nulls` ensures all bytes are cleared to zero. Cloning with `sk_clone` and `sock_copy` also ensures zeroing. We know `tp->tcp_nospace` is initialized in `subflow_ulp_init()` to 1, and `tcp_nospace` is explicitly set and cleared using memory barriers. The key change from `fs/dlm/lowcomms.c` involves replacing a check on `SOCKWQ_ASYNC_NOSPACE` with `SOCK_NOSPACE` and using `sk_set_nospace` and `sk_clear_nospace` which is the key. But that doesn't look like uninitialized memory since `con->sock->flags` is initialized when the socket is created. `net/sunrpc/svcsock.c` does a similar thing in `svc_udp_has_wspace`. However, this is for UDP, and `sk_set_nospace` on a UDP socket *conditionally* calls `tcp_set_nospace`, but only when the socket is TCP, and the `tcp_nospace` variable is only accessed within the TCP code. It is clear that the conditional branching guarantees no access to TCP data when the socket is UDP. I'm satisfied that `tcp_sk(sk)` is never accessed on a UDP socket. Now, let's consider `tcp_check_space(sk)`. This function is always called from within TCP code where `sk` is definitively a `tcp_sock`. We know `tcp_nospace` is a hint and that `SOCK_NOSPACE` is the authoritative flag. The code is carefully structured to avoid problems. Crucially, can race conditions lead to reading uninitialized memory? No, because `tcp_nospace` is simply 0 or 1. Is there any uninitialized memory being read or copied in the new logic? No. This patch manages flow control flags and doesn't expose internal kernel structures to userspace. Okay, let's verify against the 4 KMSAN criteria: 1. No kernel structures are sent to userspace. `tcp_nospace` is internal. 2. No conditional logic depends on uninitialized variables. `tcp_nospace` is *always* initialized (0 or 1). 3. No allocation/initialization of complex data structures with uninitialized fields are introduced. 4. No bounds checks or logic could cause access to uninitialized bytes. Therefore, this change doesn't introduce any uninitialized memory risks. Regular KASAN and concurrency/locking tools are sufficient. KMSAN is *not* needed here. I'm confident in my analysis. |
| 78/3 | 2026/09/26 18:47 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch introduces a cache field `tcp_nospace` in `struct tcp_sock` mirroring `SOCK_NOSPACE` on `sk-\u003esk_socket-\u003eflags`, and wraps setting/clearing of this flag with `sk_set_nospace()` and `sk_clear_nospace()` across socket callers (TCP, MPTCP, DLM, NVMe-oF, RDS, SMC, SUNRPC, TLS).\n\n1. `struct tcp_sock` is zero-initialized on allocation via `sk_alloc()`, where `want_init_on_alloc()` triggers `sk_prot_clear_nulls()` clearing the object. For cloned child sockets, `sock_copy()` replicates the zeroed state from the parent socket, and MPTCP subflows explicitly initialize `tp-\u003etcp_nospace = 1` in `subflow_ulp_init()`. The field is always properly initialized before any read.\n2. `tcp_nospace` is an internal kernel-only field within `struct tcp_sock` and is not part of user-facing structures (such as `struct tcp_info` in `include/uapi/linux/tcp.h`). No padding or structure bytes are copied to user space.\n3. No buffer bounds, length calculations, or allocations with uninitialized memory are modified.\n\nAny potential bugs from this patch (such as race conditions, memory ordering, or NULL pointer dereferences) fall under concurrency issues or standard functional errors, which are not detected by KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch introduces a cache field `tcp_nospace` in `struct tcp_sock` mirroring `SOCK_NOSPACE` on `sk-\u003esk_socket-\u003eflags`, and wraps setting/clearing of this flag with `sk_set_nospace()` and `sk_clear_nospace()` across socket callers (TCP, MPTCP, DLM, NVMe-oF, RDS, SMC, SUNRPC, TLS).\n\n1. `struct tcp_sock` is zero-initialized on allocation via `sk_alloc()`, where `want_init_on_alloc()` triggers `sk_prot_clear_nulls()` clearing the object. For cloned child sockets, `sock_copy()` replicates the zeroed state from the parent socket, and MPTCP subflows explicitly initialize `tp-\u003etcp_nospace = 1` in `subflow_ulp_init()`. The field is always properly initialized before any read.\n2. `tcp_nospace` is an internal kernel-only field within `struct tcp_sock` and is not part of user-facing structures (such as `struct tcp_info` in `include/uapi/linux/tcp.h`). No padding or structure bytes are copied to user space.\n3. No buffer bounds, length calculations, or allocations with uninitialized memory are modified.\n\nAny potential bugs from this patch (such as race conditions, memory ordering, or NULL pointer dereferences) fall under concurrency issues or standard functional errors, which are not detected by KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|