* [PATCH mptcp] mptcp: fix uninitialized local_id in syncookie MP_JOIN reconstruction
@ 2026-08-11 21:51 Harshit Varu
2026-08-11 22:23 ` [PATCH mptcp v2] mptcp: restore full join state " Harshit Varu
0 siblings, 1 reply; 4+ messages in thread
From: Harshit Varu @ 2026-08-11 21:51 UTC (permalink / raw)
To: netdev; +Cc: mptcp, matttbe, martineau, security, Harshit Varu, stable
mptcp_token_join_cookie_init_state() restores remote_nonce, local_nonce,
backup, join_id, token and msk from the saved cookie entry when rebuilding
the request socket for a MP_JOIN 4th-ACK handled under SYN cookies, but it
does not restore local_id, even though the SYN path saved it.
subflow_ulp_clone() then reads that uninitialized field and stores it as
the joined subflow's address-ID. Because the request-sock slab is
SLAB_TYPESAFE_BY_RCU and not zeroed on allocation, the value is the stale
byte of a previously freed request socket, which an off-path peer can
influence by sending concurrent MP_JOIN SYNs. This corrupts the path
manager's id-based subflow bookkeeping for the connection.
Restore subflow_req->local_id from the cookie entry, as done for the other
fields.
Fixes: 9466a1ccebbe ("mptcp: enable JOIN requests even if cookies are in use")
Cc: stable@vger.kernel.org
Assisted-by: opencode:deepseek-v4-flash
Signed-off-by: Harshit Varu <harshitvaru666@gmail.com>
---
net/mptcp/syncookies.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/mptcp/syncookies.c b/net/mptcp/syncookies.c
index 7f2252634..b5cac5701 100644
--- a/net/mptcp/syncookies.c
+++ b/net/mptcp/syncookies.c
@@ -118,6 +118,7 @@ bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subfl
subflow_req->local_nonce = e->local_nonce;
subflow_req->backup = e->backup;
subflow_req->remote_id = e->join_id;
+ subflow_req->local_id = e->local_id;
subflow_req->token = e->token;
subflow_req->msk = msk;
spin_unlock_bh(&join_entry_locks[i]);
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH mptcp v2] mptcp: restore full join state in syncookie MP_JOIN reconstruction
2026-08-11 21:51 [PATCH mptcp] mptcp: fix uninitialized local_id in syncookie MP_JOIN reconstruction Harshit Varu
@ 2026-08-11 22:23 ` Harshit Varu
2026-08-12 9:10 ` Paolo Abeni
0 siblings, 1 reply; 4+ messages in thread
From: Harshit Varu @ 2026-08-11 22:23 UTC (permalink / raw)
To: netdev; +Cc: mptcp, matttbe, martineau, security, Harshit Varu, stable
mptcp_token_join_cookie_init_state() rebuilds the request socket for a
MP_JOIN 4th-ACK that was handled under SYN cookies, but it only restores
remote_nonce, local_nonce, backup, join_id, token and msk from the saved
cookie entry. local_id, request_bkup and thmac are never restored, even
though the SYN path saves local_id and computes the other two.
subflow_ulp_clone() then reads those three fields and copies them into the
joined subflow context (local_id, request_bkup, thmac). Because the
request-sock slab is SLAB_TYPESAFE_BY_RCU and not zeroed on allocation, the
values are stale bytes of previously freed request sockets, which an
off-path peer can influence by sending concurrent MP_JOIN SYNs. A corrupted
local_id breaks id-based path-manager bookkeeping, and a corrupted
request_bkup misclassifies the subflow in the packet scheduler's
backup/active selection.
Save and restore request_bkup and thmac as well, completing the state
restore.
Fixes: 9466a1ccebbe ("mptcp: enable JOIN requests even if cookies are in use")
Cc: stable@vger.kernel.org
Assisted-by: opencode:deepseek-v4-flash
Signed-off-by: Harshit Varu <harshitvaru666@gmail.com>
---
net/mptcp/syncookies.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/mptcp/syncookies.c b/net/mptcp/syncookies.c
index 7f2252634..3c25ff627 100644
--- a/net/mptcp/syncookies.c
+++ b/net/mptcp/syncookies.c
@@ -27,7 +27,9 @@ struct join_entry {
u8 join_id;
u8 local_id;
u8 backup;
+ u8 request_bkup;
u8 valid;
+ u64 thmac;
};
#define COOKIE_JOIN_SLOTS 1024
@@ -63,8 +65,10 @@ static void mptcp_join_store_state(struct join_entry *entry,
entry->remote_nonce = subflow_req->remote_nonce;
entry->local_nonce = subflow_req->local_nonce;
entry->backup = subflow_req->backup;
+ entry->request_bkup = subflow_req->request_bkup;
entry->join_id = subflow_req->remote_id;
entry->local_id = subflow_req->local_id;
+ entry->thmac = subflow_req->thmac;
entry->valid = 1;
}
@@ -117,8 +121,11 @@ bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subfl
subflow_req->remote_nonce = e->remote_nonce;
subflow_req->local_nonce = e->local_nonce;
subflow_req->backup = e->backup;
+ subflow_req->request_bkup = e->request_bkup;
subflow_req->remote_id = e->join_id;
+ subflow_req->local_id = e->local_id;
subflow_req->token = e->token;
+ subflow_req->thmac = e->thmac;
subflow_req->msk = msk;
spin_unlock_bh(&join_entry_locks[i]);
return true;
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH mptcp v2] mptcp: restore full join state in syncookie MP_JOIN reconstruction
2026-08-11 22:23 ` [PATCH mptcp v2] mptcp: restore full join state " Harshit Varu
@ 2026-08-12 9:10 ` Paolo Abeni
2026-08-14 22:56 ` Matthieu Baerts
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2026-08-12 9:10 UTC (permalink / raw)
To: Harshit Varu, netdev; +Cc: mptcp, matttbe, martineau, security, stable
On 8/12/26 12:23 AM, Harshit Varu wrote:
> mptcp_token_join_cookie_init_state() rebuilds the request socket for a
> MP_JOIN 4th-ACK that was handled under SYN cookies, but it only restores
> remote_nonce, local_nonce, backup, join_id, token and msk from the saved
> cookie entry. local_id, request_bkup and thmac are never restored, even
> though the SYN path saves local_id and computes the other two.
>
> subflow_ulp_clone() then reads those three fields and copies them into the
> joined subflow context (local_id, request_bkup, thmac). Because the
> request-sock slab is SLAB_TYPESAFE_BY_RCU and not zeroed on allocation, the
> values are stale bytes of previously freed request sockets, which an
> off-path peer can influence by sending concurrent MP_JOIN SYNs. A corrupted
> local_id breaks id-based path-manager bookkeeping, and a corrupted
> request_bkup misclassifies the subflow in the packet scheduler's
> backup/active selection.
>
> Save and restore request_bkup and thmac as well, completing the state
> restore.
>
> Fixes: 9466a1ccebbe ("mptcp: enable JOIN requests even if cookies are in use")
> Cc: stable@vger.kernel.org
> Assisted-by: opencode:deepseek-v4-flash
> Signed-off-by: Harshit Varu <harshitvaru666@gmail.com>
> ---
> net/mptcp/syncookies.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/net/mptcp/syncookies.c b/net/mptcp/syncookies.c
> index 7f2252634..3c25ff627 100644
> --- a/net/mptcp/syncookies.c
> +++ b/net/mptcp/syncookies.c
> @@ -27,7 +27,9 @@ struct join_entry {
> u8 join_id;
> u8 local_id;
> u8 backup;
> + u8 request_bkup;
> u8 valid;
> + u64 thmac;
Is thmac used for passive flows after
mptcp_token_join_cookie_init_state()? I think it's not. If so just init
to 0 in mptcp_token_join_cookie_init_state (with a comment) and remove
remove the new field from here.
Same for request_bkup, AFAICS both are used in syn_ack only.
The bottom line is that we don't want to increase `struct join_entry`
size without good reasons.
/P
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH mptcp v2] mptcp: restore full join state in syncookie MP_JOIN reconstruction
2026-08-12 9:10 ` Paolo Abeni
@ 2026-08-14 22:56 ` Matthieu Baerts
0 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2026-08-14 22:56 UTC (permalink / raw)
To: Paolo Abeni, Harshit Varu, netdev; +Cc: mptcp, martineau, security, stable
Hi Harshit, Paolo,
@Paolo: thank you for the review!
On 12/08/2026 11:10, Paolo Abeni wrote:
> On 8/12/26 12:23 AM, Harshit Varu wrote:
>> mptcp_token_join_cookie_init_state() rebuilds the request socket for a
>> MP_JOIN 4th-ACK that was handled under SYN cookies, but it only restores
>> remote_nonce, local_nonce, backup, join_id, token and msk from the saved
>> cookie entry. local_id, request_bkup and thmac are never restored, even
>> though the SYN path saves local_id and computes the other two.
>>
>> subflow_ulp_clone() then reads those three fields and copies them into the
>> joined subflow context (local_id, request_bkup, thmac). Because the
>> request-sock slab is SLAB_TYPESAFE_BY_RCU and not zeroed on allocation, the
>> values are stale bytes of previously freed request sockets, which an
>> off-path peer can influence by sending concurrent MP_JOIN SYNs. A corrupted
>> local_id breaks id-based path-manager bookkeeping, and a corrupted
>> request_bkup misclassifies the subflow in the packet scheduler's
>> backup/active selection.
>>
>> Save and restore request_bkup and thmac as well, completing the state
>> restore.
>>
>> Fixes: 9466a1ccebbe ("mptcp: enable JOIN requests even if cookies are in use")
>> Cc: stable@vger.kernel.org
>> Assisted-by: opencode:deepseek-v4-flash
>> Signed-off-by: Harshit Varu <harshitvaru666@gmail.com>
>> ---
>> net/mptcp/syncookies.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/net/mptcp/syncookies.c b/net/mptcp/syncookies.c
>> index 7f2252634..3c25ff627 100644
>> --- a/net/mptcp/syncookies.c
>> +++ b/net/mptcp/syncookies.c
>> @@ -27,7 +27,9 @@ struct join_entry {
>> u8 join_id;
>> u8 local_id;
>> u8 backup;
>> + u8 request_bkup;
>> u8 valid;
>> + u64 thmac;
>
> Is thmac used for passive flows after
> mptcp_token_join_cookie_init_state()? I think it's not. If so just init
> to 0 in mptcp_token_join_cookie_init_state (with a comment) and remove
> remove the new field from here.
>
> Same for request_bkup, AFAICS both are used in syn_ack only.
>
> The bottom line is that we don't want to increase `struct join_entry`
> size without good reasons.
@Harshit: I agree with Paolo. So at the end, the v1 was good.
Can you please send a new version with what you had in the v1? Before
you do so, I have a few requests:
- Do not send a new version as a reply to another [1]
- Use 'PATCH net' [1]
- Wait 24h between submissions [1]
- Remove 'security@k.o' from Cc as it is sent to public MLs [2]
- Use ./scripts/get_maintainer.pl to cc the right people [3]
[1] https://docs.kernel.org/process/maintainer-netdev.html
[2] https://docs.kernel.org/process/submitting-patches.html
[3]
https://netdev-ctrl.bots.linux.dev/logs/build/1144354/14744385/cc_maintainers/desc
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-14 22:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 21:51 [PATCH mptcp] mptcp: fix uninitialized local_id in syncookie MP_JOIN reconstruction Harshit Varu
2026-08-11 22:23 ` [PATCH mptcp v2] mptcp: restore full join state " Harshit Varu
2026-08-12 9:10 ` Paolo Abeni
2026-08-14 22:56 ` Matthieu Baerts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox