提交 c5c79763 编写于 作者: P Paolo Abeni 提交者: David S. Miller

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: 79c0949e ("mptcp: Add key generation and token tree")
Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
Reviewed-by: NMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 10f6d46c
...@@ -1263,7 +1263,6 @@ static void mptcp_close(struct sock *sk, long timeout) ...@@ -1263,7 +1263,6 @@ static void mptcp_close(struct sock *sk, long timeout)
lock_sock(sk); lock_sock(sk);
mptcp_token_destroy(msk->token);
inet_sk_state_store(sk, TCP_CLOSE); inet_sk_state_store(sk, TCP_CLOSE);
/* be sure to always acquire the join list lock, to sync vs /* be sure to always acquire the join list lock, to sync vs
...@@ -1461,6 +1460,7 @@ static void mptcp_destroy(struct sock *sk) ...@@ -1461,6 +1460,7 @@ static void mptcp_destroy(struct sock *sk)
{ {
struct mptcp_sock *msk = mptcp_sk(sk); struct mptcp_sock *msk = mptcp_sk(sk);
mptcp_token_destroy(msk->token);
if (msk->cached_ext) if (msk->cached_ext)
__skb_ext_put(msk->cached_ext); __skb_ext_put(msk->cached_ext);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册