diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-04-30 21:43:37 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-30 23:11:56 +0200 |
commit | fb2ad941958a63912c65c14eb9bb3ed2f79d9916 (patch) | |
tree | 94b508593b26ecff9e93fc59dcdd900ca1bfb5dd /Kernel/Net | |
parent | 866e577f1d62837b2c8a0ca8651b1e154292cc58 (diff) | |
download | serenity-fb2ad941958a63912c65c14eb9bb3ed2f79d9916.zip |
Kernel: Remove socket from the listener's accept list when it is closed
Without this patch we end up with sockets in the listener's accept
queue with state 'closed' when doing stealth SYN scans:
Client -> Server: SYN for port 22
Server -> Client: SYN/ACK
Client -> Server: RST (i.e. don't complete the TCP handshake)
Diffstat (limited to 'Kernel/Net')
-rw-r--r-- | Kernel/Net/TCPSocket.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 393d4ac53f..1964da40d3 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -40,6 +40,9 @@ void TCPSocket::set_state(State new_state) if (new_state == State::Closed) { Locker locker(closing_sockets().lock()); closing_sockets().resource().remove(tuple()); + + if (m_originator) + release_to_originator(); } if (previous_role != m_role || was_disconnected != protocol_is_disconnected()) @@ -114,6 +117,7 @@ void TCPSocket::release_to_originator() { VERIFY(!!m_originator); m_originator.strong_ref()->release_for_accept(this); + m_originator.clear(); } void TCPSocket::release_for_accept(RefPtr<TCPSocket> socket) |