Kernel: Fix unix socket recv from

If connection on unix socket was closed and other end tries to recvfrom,
the thread would enter a fucked up state where it held the socket's
spinlock when returning to userspace.
This commit is contained in:
Bananymous 2025-06-05 22:01:31 +03:00
parent cfeabc4580
commit 0f189d410e
1 changed files with 6 additions and 0 deletions

View File

@ -394,9 +394,15 @@ namespace Kernel
auto& connection_info = m_info.get<ConnectionInfo>();
bool expected = true;
if (connection_info.target_closed.compare_exchange(expected, false))
{
m_packet_lock.unlock(state);
return 0;
}
if (!connection_info.connection)
{
m_packet_lock.unlock(state);
return BAN::Error::from_errno(ENOTCONN);
}
}
m_packet_lock.unlock(state);