Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
mptcp: Don't leak request-sockets when socket-creation fails
Browse files Browse the repository at this point in the history
We may end up not creating the socket (E.g., if mptcp_create_master_sk()
fails). In that case we need to make sure that the request-socket is
properly cleaned up. Thus, call __reqsk_free() at the appropriate place
in tcp_get_cookies_sock()

Fixes: Zero-day bug
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit 5d7d27c)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit 5433d7f)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
cpaasch authored and matttbe committed Mar 1, 2022
1 parent ef76cf9 commit 4b2a245
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion net/ipv4/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,
goto listen_overflow;

ret = mptcp_check_req_master(sk, child, req, skb, 0, tsoff);
if (ret < 0)
if (ret < 0) {
__reqsk_free(req);
return NULL;
}

if (!ret)
return tcp_sk(child)->mpcb->master_sk;
Expand Down
1 change: 0 additions & 1 deletion net/mptcp/mptcp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,6 @@ int mptcp_check_req_master(struct sock *sk, struct sock *child,
* already been dropped in __mptcp_check_req_master().
*/
sock_put(child);
reqsk_put(req);
return -1;
}
}
Expand Down

0 comments on commit 4b2a245

Please sign in to comment.