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)
This commit is contained in:
Gunnar Beutner 2021-04-30 21:43:37 +02:00 committed by Andreas Kling
parent 866e577f1d
commit fb2ad94195

View file

@ -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)