AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/26 14:45 flow patch-triage
2m Args:
null

Results:
{
  "EnableConfigs": [
    "MPTCP"
  ],
  "FocusSymbols": [
    "mptcp_subflow_ctx_release",
    "subflow_ctx_destruct",
    "mptcp_subflow_drop_ctx",
    "subflow_ulp_release",
    "mptcp_napi_poll",
    "__mptcp_close_ssk"
  ],
  "KMSANReasoning": "The patch modifies MPTCP subflow context lifetime management, deferring context destruction to the socket destructor (sk_destruct) and synchronizing with NAPI delegated action processing to avoid race conditions and use-after-free issues when subflows are closed or dropped.\n\nAll related context structures are zero-initialized at allocation time (via kzalloc_obj), and no new uninitialized memory paths, partial struct initializations, or kernel-to-user info leaks (e.g., via copy_to_user or netlink) are introduced. The risks introduced or addressed by this patch involve object lifecycles, race conditions, and reference counting, which manifest as use-after-free or double-free bugs—issues thoroughly covered by KASAN and standard kernel debugging facilities, not KMSAN.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch alters the lifecycle management and destruction sequence of MPTCP subflow contexts to address races between socket destruction, plain TCP fallback, and delegated actions processed by NAPI polling. It introduces an sk_destruct override (subflow_ctx_destruct), changes state transitions with the new MPTCP_DELEGATE_RETIRED flag in mptcp_napi_poll, and adds a runtime assertion (WARN_ON_ONCE) in mptcp_subflow_ctx_release. These changes are in core networking code and fully reachable in virtualized environments using MPTCP sockets over loopback or virtual network devices.",
  "WorthFuzzing": true
}

1/1 2026/10/26 14:45 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit cca5bd584c4c587d2e5be22d7497972b28f95f16\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Mon Oct 26 14:45:20 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c\nindex 7a22e9388e0e9..01b94a280c810 100644\n--- a/net/mptcp/protocol.c\n+++ b/net/mptcp/protocol.c\n@@ -2705,7 +2705,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,\n \t */\n \tif (!inet_csk(ssk)-\u003eicsk_ulp_ops) {\n \t\tWARN_ON_ONCE(!sock_flag(ssk, SOCK_DEAD));\n-\t\tkfree_rcu(subflow, rcu);\n+\t\tmptcp_subflow_ctx_release(ssk);\n \t} else {\n \t\t/* otherwise tcp will dispose of the ssk and subflow ctx */\n \t\t__tcp_close(ssk, 0);\n@@ -4793,6 +4793,21 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)\n \t\tstruct sock *ssk = mptcp_subflow_tcp_sock(subflow);\n \n \t\tbh_lock_sock_nested(ssk);\n+\t\tif (unlikely(!READ_ONCE(inet_csk(ssk)-\u003eicsk_ulp_ops))) {\n+\t\t\t/* The subflow was retired, by ULP release or by a\n+\t\t\t * fallback to plain TCP: nothing is left to process.\n+\t\t\t * The ops pointer is cleared with the socket owned or\n+\t\t\t * under its bh lock, so a racing read lands in the\n+\t\t\t * owned branch below instead.\n+\t\t\t * mptcp_subflow_drop_ctx() leaves a still queued\n+\t\t\t * context to us: free it now that it is dequeued.\n+\t\t\t */\n+\t\t\tif (xchg(\u0026subflow-\u003edelegated_status, 0) \u0026\n+\t\t\t    BIT(MPTCP_DELEGATE_RETIRED))\n+\t\t\t\tkfree_rcu(subflow, rcu);\n+\t\t\tgoto unlock;\n+\t\t}\n+\n \t\tif (!sock_owned_by_user(ssk)) {\n \t\t\tmptcp_subflow_process_delegated(ssk, xchg(\u0026subflow-\u003edelegated_status, 0));\n \t\t} else {\n@@ -4804,6 +4819,7 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)\n \t\t\tsmp_wmb();\n \t\t\tclear_bit(MPTCP_DELEGATE_SCHEDULED, \u0026subflow-\u003edelegated_status);\n \t\t}\n+unlock:\n \t\tbh_unlock_sock(ssk);\n \t\tsock_put(ssk);\n \ndiff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h\nindex 011e73d04ee60..45bae97a4e219 100644\n--- a/net/mptcp/protocol.h\n+++ b/net/mptcp/protocol.h\n@@ -553,8 +553,10 @@ DECLARE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);\n #define MPTCP_DELEGATE_SEND\t\t1\n #define MPTCP_DELEGATE_ACK\t\t2\n #define MPTCP_DELEGATE_SNDBUF\t\t3\n+#define MPTCP_DELEGATE_RETIRED\t\t4\t/* unreachable ctx, NAPI frees it */\n \n-#define MPTCP_DELEGATE_ACTIONS_MASK\t(~BIT(MPTCP_DELEGATE_SCHEDULED))\n+#define MPTCP_DELEGATE_ACTIONS_MASK\t(~(BIT(MPTCP_DELEGATE_SCHEDULED) | \\\n+\t\t\t\t\t   BIT(MPTCP_DELEGATE_RETIRED)))\n /* MPTCP subflow context */\n struct mptcp_subflow_context {\n \tstruct\tlist_head node;/* conn_list of subflows */\n@@ -593,7 +595,7 @@ struct mptcp_subflow_context {\n \t\tsend_fastclose : 1,\n \t\tsend_infinite_map : 1,\n \t\tremote_key_valid : 1,        /* received the peer key from */\n-\t\tdisposable : 1,\t    /* ctx can be free at ulp release time */\n+\t\tdisposable : 1,\t    /* ctx is no longer owned by the msk */\n \t\tclosing : 1,\t    /* must not pass rx data to msk anymore */\n \t\tvalid_csum_seen : 1,        /* at least one csum validated */\n \t\tis_mptfo : 1,\t    /* subflow is doing TFO */\n@@ -646,6 +648,7 @@ struct mptcp_subflow_context {\n \tconst\tstruct inet_connection_sock_af_ops *icsk_af_ops;\n \tvoid\t(*tcp_state_change)(struct sock *sk);\n \tvoid\t(*tcp_error_report)(struct sock *sk);\n+\tvoid\t(*tcp_sock_destruct)(struct sock *sk);\n \n \tstruct\trcu_head rcu;\n };\n@@ -761,6 +764,7 @@ mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow)\n }\n \n void mptcp_subflow_process_delegated(struct sock *ssk, long actions);\n+void mptcp_subflow_ctx_release(struct sock *ssk);\n \n static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow, int action)\n {\ndiff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c\nindex 78e886b202585..ebcface15661a 100644\n--- a/net/mptcp/subflow.c\n+++ b/net/mptcp/subflow.c\n@@ -471,7 +471,9 @@ void mptcp_subflow_reset(struct sock *ssk)\n \tif (ssk-\u003esk_state == TCP_CLOSE)\n \t\treturn;\n \n-\t/* must hold: tcp_done() could drop last reference on parent */\n+\t/* must hold: the parent reference owned by the subflow context is\n+\t * released together with ssk, which tcp_done() can destroy\n+\t */\n \tsock_hold(sk);\n \n \tsubflow-\u003eresetting = 1;\n@@ -814,6 +816,35 @@ static void subflow_ulp_fallback(struct sock *sk,\n \tmptcp_subflow_ops_undo_override(sk);\n }\n \n+static void subflow_ctx_destruct(struct sock *ssk)\n+{\n+\tstruct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);\n+\n+\trcu_assign_pointer(inet_csk(ssk)-\u003eicsk_ulp_data, NULL);\n+\tctx-\u003etcp_sock_destruct(ssk);\n+\tif (ctx-\u003econn)\n+\t\tsock_put(ctx-\u003econn);\n+\tkfree_rcu(ctx, rcu);\n+}\n+\n+/* Retire the context of a subflow socket that is being destroyed: a\n+ * delegated action, or any other holder of a socket reference, can still\n+ * reach the context, so free it together with the socket.\n+ *\n+ * Only an unhashed, dead socket may be retired this way. TCP never clones\n+ * such a socket, so the overridden destructor can't leak into a child.\n+ */\n+void mptcp_subflow_ctx_release(struct sock *ssk)\n+{\n+\tstruct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);\n+\n+\tif (WARN_ON_ONCE(ssk-\u003esk_destruct == subflow_ctx_destruct))\n+\t\treturn;\n+\n+\tctx-\u003etcp_sock_destruct = ssk-\u003esk_destruct;\n+\tssk-\u003esk_destruct = subflow_ctx_destruct;\n+}\n+\n void mptcp_subflow_drop_ctx(struct sock *ssk)\n {\n \tstruct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);\n@@ -826,9 +857,20 @@ void mptcp_subflow_drop_ctx(struct sock *ssk)\n \t\tsubflow_ulp_fallback(ssk, ctx);\n \t\tif (ctx-\u003econn)\n \t\t\tsock_put(ctx-\u003econn);\n-\t}\n \n-\tkfree_rcu(ctx, rcu);\n+\t\t/* The socket lives on as a plain TCP socket: it must keep\n+\t\t * neither a stale ULP context nor an overridden destructor,\n+\t\t * so the context can't be retired through sk_destruct here.\n+\t\t * A delegated action may still be queued for it, though:\n+\t\t * hand the context over to mptcp_napi_poll() in that case.\n+\t\t */\n+\t\tif (!(set_mask_bits(\u0026ctx-\u003edelegated_status, 0,\n+\t\t\t\t    BIT(MPTCP_DELEGATE_RETIRED)) \u0026\n+\t\t      BIT(MPTCP_DELEGATE_SCHEDULED)))\n+\t\t\tkfree_rcu(ctx, rcu);\n+\t} else {\n+\t\tmptcp_subflow_ctx_release(ssk);\n+\t}\n }\n \n void __mptcp_subflow_fully_established(struct mptcp_sock *msk,\n@@ -2082,12 +2124,11 @@ static void subflow_ulp_release(struct sock *ssk)\n \t\tif (!release \u0026\u0026 !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW,\n \t\t\t\t\t\t  \u0026mptcp_sk(sk)-\u003eflags))\n \t\t\tmptcp_schedule_work(sk);\n-\t\tsock_put(sk);\n \t}\n \n \tmptcp_subflow_ops_undo_override(ssk);\n \tif (release)\n-\t\tkfree_rcu(ctx, rcu);\n+\t\tmptcp_subflow_ctx_release(ssk);\n }\n \n static void subflow_ulp_clone(const struct request_sock *req,\n"
}

2/1 2026/10/26 14:45 agent patch-evaluator
1m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "MPTCP"
  ],
  "FocusSymbols": [
    "mptcp_subflow_ctx_release",
    "subflow_ctx_destruct",
    "mptcp_subflow_drop_ctx",
    "subflow_ulp_release",
    "mptcp_napi_poll",
    "__mptcp_close_ssk"
  ],
  "Reasoning": "The patch alters the lifecycle management and destruction sequence of MPTCP subflow contexts to address races between socket destruction, plain TCP fallback, and delegated actions processed by NAPI polling. It introduces an sk_destruct override (subflow_ctx_destruct), changes state transitions with the new MPTCP_DELEGATE_RETIRED flag in mptcp_napi_poll, and adds a runtime assertion (WARN_ON_ONCE) in mptcp_subflow_ctx_release. These changes are in core networking code and fully reachable in virtualized environments using MPTCP sockets over loopback or virtual network devices.",
  "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 cca5bd584c4c587d2e5be22d7497972b28f95f16
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Oct 26 14:45:20 2026 +0000

    syz-cluster: applied patch under review

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 7a22e9388e0e9..01b94a280c810 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2705,7 +2705,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 	 */
 	if (!inet_csk(ssk)->icsk_ulp_ops) {
 		WARN_ON_ONCE(!sock_flag(ssk, SOCK_DEAD));
-		kfree_rcu(subflow, rcu);
+		mptcp_subflow_ctx_release(ssk);
 	} else {
 		/* otherwise tcp will dispose of the ssk and subflow ctx */
 		__tcp_close(ssk, 0);
@@ -4793,6 +4793,21 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 
 		bh_lock_sock_nested(ssk);
+		if (unlikely(!READ_ONCE(inet_csk(ssk)->icsk_ulp_ops))) {
+			/* The subflow was retired, by ULP release or by a
+			 * fallback to plain TCP: nothing is left to process.
+			 * The ops pointer is cleared with the socket owned or
+			 * under its bh lock, so a racing read lands in the
+			 * owned branch below instead.
+			 * mptcp_subflow_drop_ctx() leaves a still queued
+			 * context to us: free it now that it is dequeued.
+			 */
+			if (xchg(&subflow->delegated_status, 0) &
+			    BIT(MPTCP_DELEGATE_RETIRED))
+				kfree_rcu(subflow, rcu);
+			goto unlock;
+		}
+
 		if (!sock_owned_by_user(ssk)) {
 			mptcp_subflow_process_delegated(ssk, xchg(&subflow->delegated_status, 0));
 		} else {
@@ -4804,6 +4819,7 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
 			smp_wmb();
 			clear_bit(MPTCP_DELEGATE_SCHEDULED, &subflow->delegated_status);
 		}
+unlock:
 		bh_unlock_sock(ssk);
 		sock_put(ssk);
 
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 011e73d04ee60..45bae97a4e219 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -553,8 +553,10 @@ DECLARE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
 #define MPTCP_DELEGATE_SEND		1
 #define MPTCP_DELEGATE_ACK		2
 #define MPTCP_DELEGATE_SNDBUF		3
+#define MPTCP_DELEGATE_RETIRED		4	/* unreachable ctx, NAPI frees it */
 
-#define MPTCP_DELEGATE_ACTIONS_MASK	(~BIT(MPTCP_DELEGATE_SCHEDULED))
+#define MPTCP_DELEGATE_ACTIONS_MASK	(~(BIT(MPTCP_DELEGATE_SCHEDULED) | \
+					   BIT(MPTCP_DELEGATE_RETIRED)))
 /* MPTCP subflow context */
 struct mptcp_subflow_context {
 	struct	list_head node;/* conn_list of subflows */
@@ -593,7 +595,7 @@ struct mptcp_subflow_context {
 		send_fastclose : 1,
 		send_infinite_map : 1,
 		remote_key_valid : 1,        /* received the peer key from */
-		disposable : 1,	    /* ctx can be free at ulp release time */
+		disposable : 1,	    /* ctx is no longer owned by the msk */
 		closing : 1,	    /* must not pass rx data to msk anymore */
 		valid_csum_seen : 1,        /* at least one csum validated */
 		is_mptfo : 1,	    /* subflow is doing TFO */
@@ -646,6 +648,7 @@ struct mptcp_subflow_context {
 	const	struct inet_connection_sock_af_ops *icsk_af_ops;
 	void	(*tcp_state_change)(struct sock *sk);
 	void	(*tcp_error_report)(struct sock *sk);
+	void	(*tcp_sock_destruct)(struct sock *sk);
 
 	struct	rcu_head rcu;
 };
@@ -761,6 +764,7 @@ mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow)
 }
 
 void mptcp_subflow_process_delegated(struct sock *ssk, long actions);
+void mptcp_subflow_ctx_release(struct sock *ssk);
 
 static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow, int action)
 {
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 78e886b202585..ebcface15661a 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -471,7 +471,9 @@ void mptcp_subflow_reset(struct sock *ssk)
 	if (ssk->sk_state == TCP_CLOSE)
 		return;
 
-	/* must hold: tcp_done() could drop last reference on parent */
+	/* must hold: the parent reference owned by the subflow context is
+	 * released together with ssk, which tcp_done() can destroy
+	 */
 	sock_hold(sk);
 
 	subflow->resetting = 1;
@@ -814,6 +816,35 @@ static void subflow_ulp_fallback(struct sock *sk,
 	mptcp_subflow_ops_undo_override(sk);
 }
 
+static void subflow_ctx_destruct(struct sock *ssk)
+{
+	struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);
+
+	rcu_assign_pointer(inet_csk(ssk)->icsk_ulp_data, NULL);
+	ctx->tcp_sock_destruct(ssk);
+	if (ctx->conn)
+		sock_put(ctx->conn);
+	kfree_rcu(ctx, rcu);
+}
+
+/* Retire the context of a subflow socket that is being destroyed: a
+ * delegated action, or any other holder of a socket reference, can still
+ * reach the context, so free it together with the socket.
+ *
+ * Only an unhashed, dead socket may be retired this way. TCP never clones
+ * such a socket, so the overridden destructor can't leak into a child.
+ */
+void mptcp_subflow_ctx_release(struct sock *ssk)
+{
+	struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);
+
+	if (WARN_ON_ONCE(ssk->sk_destruct == subflow_ctx_destruct))
+		return;
+
+	ctx->tcp_sock_destruct = ssk->sk_destruct;
+	ssk->sk_destruct = subflow_ctx_destruct;
+}
+
 void mptcp_subflow_drop_ctx(struct sock *ssk)
 {
 	struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);
@@ -826,9 +857,20 @@ void mptcp_subflow_drop_ctx(struct sock *ssk)
 		subflow_ulp_fallback(ssk, ctx);
 		if (ctx->conn)
 			sock_put(ctx->conn);
-	}
 
-	kfree_rcu(ctx, rcu);
+		/* The socket lives on as a plain TCP socket: it must keep
+		 * neither a stale ULP context nor an overridden destructor,
+		 * so the context can't be retired through sk_destruct here.
+		 * A delegated action may still be queued for it, though:
+		 * hand the context over to mptcp_napi_poll() in that case.
+		 */
+		if (!(set_mask_bits(&ctx->delegated_status, 0,
+				    BIT(MPTCP_DELEGATE_RETIRED)) &
+		      BIT(MPTCP_DELEGATE_SCHEDULED)))
+			kfree_rcu(ctx, rcu);
+	} else {
+		mptcp_subflow_ctx_release(ssk);
+	}
 }
 
 void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
@@ -2082,12 +2124,11 @@ static void subflow_ulp_release(struct sock *ssk)
 		if (!release && !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW,
 						  &mptcp_sk(sk)->flags))
 			mptcp_schedule_work(sk);
-		sock_put(sk);
 	}
 
 	mptcp_subflow_ops_undo_override(ssk);
 	if (release)
-		kfree_rcu(ctx, rcu);
+		mptcp_subflow_ctx_release(ssk);
 }
 
 static void subflow_ulp_clone(const struct request_sock *req,

3/2 2026/10/26 14:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 5347
							output: 33
							thoughts: 1387
						

Thoughts:
**Patch Evaluation: MPTCP Subflow Context Lifecycle**

Okay, let's dive into this patch series. First, I need to understand the scope. It looks like we're touching `net/mptcp/protocol.c`, `net/mptcp/protocol.h`, and `net/mptcp/subflow.c`. That places us squarely within the MPTCP (MultiPath TCP) subsystem in the networking stack. Given that MPTCP is core networking code and a frequent target for syzkaller, this warrants a careful examination.

My initial thought is to analyze the commit and assess whether the changes are reachable and worth fuzzing. The files impacted are a good indicator of the importance of this patch.

I'll start by scrutinizing the code diffs provided. In `protocol.c`, I see changes related to `__mptcp_close_ssk()`, and a new check within `mptcp_napi_poll()`. The `protocol.h` changes define `MPTCP_DELEGATE_RETIRED` and introduce `tcp_sock_destruct` within `mptcp_subflow_context` and a new `mptcp_subflow_ctx_release` function. The key changes are in `subflow.c`, including the implementation of `subflow_ctx_destruct`, `mptcp_subflow_ctx_release`, and modifications to `mptcp_subflow_drop_ctx()` and `subflow_ulp_release()`.

The diff reveals lifecycle and refcounting changes, specifically around `sock_put`, destructor chaining, and the retirement of delegated actions, and potential race conditions between `napi_poll`, `subflow_drop`, `subflow_release`, and `tcp_close`. The new `WARN_ON_ONCE` assertion within `mptcp_subflow_ctx_release` is a clear red flag; this is likely addressing a use-after-free or a race condition related to context release and delegated actions, which are notorious for these sorts of issues.

Now, let's assess reachability and fuzzing potential. MPTCP is fully reachable through standard network sockets, using `IPPROTO_MPTCP`, and loopback/virtual network devices. The code touches core subsystems: networking, refactoring, lifecycle management, and those classic race conditions, with runtime assertions thrown in for good measure.

Given this, I have to conclude that **this patch is definitely worth fuzzing**. The changes are in critical areas, and it is almost certainly attempting to address a tricky concurrency bug. I need to make sure the MPTCP configuration options are set. I need to grep the `Kconfig` for the required configuration options.



4/2 2026/10/26 14:45 tool grepper
0m Args:
{
  "Expression": "config MPTCP",
  "PathPrefixes": [
    "net/mptcp/Kconfig"
  ]
}

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"
}

5/2 2026/10/26 14:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 7569
							output: 34
							thoughts: 25
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing the MPTCP Configuration Dependencies**

Alright, let's dive in. My immediate thought is to head straight to `net/mptcp/Kconfig`. I need to understand the dependencies tied to the `config MPTCP` option. Knowing the dependencies is crucial; it'll tell me what other kernel features, options, or hardware support are required for MPTCP to even be considered a viable configuration. Specifically, I'm thinking about:

*   **Underlying Network Stack Components:** Are there dependencies on specific network protocols (like TCP, of course, but what about others that might influence MPTCP's behavior), or features within the networking stack (like specific congestion control algorithms)?
*   **Hardware Considerations:** Does it depend on specific hardware capabilities, like support for certain NIC features or offload engines? Is there any hard requirement that would need external components?
*   **Other Related Configuration Options:** What other kernel options might interact with MPTCP? Are there any options that might disable MPTCP, even if `config MPTCP` is enabled?

I'll be looking for things like `depends on`, `select`, `requires`, and any other config keywords that reveal how MPTCP's functionality ties into the overall kernel build and runtime. I'll need to think about how these dependencies might impact the system, performance, and overall stability. I need to understand everything that MPTCP relies on to perform its magic.



6/2 2026/10/26 14:45 tool read-file
0m Args:
{
  "File": "net/mptcp/Kconfig",
  "FirstLine": 1,
  "LineCount": 35
}

Results:
{
  "Contents": "   1:\t\n   2:\tconfig MPTCP\n   3:\t\tbool \"MPTCP: Multipath TCP\"\n   4:\t\tdepends on INET\n   5:\t\tselect SKB_EXTENSIONS\n   6:\t\tselect CRYPTO_LIB_SHA256\n   7:\t\tselect CRYPTO_LIB_UTILS\n   8:\t\thelp\n   9:\t\t  Multipath TCP (MPTCP) connections send and receive data over multiple\n  10:\t\t  subflows in order to utilize multiple network paths. Each subflow\n  11:\t\t  uses the TCP protocol, and TCP options carry header information for\n  12:\t\t  MPTCP.\n  13:\t\n  14:\tif MPTCP\n  15:\t\n  16:\tconfig INET_MPTCP_DIAG\n  17:\t\tdepends on INET_DIAG\n  18:\t\tdef_tristate INET_DIAG\n  19:\t\n  20:\tconfig MPTCP_IPV6\n  21:\t\tbool \"MPTCP: IPv6 support for Multipath TCP\"\n  22:\t\tdepends on IPV6=y\n  23:\t\tdefault y\n  24:\t\n  25:\tconfig MPTCP_KUNIT_TEST\n  26:\t\ttristate \"This builds the MPTCP KUnit tests\" if !KUNIT_ALL_TESTS\n  27:\t\tdepends on KUNIT\n  28:\t\tdefault KUNIT_ALL_TESTS\n  29:\t\thelp\n  30:\t\t  Currently covers the MPTCP crypto and token helpers.\n  31:\t\t  Only useful for kernel devs running KUnit test harness and are not\n  32:\t\t  for inclusion into a production build.\n  33:\t\n  34:\t\t  For more information on KUnit and unit tests in general please refer\n  35:\t\t  to the KUnit documentation in Documentation/dev-tools/kunit/.\n"
}

7/2 2026/10/26 14:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 8421
							output: 33
							thoughts: 23
						

Thoughts:
Here's a summary of my thinking process:

**MPTCP Dependency Investigation**

Okay, so I'm thinking about MPTCP and how it functions within the networking stack. My first thought is that MPTCP has a definite dependency on INET. I need to get a clearer understanding of this relationship, and how it is implemented.

To dig deeper, I'm going to look at the build configuration, and how MPTCP is brought in to the kernel. I'm going to examine the `net/mptcp/Makefile` file. That will be the key to understanding this dependency better.



8/2 2026/10/26 14:45 tool read-file
0m Args:
{
  "File": "net/mptcp/Makefile",
  "FirstLine": 1,
  "LineCount": 25
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0\n   2:\tobj-$(CONFIG_MPTCP) += mptcp.o\n   3:\t\n   4:\tmptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \\\n   5:\t\t   mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o sched.o \\\n   6:\t\t   mptcp_pm_gen.o pm_kernel.o\n   7:\t\n   8:\tobj-$(CONFIG_SYN_COOKIES) += syncookies.o\n   9:\tobj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o\n  10:\t\n  11:\tmptcp_crypto_test-objs := crypto_test.o\n  12:\tmptcp_token_test-objs := token_test.o\n  13:\tobj-$(CONFIG_MPTCP_KUNIT_TEST) += mptcp_crypto_test.o mptcp_token_test.o\n  14:\t\n  15:\tobj-$(CONFIG_BPF_SYSCALL) += bpf.o\n"
}

9/2 2026/10/26 14:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 8917
							output: 33
							thoughts: 274
						

Thoughts:
**Analyzing the Subflow Context Release Changes in MPTCP**

Okay, so I'm looking at these kernel configuration options; `CONFIG_MPTCP` is the key one here, as it's the gate for building `protocol.o` and `subflow.o`. That makes sense, and `CONFIG_INET` is the expected parent dependency. Now, let's dive into the specifics, focusing on the changes.

I need to see what's been modified or added related to this subflow context. I can see a few functions are the core of it:

I see:

1.  `mptcp_subflow_ctx_release` - A brand new function in `net/mptcp/subflow.c`, so that's interesting; what's it doing?
2.  `subflow_ctx_destruct` - Another new function in `net/mptcp/subflow.c`, and it's static, so it should be used in the same file. I want to understand its scope.
3.  `mptcp_subflow_drop_ctx` - This one's been modified in `net/mptcp/subflow.c`; I need to see *how* it's been changed. What are the implications?
4.  `subflow_ulp_release` - This is also modified in `net/mptcp/subflow.c`. I need to understand its relationship to the other functions, specifically what calls it and what relies on it.
5.  `mptcp_napi_poll` - This function is modified in `net/mptcp/protocol.c` - so I need to see how it works now with these subflow changes.
6.  `__mptcp_close_ssk` - It's also modified in `net/mptcp/protocol.c`, and I need to see how this subflow context release works with an established connection.

I need to check how `mptcp_subflow_process_delegated` or other callers interacts with these functions, and especially where `subflow_ulp_release` is being used now. That's where I need to focus next. I think this will tell me the overall direction and purpose of the changes.



10/2 2026/10/26 14:45 tool grepper
0m Args:
{
  "Expression": "subflow_ulp_release",
  "PathPrefixes": [
    "net/mptcp/"
  ]
}

Results:
{
  "Output": "net/mptcp/subflow.c=2059=static int subflow_ulp_init(struct sock *sk)\n--\nnet/mptcp/subflow.c-2103-\nnet/mptcp/subflow.c:2104:static void subflow_ulp_release(struct sock *ssk)\nnet/mptcp/subflow.c-2105-{\n--\nnet/mptcp/subflow.c=2216=static struct tcp_ulp_ops subflow_ulp_ops __read_mostly = {\n--\nnet/mptcp/subflow.c-2219-\t.init\t\t= subflow_ulp_init,\nnet/mptcp/subflow.c:2220:\t.release\t= subflow_ulp_release,\nnet/mptcp/subflow.c-2221-\t.clone\t\t= subflow_ulp_clone,\n"
}

11/2 2026/10/26 14:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 9955
							output: 37
							thoughts: 20
						

Thoughts:
Here's my thought process, as if I were considering this myself:

**Investigating the `mptcp_subflow_drop_ctx` Function Calls**

Okay, so I need to understand the impact and usage of `mptcp_subflow_drop_ctx`. My first step, naturally, is to trace where this function is actually *called* within the codebase. I need to figure out where the context, represented by that function, is being utilized and managed. That's the starting point. Time to dive into the call graph and see who's invoking this function. This is critical for assessing how this part of the MPTCP stack behaves.



12/2 2026/10/26 14:46 tool grepper
0m Args:
{
  "Expression": "mptcp_subflow_drop_ctx",
  "PathPrefixes": [
    "net/mptcp/"
  ]
}

Results:
{
  "Output": "net/mptcp/protocol.c=2642=static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,\n--\nnet/mptcp/protocol.c-2680-\t\tmptcp_set_close_tout(sk, tcp_jiffies32 - (mptcp_close_timeout(sk) + 1));\nnet/mptcp/protocol.c:2681:\t\tmptcp_subflow_drop_ctx(ssk);\nnet/mptcp/protocol.c-2682-\t\tgoto out_release;\n--\nnet/mptcp/protocol.c=4785=static int mptcp_napi_poll(struct napi_struct *napi, int budget)\n--\nnet/mptcp/protocol.c-4801-\t\t\t * owned branch below instead.\nnet/mptcp/protocol.c:4802:\t\t\t * mptcp_subflow_drop_ctx() leaves a still queued\nnet/mptcp/protocol.c-4803-\t\t\t * context to us: free it now that it is dequeued.\n--\nnet/mptcp/protocol.h=923=bool mptcp_subflow_active(struct mptcp_subflow_context *subflow);\nnet/mptcp/protocol.h-924-\nnet/mptcp/protocol.h:925:void mptcp_subflow_drop_ctx(struct sock *ssk);\nnet/mptcp/protocol.h-926-\n--\nnet/mptcp/subflow.c=837=void mptcp_subflow_ctx_release(struct sock *ssk)\n--\nnet/mptcp/subflow.c-847-\nnet/mptcp/subflow.c:848:void mptcp_subflow_drop_ctx(struct sock *ssk)\nnet/mptcp/subflow.c-849-{\n--\nnet/mptcp/subflow.c=885=static struct sock *subflow_syn_recv_sock(const struct sock *sk,\n--\nnet/mptcp/subflow.c-1044-dispose_child:\nnet/mptcp/subflow.c:1045:\tmptcp_subflow_drop_ctx(child);\nnet/mptcp/subflow.c-1046-\ttcp_rsk(req)-\u003edrop_req = true;\n--\nnet/mptcp/subflow.c-1057-\t\tSUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK);\nnet/mptcp/subflow.c:1058:\tmptcp_subflow_drop_ctx(child);\nnet/mptcp/subflow.c-1059-\treturn child;\n"
}

13/2 2026/10/26 14:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 10860
							output: 35
							thoughts: 17
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing the `__mptcp_close_ssk` Callers**

Alright, before I dive deeper into this, I need to make sure I'm not missing anything crucial related to the `__mptcp_close_ssk` function. It's often the smaller details that trip me up, so a systematic review is in order. My initial focus was on X, Y, and Z, but it suddenly struck me: I should also explicitly check the callers of `__mptcp_close_ssk`. You know how it goes; a bug can often originate upstream. This might reveal some unexpected usage patterns, potential race conditions I've overlooked, or assumptions in other parts of the code that are now invalidating the use of the function. Understanding where and how this function is *called* is just as important, if not more important, than understanding the function's internal logic at this stage. It is important to remember what the code does, as well as where.



14/2 2026/10/26 14:46 tool grepper
0m Args:
{
  "Expression": "__mptcp_close_ssk",
  "PathPrefixes": [
    "net/mptcp/"
  ]
}

Results:
{
  "Output": "net/mptcp/protocol.c=2558=bool __mptcp_retransmit_pending_data(struct sock *sk)\n--\nnet/mptcp/protocol.c-2594-\nnet/mptcp/protocol.c:2595:/* flags for __mptcp_close_ssk() */\nnet/mptcp/protocol.c-2596-#define MPTCP_CF_PUSH\t\tBIT(1)\n--\nnet/mptcp/protocol.c=2618=static void mptcp_cleanup_ssk_backlog(struct sock *sk, struct sock *ssk)\n--\nnet/mptcp/protocol.c-2641- */\nnet/mptcp/protocol.c:2642:static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,\nnet/mptcp/protocol.c-2643-\t\t\t      struct mptcp_subflow_context *subflow,\n--\nnet/mptcp/protocol.c=2748=void mptcp_close_ssk(struct sock *sk, struct sock *ssk,\n--\nnet/mptcp/protocol.c-2764-\nnet/mptcp/protocol.c:2765:\t__mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_PUSH);\nnet/mptcp/protocol.c-2766-}\n--\nnet/mptcp/protocol.c=3122=static void mptcp_worker(struct work_struct *work)\n--\nnet/mptcp/protocol.c-3149-\t\tmptcp_for_each_subflow_safe(msk, subflow, tmp)\nnet/mptcp/protocol.c:3150:\t\t\t__mptcp_close_ssk(sk, subflow-\u003etcp_sock, subflow, 0);\nnet/mptcp/protocol.c-3151-\t\tmptcp_close_wake_up(sk);\n--\nnet/mptcp/protocol.c=3569=static void mptcp_destroy_common(struct mptcp_sock *msk)\n--\nnet/mptcp/protocol.c-3578-\tmptcp_for_each_subflow_safe(msk, subflow, tmp)\nnet/mptcp/protocol.c:3579:\t\t__mptcp_close_ssk(sk, mptcp_subflow_tcp_sock(subflow), subflow, 0);\nnet/mptcp/protocol.c-3580-\n--\nnet/mptcp/protocol.c=4104=static int mptcp_ioctl_outq(const struct mptcp_sock *msk, u64 v)\n--\nnet/mptcp/protocol.c-4119-\t\t/* the first subflow is disconnected after close - see\nnet/mptcp/protocol.c:4120:\t\t * __mptcp_close_ssk(). tcp_disconnect() moves the write_seq\nnet/mptcp/protocol.c-4121-\t\t * so ignore that status, too.\n--\nnet/mptcp/subflow.c=1962=static void subflow_state_change(struct sock *sk)\n--\nnet/mptcp/subflow.c-1969-\t/* Rx queue processing is unneeded, error reporting will take place at\nnet/mptcp/subflow.c:1970:\t * __mptcp_close_ssk() time and subflow reset can't happen in case of\nnet/mptcp/subflow.c-1971-\t * fallback: subflow_sched_work_if_closed() would be a no-op.\n--\nnet/mptcp/subflow.c=2104=static void subflow_ulp_release(struct sock *ssk)\n--\nnet/mptcp/subflow.c-2115-\t\t/* if the msk has been orphaned, keep the ctx\nnet/mptcp/subflow.c:2116:\t\t * alive, will be freed by __mptcp_close_ssk(),\nnet/mptcp/subflow.c-2117-\t\t * when the subflow is still unaccepted\n"
}

15/2 2026/10/26 14:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 12187
							output: 35
							thoughts: 36
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing the `mptcp_napi_poll` Function**

Alright, time to dig into this `mptcp_napi_poll` function. My first instinct, as always, is to understand its scope and usage. Where is this thing actually *called*? No need for a lengthy review of the code; I'll get straight to the point. I'll fire up a `grep` – that's the fastest and most reliable way to trace its usage within the codebase and get a quick overview of its context. Knowing where it's used will then allow me to quickly build a mental map of its purpose, inputs, outputs, and how it fits into the broader Multipath TCP architecture. Let's see what we find!



16/2 2026/10/26 14:46 tool grepper
0m Args:
{
  "Expression": "mptcp_napi_poll",
  "PathPrefixes": [
    "net/mptcp/"
  ]
}

Results:
{
  "Output": "net/mptcp/protocol.c=4777=static struct inet_protosw mptcp_protosw = {\n--\nnet/mptcp/protocol.c-4784-\nnet/mptcp/protocol.c:4785:static int mptcp_napi_poll(struct napi_struct *napi, int budget)\nnet/mptcp/protocol.c-4786-{\n--\nnet/mptcp/protocol.c=4837=void __init mptcp_proto_init(void)\n--\nnet/mptcp/protocol.c-4853-\t\tnetif_napi_add_tx(mptcp_napi_dev, \u0026delegated-\u003enapi,\nnet/mptcp/protocol.c:4854:\t\t\t\t  mptcp_napi_poll);\nnet/mptcp/protocol.c-4855-\t\tnapi_enable(\u0026delegated-\u003enapi);\n--\nnet/mptcp/protocol.h=769=static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow, int action)\n--\nnet/mptcp/protocol.h-778-\t/* The implied barrier pairs with tcp_release_cb_override()\nnet/mptcp/protocol.h:779:\t * mptcp_napi_poll(), and ensures the below list check sees list\nnet/mptcp/protocol.h-780-\t * updates done prior to delegated status bits changes\n--\nnet/mptcp/subflow.c=848=void mptcp_subflow_drop_ctx(struct sock *ssk)\n--\nnet/mptcp/subflow.c-864-\t\t * A delegated action may still be queued for it, though:\nnet/mptcp/subflow.c:865:\t\t * hand the context over to mptcp_napi_poll() in that case.\nnet/mptcp/subflow.c-866-\t\t */\n--\nnet/mptcp/subflow.c=2189=static void tcp_release_cb_override(struct sock *ssk)\n--\nnet/mptcp/subflow.c-2195-\t * the napi queue. To respect locking, only the same CPU that originated\nnet/mptcp/subflow.c:2196:\t * the action can touch the list. mptcp_napi_poll will take care of it.\nnet/mptcp/subflow.c-2197-\t */\n"
}

17/2 2026/10/26 14:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 13064
							output: 234
							thoughts: 1952
						

Thoughts:
**Analysis of MPTCP Subflow Context Lifecycle Patch**

Okay, let's break this down. My initial assessment focuses on the functions involved: `mptcp_subflow_ctx_release`, `subflow_ctx_destruct`, `mptcp_subflow_drop_ctx`, `subflow_ulp_release`, `mptcp_napi_poll`, and `__mptcp_close_ssk`. Are they core, universally used functions? No, they are all very specific to MPTCP's subflow management, its delegated actions, and the overall lifecycle of these subflows. This immediately flags them as potential areas for careful scrutiny.

Next, I'm checking the changes. The diff clearly shows modifications to `net/mptcp/protocol.c`, `net/mptcp/protocol.h`, and `net/mptcp/subflow.c`. I need to understand the scope and impact here. The commit message provides crucial context - syz-cluster indicates a patch under review, likely related to fuzzing.

Diving into the changes, in `protocol.c`, `__mptcp_close_ssk` is now calling `mptcp_subflow_ctx_release` instead of directly freeing. `mptcp_napi_poll` is updated to handle `MPTCP_DELEGATE_RETIRED` and correctly free the subflow context. `protocol.h` introduces `MPTCP_DELEGATE_RETIRED`, updates the delegate action mask, adds a `tcp_sock_destruct` pointer, and declares `mptcp_subflow_ctx_release`. Finally, `subflow.c` sees updates to comments in `mptcp_subflow_reset`. `subflow_ctx_destruct` now sets `inet_csk(ssk)->icsk_ulp_data` to NULL, calls the previous `tcp_sock_destruct`, drops ref on `ctx->conn`, and then frees the context. `mptcp_subflow_ctx_release` hooks into the socket's destruction with `subflow_ctx_destruct` and contains a runtime assertion. `mptcp_subflow_drop_ctx` now either sets `MPTCP_DELEGATE_RETIRED` or calls `kfree_rcu` based on context, and `subflow_ulp_release` also uses `mptcp_subflow_ctx_release`.

The crux of this patch is about addressing subflow context lifetime issues and race conditions, especially regarding delegated actions, which execute in NAPI context, and socket destruction, or TCP fallback. By deferring destruction using `sk_destruct` and correctly handling retired subflows in `mptcp_napi_poll`, this patch aims to prevent use-after-free or data corruption issues. However, these fixes can introduce new concurrency issues and require great care. The introduction of `WARN_ON_ONCE` suggests the developers are aware of these potential issues.

Now, how reachable is this code? Very reachable. Standard QEMU, using MPTCP sockets with AF_INET/AF_INET6 are all available to trigger these specific paths, especially with loopback connections. Syzkaller's existing MPTCP support confirms this.

We need to make sure the necessary kernel configs are present. `MPTCP` is the essential one, along with `INET` as a base requirement. No need to include `MPTCP_IPV6` separately, since `MPTCP` handles all of `net/mptcp/`.

The key functions to focus on are the ones identified initially: `mptcp_subflow_ctx_release`, `subflow_ctx_destruct`, `mptcp_subflow_drop_ctx`, `subflow_ulp_release`, `mptcp_napi_poll`, and `__mptcp_close_ssk`. The fact that `subflow_ctx_destruct`, `subflow_ulp_release` and `mptcp_napi_poll` are static but will be compiled into `vmlinux` makes them worth checking. Similarly, although `__mptcp_close_ssk` is static, it's called from several other functions which could be exported.

Given all this, I conclude:
-   This patch is definitely worth fuzzing.
-   The reasoning is clear: it fixes critical concurrency and lifecycle management issues in MPTCP subflows, particularly around socket destruction and delegated actions. The changes involve modifying `sk_destruct`, and `mptcp_napi_poll`, introducing an assertion, and are all fully reachable.
-   The focus symbols are: `mptcp_subflow_ctx_release`, `subflow_ctx_dest


18/2 2026/10/26 14:46 tool set-results
0m Args:
{
  "EnableConfigs": [
    "MPTCP"
  ],
  "FocusSymbols": [
    "mptcp_subflow_ctx_release",
    "subflow_ctx_destruct",
    "mptcp_subflow_drop_ctx",
    "subflow_ulp_release",
    "mptcp_napi_poll",
    "__mptcp_close_ssk"
  ],
  "Reasoning": "The patch alters the lifecycle management and destruction sequence of MPTCP subflow contexts to address races between socket destruction, plain TCP fallback, and delegated actions processed by NAPI polling. It introduces an sk_destruct override (subflow_ctx_destruct), changes state transitions with the new MPTCP_DELEGATE_RETIRED flag in mptcp_napi_poll, and adds a runtime assertion (WARN_ON_ONCE) in mptcp_subflow_ctx_release. These changes are in core networking code and fully reachable in virtualized environments using MPTCP sockets over loopback or virtual network devices.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "MPTCP"
  ],
  "FocusSymbols": [
    "mptcp_subflow_ctx_release",
    "subflow_ctx_destruct",
    "mptcp_subflow_drop_ctx",
    "subflow_ulp_release",
    "mptcp_napi_poll",
    "__mptcp_close_ssk"
  ],
  "Reasoning": "The patch alters the lifecycle management and destruction sequence of MPTCP subflow contexts to address races between socket destruction, plain TCP fallback, and delegated actions processed by NAPI polling. It introduces an sk_destruct override (subflow_ctx_destruct), changes state transitions with the new MPTCP_DELEGATE_RETIRED flag in mptcp_napi_poll, and adds a runtime assertion (WARN_ON_ONCE) in mptcp_subflow_ctx_release. These changes are in core networking code and fully reachable in virtualized environments using MPTCP sockets over loopback or virtual network devices.",
  "WorthFuzzing": true
}

19/1 2026/10/26 14:46 action If
1m Args:
{
  "WorthFuzzing": true
}

Results:
null

20/2 2026/10/26 14:46 agent kmsan-evaluator
1m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch modifies MPTCP subflow context lifetime management, deferring context destruction to the socket destructor (sk_destruct) and synchronizing with NAPI delegated action processing to avoid race conditions and use-after-free issues when subflows are closed or dropped.\n\nAll related context structures are zero-initialized at allocation time (via kzalloc_obj), and no new uninitialized memory paths, partial struct initializations, or kernel-to-user info leaks (e.g., via copy_to_user or netlink) are introduced. The risks introduced or addressed by this patch involve object lifecycles, race conditions, and reference counting, which manifest as use-after-free or double-free bugs—issues thoroughly covered by KASAN and standard kernel debugging facilities, not KMSAN.",
  "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 cca5bd584c4c587d2e5be22d7497972b28f95f16
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Oct 26 14:45:20 2026 +0000

    syz-cluster: applied patch under review

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 7a22e9388e0e9..01b94a280c810 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2705,7 +2705,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 	 */
 	if (!inet_csk(ssk)->icsk_ulp_ops) {
 		WARN_ON_ONCE(!sock_flag(ssk, SOCK_DEAD));
-		kfree_rcu(subflow, rcu);
+		mptcp_subflow_ctx_release(ssk);
 	} else {
 		/* otherwise tcp will dispose of the ssk and subflow ctx */
 		__tcp_close(ssk, 0);
@@ -4793,6 +4793,21 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 
 		bh_lock_sock_nested(ssk);
+		if (unlikely(!READ_ONCE(inet_csk(ssk)->icsk_ulp_ops))) {
+			/* The subflow was retired, by ULP release or by a
+			 * fallback to plain TCP: nothing is left to process.
+			 * The ops pointer is cleared with the socket owned or
+			 * under its bh lock, so a racing read lands in the
+			 * owned branch below instead.
+			 * mptcp_subflow_drop_ctx() leaves a still queued
+			 * context to us: free it now that it is dequeued.
+			 */
+			if (xchg(&subflow->delegated_status, 0) &
+			    BIT(MPTCP_DELEGATE_RETIRED))
+				kfree_rcu(subflow, rcu);
+			goto unlock;
+		}
+
 		if (!sock_owned_by_user(ssk)) {
 			mptcp_subflow_process_delegated(ssk, xchg(&subflow->delegated_status, 0));
 		} else {
@@ -4804,6 +4819,7 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
 			smp_wmb();
 			clear_bit(MPTCP_DELEGATE_SCHEDULED, &subflow->delegated_status);
 		}
+unlock:
 		bh_unlock_sock(ssk);
 		sock_put(ssk);
 
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 011e73d04ee60..45bae97a4e219 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -553,8 +553,10 @@ DECLARE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
 #define MPTCP_DELEGATE_SEND		1
 #define MPTCP_DELEGATE_ACK		2
 #define MPTCP_DELEGATE_SNDBUF		3
+#define MPTCP_DELEGATE_RETIRED		4	/* unreachable ctx, NAPI frees it */
 
-#define MPTCP_DELEGATE_ACTIONS_MASK	(~BIT(MPTCP_DELEGATE_SCHEDULED))
+#define MPTCP_DELEGATE_ACTIONS_MASK	(~(BIT(MPTCP_DELEGATE_SCHEDULED) | \
+					   BIT(MPTCP_DELEGATE_RETIRED)))
 /* MPTCP subflow context */
 struct mptcp_subflow_context {
 	struct	list_head node;/* conn_list of subflows */
@@ -593,7 +595,7 @@ struct mptcp_subflow_context {
 		send_fastclose : 1,
 		send_infinite_map : 1,
 		remote_key_valid : 1,        /* received the peer key from */
-		disposable : 1,	    /* ctx can be free at ulp release time */
+		disposable : 1,	    /* ctx is no longer owned by the msk */
 		closing : 1,	    /* must not pass rx data to msk anymore */
 		valid_csum_seen : 1,        /* at least one csum validated */
 		is_mptfo : 1,	    /* subflow is doing TFO */
@@ -646,6 +648,7 @@ struct mptcp_subflow_context {
 	const	struct inet_connection_sock_af_ops *icsk_af_ops;
 	void	(*tcp_state_change)(struct sock *sk);
 	void	(*tcp_error_report)(struct sock *sk);
+	void	(*tcp_sock_destruct)(struct sock *sk);
 
 	struct	rcu_head rcu;
 };
@@ -761,6 +764,7 @@ mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow)
 }
 
 void mptcp_subflow_process_delegated(struct sock *ssk, long actions);
+void mptcp_subflow_ctx_release(struct sock *ssk);
 
 static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow, int action)
 {
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 78e886b202585..ebcface15661a 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -471,7 +471,9 @@ void mptcp_subflow_reset(struct sock *ssk)
 	if (ssk->sk_state == TCP_CLOSE)
 		return;
 
-	/* must hold: tcp_done() could drop last reference on parent */
+	/* must hold: the parent reference owned by the subflow context is
+	 * released together with ssk, which tcp_done() can destroy
+	 */
 	sock_hold(sk);
 
 	subflow->resetting = 1;
@@ -814,6 +816,35 @@ static void subflow_ulp_fallback(struct sock *sk,
 	mptcp_subflow_ops_undo_override(sk);
 }
 
+static void subflow_ctx_destruct(struct sock *ssk)
+{
+	struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);
+
+	rcu_assign_pointer(inet_csk(ssk)->icsk_ulp_data, NULL);
+	ctx->tcp_sock_destruct(ssk);
+	if (ctx->conn)
+		sock_put(ctx->conn);
+	kfree_rcu(ctx, rcu);
+}
+
+/* Retire the context of a subflow socket that is being destroyed: a
+ * delegated action, or any other holder of a socket reference, can still
+ * reach the context, so free it together with the socket.
+ *
+ * Only an unhashed, dead socket may be retired this way. TCP never clones
+ * such a socket, so the overridden destructor can't leak into a child.
+ */
+void mptcp_subflow_ctx_release(struct sock *ssk)
+{
+	struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);
+
+	if (WARN_ON_ONCE(ssk->sk_destruct == subflow_ctx_destruct))
+		return;
+
+	ctx->tcp_sock_destruct = ssk->sk_destruct;
+	ssk->sk_destruct = subflow_ctx_destruct;
+}
+
 void mptcp_subflow_drop_ctx(struct sock *ssk)
 {
 	struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);
@@ -826,9 +857,20 @@ void mptcp_subflow_drop_ctx(struct sock *ssk)
 		subflow_ulp_fallback(ssk, ctx);
 		if (ctx->conn)
 			sock_put(ctx->conn);
-	}
 
-	kfree_rcu(ctx, rcu);
+		/* The socket lives on as a plain TCP socket: it must keep
+		 * neither a stale ULP context nor an overridden destructor,
+		 * so the context can't be retired through sk_destruct here.
+		 * A delegated action may still be queued for it, though:
+		 * hand the context over to mptcp_napi_poll() in that case.
+		 */
+		if (!(set_mask_bits(&ctx->delegated_status, 0,
+				    BIT(MPTCP_DELEGATE_RETIRED)) &
+		      BIT(MPTCP_DELEGATE_SCHEDULED)))
+			kfree_rcu(ctx, rcu);
+	} else {
+		mptcp_subflow_ctx_release(ssk);
+	}
 }
 
 void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
@@ -2082,12 +2124,11 @@ static void subflow_ulp_release(struct sock *ssk)
 		if (!release && !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW,
 						  &mptcp_sk(sk)->flags))
 			mptcp_schedule_work(sk);
-		sock_put(sk);
 	}
 
 	mptcp_subflow_ops_undo_override(ssk);
 	if (release)
-		kfree_rcu(ctx, rcu);
+		mptcp_subflow_ctx_release(ssk);
 }
 
 static void subflow_ulp_clone(const struct request_sock *req,

21/3 2026/10/26 14:46 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 4559
							output: 36
							thoughts: 1152
						

Thoughts:
**Analyzing the Patch for KMSAN Fuzzing Necessity**

Okay, here's the deal: I need to decide if this patch requires dedicated KMSAN fuzzing or if KASAN/LOCKDEP will suffice. Since this is a vulnerability auditing task, it's low-severity, defensive work, so it's safe to proceed.

First, I'll dive into the patch itself. What does it do? Let's break it down:

*   **`net/mptcp/protocol.c`**: The critical change is `__mptcp_close_ssk`, which now calls `mptcp_subflow_ctx_release(ssk)` instead of a direct `kfree_rcu`. Also in `mptcp_napi_poll`: A new check has been added to guard against using freed structures.
*   **`net/mptcp/protocol.h`**: We see definitions for `MPTCP_DELEGATE_RETIRED` and updates to masks, and the introduction of a new `tcp_sock_destruct` function pointer and `mptcp_subflow_ctx_release` function.
*   **`net/mptcp/subflow.c`**: We have `subflow_ctx_destruct`, which handles the freeing of the subflow context, and the new `mptcp_subflow_ctx_release`, where the function pointers are arranged to ensure correct clean-up. `mptcp_subflow_drop_ctx` now uses `mptcp_subflow_ctx_release` for some fallback scenarios and `subflow_ulp_release` now calls `mptcp_subflow_ctx_release` instead of `kfree_rcu` directly.

So, it's all about subflow context lifetime management, which is likely a use-after-free or race condition fix. It seems the patch is trying to synchronize the context's destruction with the socket's lifecycle, specifically in relation to NAPI poll handling and delegated actions. The key is in the `mptcp_subflow_ctx_release` and `subflow_ctx_destruct`.

Basically, there's a risk that a subflow context could be freed before being cleaned up, particularly if a delegated action is queued on it in NAPI poll. This could lead to a use-after-free or a race. The patch is trying to ensure that the context is cleaned up by the socket destructor, or that it gets cleaned up after the delegated action is dequeued.

Now, to determine the *best* fuzzing strategy, I'd like to check the git log and related code for more information using `grepper` or other tools. I'll need to know the origin of the bug, what scenarios trigger it, and if it's really the context lifetime that is the main issue.



22/3 2026/10/26 14:46 tool grepper
0m Args:
{
  "Expression": "mptcp_subflow_ctx_release",
  "PathPrefixes": [
    "net/mptcp"
  ]
}

Results:
{
  "Output": "net/mptcp/protocol.c=2642=static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,\n--\nnet/mptcp/protocol.c-2707-\t\tWARN_ON_ONCE(!sock_flag(ssk, SOCK_DEAD));\nnet/mptcp/protocol.c:2708:\t\tmptcp_subflow_ctx_release(ssk);\nnet/mptcp/protocol.c-2709-\t} else {\n--\nnet/mptcp/protocol.h=766=void mptcp_subflow_process_delegated(struct sock *ssk, long actions);\nnet/mptcp/protocol.h:767:void mptcp_subflow_ctx_release(struct sock *ssk);\nnet/mptcp/protocol.h-768-\n--\nnet/mptcp/subflow.c=819=static void subflow_ctx_destruct(struct sock *ssk)\n--\nnet/mptcp/subflow.c-836- */\nnet/mptcp/subflow.c:837:void mptcp_subflow_ctx_release(struct sock *ssk)\nnet/mptcp/subflow.c-838-{\n--\nnet/mptcp/subflow.c=848=void mptcp_subflow_drop_ctx(struct sock *ssk)\n--\nnet/mptcp/subflow.c-871-\t} else {\nnet/mptcp/subflow.c:872:\t\tmptcp_subflow_ctx_release(ssk);\nnet/mptcp/subflow.c-873-\t}\n--\nnet/mptcp/subflow.c=2104=static void subflow_ulp_release(struct sock *ssk)\n--\nnet/mptcp/subflow.c-2130-\tif (release)\nnet/mptcp/subflow.c:2131:\t\tmptcp_subflow_ctx_release(ssk);\nnet/mptcp/subflow.c-2132-}\n"
}

23/3 2026/10/26 14:46 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 6891
							output: 39
							thoughts: 28
						

Thoughts:
Here's a summary of my thought process, as requested:

**Contextual Investigation**

Okay, so I need to understand what's happening around `subflow_ulp_release` and `mptcp_subflow_drop_ctx`. My first thought is to dive into the code and see how these two functions are related, if at all. Is one called from within the other? Are they used in similar situations? What data structures do they operate on, and are those structures shared in any way? This is likely related to MPTCP subflow management, so I need to see how these functions interact with the core MPTCP connection state. I also need to understand why I'm looking at these specific functions in the first place. What problem are we trying to solve or understand? Is it a performance issue, a bug, or just a general review? This contextual understanding is crucial to avoid a wild goose chase. I need to trace the execution path and identify potential bottlenecks or areas for improvement in the subflow lifecycle. Time to get my hands dirty and start digging into the surrounding code!



24/3 2026/10/26 14:47 tool read-file
0m Args:
{
  "File": "net/mptcp/subflow.c",
  "FirstLine": 2100,
  "LineCount": 40
}

Results:
{
  "Contents": "2100:\tout:\n2101:\t\treturn err;\n2102:\t}\n2103:\t\n2104:\tstatic void subflow_ulp_release(struct sock *ssk)\n2105:\t{\n2106:\t\tstruct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);\n2107:\t\tbool release = true;\n2108:\t\tstruct sock *sk;\n2109:\t\n2110:\t\tif (!ctx)\n2111:\t\t\treturn;\n2112:\t\n2113:\t\tsk = ctx-\u003econn;\n2114:\t\tif (sk) {\n2115:\t\t\t/* if the msk has been orphaned, keep the ctx\n2116:\t\t\t * alive, will be freed by __mptcp_close_ssk(),\n2117:\t\t\t * when the subflow is still unaccepted\n2118:\t\t\t */\n2119:\t\t\trelease = ctx-\u003edisposable || list_empty(\u0026ctx-\u003enode);\n2120:\t\n2121:\t\t\t/* inet_child_forget() does not call sk_state_change(),\n2122:\t\t\t * explicitly trigger the socket close machinery\n2123:\t\t\t */\n2124:\t\t\tif (!release \u0026\u0026 !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW,\n2125:\t\t\t\t\t\t\t  \u0026mptcp_sk(sk)-\u003eflags))\n2126:\t\t\t\tmptcp_schedule_work(sk);\n2127:\t\t}\n2128:\t\n2129:\t\tmptcp_subflow_ops_undo_override(ssk);\n2130:\t\tif (release)\n2131:\t\t\tmptcp_subflow_ctx_release(ssk);\n2132:\t}\n2133:\t\n2134:\tstatic void subflow_ulp_clone(const struct request_sock *req,\n2135:\t\t\t\t      struct sock *newsk,\n2136:\t\t\t\t      const gfp_t priority)\n2137:\t{\n2138:\t\tstruct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req);\n2139:\t\tstruct mptcp_subflow_context *old_ctx = mptcp_subflow_ctx(newsk);\n"
}

25/3 2026/10/26 14:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 7795
							output: 38
							thoughts: 17
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating a Potential Socket Leak in MPTCP**

Alright, so we're tracking down something in MPTCP, probably a socket leak based on the context. My initial thought is to make sure we're comprehensively covering the shutdown path. We've got our eye on things, but it's crucial to be absolutely thorough. Specifically, I need to check the `__mptcp_close_ssk` function to ensure that it's handling the teardown and resource release correctly. We can't afford to miss any potential areas where sockets might not be properly cleaned up. A subtle leak there could manifest in all sorts of nasty ways down the line. It’s the kind of thing you have to chase down methodically, piece by piece. Time to dive in and get to the bottom of this!



26/3 2026/10/26 14:47 tool read-file
0m Args:
{
  "File": "net/mptcp/protocol.c",
  "FirstLine": 2695,
  "LineCount": 30
}

Results:
{
  "Contents": "2695:\t\t\trelease_sock(ssk);\n2696:\t\n2697:\t\t\tgoto out;\n2698:\t\t}\n2699:\t\n2700:\t\tsubflow-\u003edisposable = 1;\n2701:\t\n2702:\t\t/* if ssk hit tcp_done(), tcp_cleanup_ulp() cleared the related ops\n2703:\t\t * the ssk has been already destroyed, we just need to release the\n2704:\t\t * reference owned by msk;\n2705:\t\t */\n2706:\t\tif (!inet_csk(ssk)-\u003eicsk_ulp_ops) {\n2707:\t\t\tWARN_ON_ONCE(!sock_flag(ssk, SOCK_DEAD));\n2708:\t\t\tmptcp_subflow_ctx_release(ssk);\n2709:\t\t} else {\n2710:\t\t\t/* otherwise tcp will dispose of the ssk and subflow ctx */\n2711:\t\t\t__tcp_close(ssk, 0);\n2712:\t\n2713:\t\t\t/* close acquired an extra ref */\n2714:\t\t\t__sock_put(ssk);\n2715:\t\t}\n2716:\t\n2717:\tout_release:\n2718:\t\t__mptcp_subflow_error_report(sk, ssk);\n2719:\t\trelease_sock(ssk);\n2720:\t\n2721:\t\tsock_put(ssk);\n2722:\t\n2723:\t\tif (ssk == msk-\u003efirst)\n2724:\t\t\tWRITE_ONCE(msk-\u003efirst, NULL);\n"
}

27/3 2026/10/26 14:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 8465
							output: 38
							thoughts: 29
						

Thoughts:
Okay, let's dive into this. Here's my summary, taking on the persona you've requested:

**Investigating `mptcp_subflow_drop_ctx`**

Alright, let's get down to it. I need to refresh my memory on how MPTCP subflow context dropping is handled. Specifically, I'm thinking about `mptcp_subflow_drop_ctx`. Time to head over to the source code – that means `net/mptcp/subflow.c` is the target. I need to understand the logic in that function and how it fits into the broader picture of MPTCP connection management, especially when considering packet loss and subflow failure scenarios. I want to see how the context clean-up works, potential race conditions, and error handling. This could be critical for diagnosing some of those complex, intermittent MPTCP issues I've been seeing. Gotta make sure I'm up-to-date with this!



28/3 2026/10/26 14:47 tool read-file
0m Args:
{
  "File": "net/mptcp/subflow.c",
  "FirstLine": 840,
  "LineCount": 45
}

Results:
{
  "Contents": " 840:\t\n 841:\t\tif (WARN_ON_ONCE(ssk-\u003esk_destruct == subflow_ctx_destruct))\n 842:\t\t\treturn;\n 843:\t\n 844:\t\tctx-\u003etcp_sock_destruct = ssk-\u003esk_destruct;\n 845:\t\tssk-\u003esk_destruct = subflow_ctx_destruct;\n 846:\t}\n 847:\t\n 848:\tvoid mptcp_subflow_drop_ctx(struct sock *ssk)\n 849:\t{\n 850:\t\tstruct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk);\n 851:\t\n 852:\t\tif (!ctx)\n 853:\t\t\treturn;\n 854:\t\n 855:\t\tlist_del(\u0026mptcp_subflow_ctx(ssk)-\u003enode);\n 856:\t\tif (inet_csk(ssk)-\u003eicsk_ulp_ops) {\n 857:\t\t\tsubflow_ulp_fallback(ssk, ctx);\n 858:\t\t\tif (ctx-\u003econn)\n 859:\t\t\t\tsock_put(ctx-\u003econn);\n 860:\t\n 861:\t\t\t/* The socket lives on as a plain TCP socket: it must keep\n 862:\t\t\t * neither a stale ULP context nor an overridden destructor,\n 863:\t\t\t * so the context can't be retired through sk_destruct here.\n 864:\t\t\t * A delegated action may still be queued for it, though:\n 865:\t\t\t * hand the context over to mptcp_napi_poll() in that case.\n 866:\t\t\t */\n 867:\t\t\tif (!(set_mask_bits(\u0026ctx-\u003edelegated_status, 0,\n 868:\t\t\t\t\t    BIT(MPTCP_DELEGATE_RETIRED)) \u0026\n 869:\t\t\t      BIT(MPTCP_DELEGATE_SCHEDULED)))\n 870:\t\t\t\tkfree_rcu(ctx, rcu);\n 871:\t\t} else {\n 872:\t\t\tmptcp_subflow_ctx_release(ssk);\n 873:\t\t}\n 874:\t}\n 875:\t\n 876:\tvoid __mptcp_subflow_fully_established(struct mptcp_sock *msk,\n 877:\t\t\t\t\t       struct mptcp_subflow_context *subflow,\n 878:\t\t\t\t\t       const struct mptcp_options_received *mp_opt)\n 879:\t{\n 880:\t\tsubflow_set_remote_key(msk, subflow, mp_opt);\n 881:\t\tWRITE_ONCE(subflow-\u003efully_established, true);\n 882:\t\tWRITE_ONCE(msk-\u003efully_established, true);\n 883:\t}\n 884:\t\n"
}

29/3 2026/10/26 14:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 9481
							output: 38
							thoughts: 26
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Diving into `mptcp_napi_poll`**

Alright, time to dig into the heart of the MultiPath TCP (MPTCP) NAPI (Network API) polling mechanism. My initial thought is to navigate straight to the `mptcp_napi_poll` function within `net/mptcp/protocol.c`. I need to get a clear picture of how MPTCP interfaces with the NAPI framework. I want to understand how it processes incoming packets, handles scheduling, and interacts with the device driver. I'm hoping to quickly identify the crucial synchronization points, any potential bottlenecks, and how the MPTCP layer manages its own queues within the NAPI context. I'm looking for the "meat" of the packet processing and scheduling logic.



30/3 2026/10/26 14:47 tool read-file
0m Args:
{
  "File": "net/mptcp/protocol.c",
  "FirstLine": 4785,
  "LineCount": 45
}

Results:
{
  "Contents": "4785:\tstatic int mptcp_napi_poll(struct napi_struct *napi, int budget)\n4786:\t{\n4787:\t\tstruct mptcp_delegated_action *delegated;\n4788:\t\tstruct mptcp_subflow_context *subflow;\n4789:\t\tint work_done = 0;\n4790:\t\n4791:\t\tdelegated = container_of(napi, struct mptcp_delegated_action, napi);\n4792:\t\twhile ((subflow = mptcp_subflow_delegated_next(delegated)) != NULL) {\n4793:\t\t\tstruct sock *ssk = mptcp_subflow_tcp_sock(subflow);\n4794:\t\n4795:\t\t\tbh_lock_sock_nested(ssk);\n4796:\t\t\tif (unlikely(!READ_ONCE(inet_csk(ssk)-\u003eicsk_ulp_ops))) {\n4797:\t\t\t\t/* The subflow was retired, by ULP release or by a\n4798:\t\t\t\t * fallback to plain TCP: nothing is left to process.\n4799:\t\t\t\t * The ops pointer is cleared with the socket owned or\n4800:\t\t\t\t * under its bh lock, so a racing read lands in the\n4801:\t\t\t\t * owned branch below instead.\n4802:\t\t\t\t * mptcp_subflow_drop_ctx() leaves a still queued\n4803:\t\t\t\t * context to us: free it now that it is dequeued.\n4804:\t\t\t\t */\n4805:\t\t\t\tif (xchg(\u0026subflow-\u003edelegated_status, 0) \u0026\n4806:\t\t\t\t    BIT(MPTCP_DELEGATE_RETIRED))\n4807:\t\t\t\t\tkfree_rcu(subflow, rcu);\n4808:\t\t\t\tgoto unlock;\n4809:\t\t\t}\n4810:\t\n4811:\t\t\tif (!sock_owned_by_user(ssk)) {\n4812:\t\t\t\tmptcp_subflow_process_delegated(ssk, xchg(\u0026subflow-\u003edelegated_status, 0));\n4813:\t\t\t} else {\n4814:\t\t\t\t/* tcp_release_cb_override already processed\n4815:\t\t\t\t * the action or will do at next release_sock().\n4816:\t\t\t\t * In both case must dequeue the subflow here - on the same\n4817:\t\t\t\t * CPU that scheduled it.\n4818:\t\t\t\t */\n4819:\t\t\t\tsmp_wmb();\n4820:\t\t\t\tclear_bit(MPTCP_DELEGATE_SCHEDULED, \u0026subflow-\u003edelegated_status);\n4821:\t\t\t}\n4822:\tunlock:\n4823:\t\t\tbh_unlock_sock(ssk);\n4824:\t\t\tsock_put(ssk);\n4825:\t\n4826:\t\t\tif (++work_done == budget)\n4827:\t\t\t\treturn budget;\n4828:\t\t}\n4829:\t\n"
}

31/3 2026/10/26 14:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 10493
							output: 36
							thoughts: 774
						

Thoughts:
**KMSAN vs. KASAN: A Thoughtful Analysis**

Okay, so I'm diving into this code change and need to determine if a KMSAN run is even warranted. Let's see, the text emphasizes a critical point: KMSAN is costly, so I shouldn't waste time on it if standard KASAN or other debug tools can handle the potential issues. We are talking about uninitialized memory reads and leaks *only*. KASAN already covers the usual suspects - out-of-bounds, use-after-free, double frees, and locking issues. I need to be strategic here.

The rule of thumb is clear: **NeedsKMSAN=true ONLY if the patch introduces or modifies kernel structures sent to user space where there's a risk of uninitialized fields, or if we see conditional logic or complex data structures relying on uninitialized variables.** Also, any potential uninitialized bytes due to logic or bounds checks. Otherwise, **NeedsKMSAN=false.** If everything is zeroed or initialized before use, we're good. If the patch avoids introducing information leaks, then we are good.

Now, let's analyze the patch itself.

1.  **MPTCP Changes:** It looks like this patch is all about socket cleanup and subflow context release in MPTCP, focusing on avoiding a potential race/use-after-free situation where the context might be freed prematurely. I'm focusing on the `mptcp_subflow_ctx_release` and the handling of the retired subflow flag (`MPTCP_DELEGATE_RETIRED`) in `mptcp_napi_poll()`.

2.  **User-Space Implications:** Does this touch any kernel structures sent to user space? No, nothing is being sent to user space.

3.  **Uninitialized Memory:** Does the code change use any uninitialized memory or new stack/heap allocations? No, the code changes are not allocating any new memory.

4.  **Conditional Logic:** Is there any conditional branching that depends on uninitialized variables? I don't see any of that. The `delegated_status` flag, used in conditional logic, is an atomic bitfield within the `mptcp_subflow_context` structure, and it is allocated either using `kmem_cache_zalloc` or `kzalloc`, which means it will be zero-initialized. I should double-check the allocation.

So, based on this initial assessment, I'm leaning heavily towards **NeedsKMSAN=false**. I'll confirm that allocation and then I'm confident that KASAN and the usual debug techniques will be enough here. The patch deals with race conditions and memory safety, which KASAN, LOCKDEP, and the other standard debug detectors are equipped to catch.



32/3 2026/10/26 14:47 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "mptcp_subflow_create_ctx",
  "PathPrefixes": [
    "net/mptcp"
  ]
}

Results:
{
  "error": "no matches"
}

33/3 2026/10/26 14:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 11911
							output: 32
							thoughts: 18
						

Thoughts:
Here's my thought process, as requested:

**Tracing the Allocation of `mptcp_subflow_context`**

Okay, so I need to figure out where the `mptcp_subflow_context` structure is actually being allocated in the kernel. This is fundamental for understanding how Multipath TCP (MPTCP) manages its subflows. I'm going to start with the obvious approach: a code search. I'll need to use my usual tools – likely `grep` or maybe even `git grep` if the code is under version control. The goal is to find all instances where `mptcp_subflow_context` is *allocated*, and that implies calls to functions like `kmalloc`, `kzalloc`, `alloc_page`, or possibly custom allocation routines specific to MPTCP. I'll need to be aware of how these functions might be wrapped or used in macros, which can obscure things a bit. I'll also watch out for potential constructors or initializers that might be indirectly allocating it as part of a larger structure. I'll need to consider allocation within the context of MPTCP's connection establishment and data transfer phases, because those contexts are where these subflows are born. From there, I'll analyze the call paths and try to follow the flow from high-level MPTCP operations down to the allocation function calls. This will give me the allocation location context I need.



34/3 2026/10/26 14:47 tool grepper
0m Args:
{
  "Expression": "subflow_create_ctx",
  "PathPrefixes": [
    "net/mptcp"
  ]
}

Results:
{
  "Output": "net/mptcp/subflow.c=1864=int mptcp_subflow_create_socket(struct sock *sk, unsigned short family,\n--\nnet/mptcp/subflow.c-1928-\nnet/mptcp/subflow.c:1929:static struct mptcp_subflow_context *subflow_create_ctx(struct sock *sk,\nnet/mptcp/subflow.c-1930-\t\t\t\t\t\t\tgfp_t priority)\n--\nnet/mptcp/subflow.c=2059=static int subflow_ulp_init(struct sock *sk)\n--\nnet/mptcp/subflow.c-2073-\nnet/mptcp/subflow.c:2074:\tctx = subflow_create_ctx(sk, GFP_KERNEL);\nnet/mptcp/subflow.c-2075-\tif (!ctx) {\n--\nnet/mptcp/subflow.c=2134=static void subflow_ulp_clone(const struct request_sock *req,\n--\nnet/mptcp/subflow.c-2147-\nnet/mptcp/subflow.c:2148:\tnew_ctx = subflow_create_ctx(newsk, priority);\nnet/mptcp/subflow.c-2149-\tif (!new_ctx) {\n"
}

35/3 2026/10/26 14:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 12616
							output: 39
							thoughts: 12
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience, presented in the first person:

**Diving into `subflow_create_ctx`**

Alright, let's get down to brass tacks. My initial thought is to zero in on `subflow_create_ctx`. It's the critical entry point, the keystone of the entire subflow creation process. Given the context, I'm expecting this to be where the foundational elements are initialized. I need to understand what's being set up here – the core data structures, any default configurations, resource allocation, and any preliminary validation that might be taking place. My expert intuition is telling me that a deep dive into `subflow_create_ctx` will illuminate the architecture of the subflow management system, its dependencies, and potential bottlenecks. This is where I can get a true understanding of the control flow, the data flow and the general function of the process. I anticipate needing to trace variable assignments, inspect object instantiation, and identify any crucial hooks or extension points within this context. I'll need to focus on what data is used, how it is used and why it is being used.



36/3 2026/10/26 14:47 tool read-file
0m Args:
{
  "File": "net/mptcp/subflow.c",
  "FirstLine": 1928,
  "LineCount": 25
}

Results:
{
  "Contents": "1928:\t\n1929:\tstatic struct mptcp_subflow_context *subflow_create_ctx(struct sock *sk,\n1930:\t\t\t\t\t\t\t\tgfp_t priority)\n1931:\t{\n1932:\t\tstruct inet_connection_sock *icsk = inet_csk(sk);\n1933:\t\tstruct mptcp_subflow_context *ctx;\n1934:\t\n1935:\t\tctx = kzalloc_obj(*ctx, priority);\n1936:\t\tif (!ctx)\n1937:\t\t\treturn NULL;\n1938:\t\n1939:\t\trcu_assign_pointer(icsk-\u003eicsk_ulp_data, ctx);\n1940:\t\tINIT_LIST_HEAD(\u0026ctx-\u003enode);\n1941:\t\tINIT_LIST_HEAD(\u0026ctx-\u003edelegated_node);\n1942:\t\n1943:\t\tpr_debug(\"subflow=%p\\n\", ctx);\n1944:\t\n1945:\t\tctx-\u003etcp_sock = sk;\n1946:\t\tWRITE_ONCE(ctx-\u003elocal_id, -1);\n1947:\t\n1948:\t\treturn ctx;\n1949:\t}\n1950:\t\n1951:\tstatic void __subflow_state_change(struct sock *sk)\n1952:\t{\n"
}

37/3 2026/10/26 14:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 13276
							output: 190
							thoughts: 426
						

Thoughts:
**My Assessment of the MPTCP Subflow Context Patch**

Okay, so looking at this patch, my initial thought is that the `struct mptcp_subflow_context` is being allocated with `kzalloc_obj`, which means it's completely zeroed out initially. Good, that's clean. The addition of `tcp_sock_destruct` to the `struct mptcp_subflow_context` and its assignment to `ssk->sk_destruct` confirms this zero-initialization. This is good practice.

What this patch is clearly aiming to resolve is a classic object lifecycle problem – reference counting and the dreaded race condition. Specifically, it's about preventing use-after-free or double-free scenarios when subflows are torn down, particularly when they're in the middle of delegated actions within NAPI or while TCP socket destruction is still pending. This is a critical area for MPTCP, and I'm glad to see it being addressed proactively.

The good news is that any potential pitfalls introduced by this change are well-covered by standard kernel debugging tools. KASAN will catch any use-after-free or double-free issues. KMEMLEAK will detect memory leaks, and LOCKDEP will ensure locking sanity avoiding deadlock. Assertions like WARN_ON_ONCE and BUG_ON will also flag any unexpected states. That's a solid defense-in-depth approach.

Furthermore, I see no indication of uninitialized memory reads or any potential for information leaks to userspace. Therefore, the "NeedsKMSAN=false" assessment is correct. There's no justification for KMSAN here.

Let's quickly recap and confirm the reasoning: the patch modifies the MPTCP subflow context lifecycle and socket destruction hooks, handling delegated actions during NAPI poll and ULP release/drop. The patch addresses lifetime management and race conditions between socket destruction and NAPI delegated processing. Any bugs here would be use-after-free, double-free, or reference count leaks, which are monitored by KASAN and standard kernel debuggers. There's nothing about uninitialized memory allocations, partial struct initializations, user-space copies, or conditional branches on uninitialized memory. Therefore, a dedicated KMSAN session is not justified.

Alright, that covers it. I'm satisfied with the analysis. Let's call `set-results`.



38/3 2026/10/26 14:48 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch modifies MPTCP subflow context lifetime management, deferring context destruction to the socket destructor (sk_destruct) and synchronizing with NAPI delegated action processing to avoid race conditions and use-after-free issues when subflows are closed or dropped.\n\nAll related context structures are zero-initialized at allocation time (via kzalloc_obj), and no new uninitialized memory paths, partial struct initializations, or kernel-to-user info leaks (e.g., via copy_to_user or netlink) are introduced. The risks introduced or addressed by this patch involve object lifecycles, race conditions, and reference counting, which manifest as use-after-free or double-free bugs—issues thoroughly covered by KASAN and standard kernel debugging facilities, not KMSAN.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch modifies MPTCP subflow context lifetime management, deferring context destruction to the socket destructor (sk_destruct) and synchronizing with NAPI delegated action processing to avoid race conditions and use-after-free issues when subflows are closed or dropped.\n\nAll related context structures are zero-initialized at allocation time (via kzalloc_obj), and no new uninitialized memory paths, partial struct initializations, or kernel-to-user info leaks (e.g., via copy_to_user or netlink) are introduced. The risks introduced or addressed by this patch involve object lifecycles, race conditions, and reference counting, which manifest as use-after-free or double-free bugs—issues thoroughly covered by KASAN and standard kernel debugging facilities, not KMSAN.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)