Skip to content

Commit c5c7976

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: remove msk from the token container at destruction time.
Currently we remote the msk from the token container only via mptcp_close(). The MPTCP master socket can be destroyed also via other paths (e.g. if not yet accepted, when shutting down the listener socket). When we hit the latter scenario, dangling msk references are left into the token container, leading to memory corruption and/or UaF. This change addresses the issue by moving the token removal into the msk destructor. Fixes: 79c0949 ("mptcp: Add key generation and token tree") Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 10f6d46 commit c5c7976

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/mptcp/protocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,6 @@ static void mptcp_close(struct sock *sk, long timeout)
12631263

12641264
lock_sock(sk);
12651265

1266-
mptcp_token_destroy(msk->token);
12671266
inet_sk_state_store(sk, TCP_CLOSE);
12681267

12691268
/* be sure to always acquire the join list lock, to sync vs
@@ -1461,6 +1460,7 @@ static void mptcp_destroy(struct sock *sk)
14611460
{
14621461
struct mptcp_sock *msk = mptcp_sk(sk);
14631462

1463+
mptcp_token_destroy(msk->token);
14641464
if (msk->cached_ext)
14651465
__skb_ext_put(msk->cached_ext);
14661466

0 commit comments

Comments
 (0)