From 5590a8194beefd13d2b5a4d6b81899294a4944df Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 4 Aug 2023 12:59:15 -0400 Subject: [PATCH] network/protocols/unix: Recheck fShutdown{Read|Write} before socket notify. They may have changed, and we must not use the socket object if they are set. Related to #18535. --- .../kernel/network/protocols/unix/UnixDatagramEndpoint.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp b/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp index fedc5eb10f..8a0fb61e1e 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/unix/UnixDatagramEndpoint.cpp @@ -288,14 +288,16 @@ UnixDatagramEndpoint::Send(const iovec* vecs, size_t vecCount, fifoLocker.Unlock(); targetLocker.Lock(); - if (notifyRead) + // We must recheck fShutdownRead after reacquiring the lock, as it may have changed. + if (notifyRead && !targetEndpoint->fShutdownRead) gSocketModule->notify(targetEndpoint->socket, B_SELECT_READ, readable); targetLocker.Unlock(); if (notifyWrite) { endpointLocker.Lock(); - gSocketModule->notify(socket, B_SELECT_WRITE, writable); + if (!fShutdownWrite) + gSocketModule->notify(socket, B_SELECT_WRITE, writable); } switch (result) {