Re: [PATCH net] mptcp: fix uninitialized local_id in syncookie MP_JOIN reconstruction

[email protected]
Newsgroups dev.linux.lists.mptcp
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The `request_bkup` bitfield in `mptcp_subflow_request_sock` is left uninitialized during syncookie MP_JOIN reconstruction, causing stale data to dictate the subflow backup state.
--

--- Patch [1]: [PATCH net] mptcp: fix uninitialized local_id in syncookie MP_JOIN reconstruction ---
commit ac471f0880c8ac59556dc5bd33e8a83b1849726c
Author: Harshit Varu <[email protected]>

mptcp: fix uninitialized local_id in syncookie MP_JOIN reconstruction

This commit restores the local_id field from the saved cookie entry when
rebuilding the request socket for an MP_JOIN 4th-ACK handled under SYN
cookies. This prevents the subflow from using stale slab memory as its
address-ID, protecting the path manager's bookkeeping.

> diff --git a/net/mptcp/syncookies.c b/net/mptcp/syncookies.c
> index 7f22526346a7e..b5cac57011221 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;

[Severity: High]
This is a pre-existing issue, but does this code also leave the request_bkup
bitfield uninitialized during syncookie reconstruction?

While this commit fixes local_id, the request_bkup bitfield in
mptcp_subflow_request_sock doesn't appear to be saved in
mptcp_join_store_state() or restored here.

Since the request_sock slab is SLAB_TYPESAFE_BY_RCU and memory isn't zeroed
on allocation, subflow_init_req() zeroes some adjacent bitfields but misses
request_bkup:

net/mptcp/subflow.c:subflow_init_req() {
    ...
    subflow_req->mp_capable = 0;
    subflow_req->mp_join = 0;
    subflow_req->csum_reqd = mptcp_is_checksum_enabled(sock_net(sk_listener));
    ...
}

When the final subflow context is cloned, it copies this uninitialized state
directly from the request socket:

net/mptcp/subflow.c:subflow_ulp_clone() {
    ...
    new_ctx->backup = subflow_req->backup;
    new_ctx->request_bkup = subflow_req->request_bkup;
    ...
}

Could this stale memory cause the MPTCP stack to erroneously treat primary
paths as backup paths (or vice versa)?

>  	subflow_req->token = e->token;
>  	subflow_req->msk = msk;
>  	spin_unlock_bh(&join_entry_locks[i]);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.