Skip to content

Commit

Permalink
Kernel: Remove socket from the listener's accept list when it is closed
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
gunnarbeutner authored and awesomekling committed Apr 30, 2021
1 parent 866e577 commit fb2ad94
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Kernel/Net/TCPSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fb2ad94

Please sign in to comment.