git: 66c8e3fccf0c - main - socket: fix listen(2) on an already listening socket

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Thu, 30 Jun 2022 14:50:51 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=66c8e3fccf0c426865a917f7b1945558b12017e4

commit 66c8e3fccf0c426865a917f7b1945558b12017e4
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-06-30 14:50:29 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-06-30 14:50:29 +0000

    socket: fix listen(2) on an already listening socket
    
    Reviewed by:            markj
    Differential revision:  https://reviews.freebsd.org/D35669
    Fixes:                  141fe2dceeaeefaaffc2242c8652345a081e825a
---
 sys/kern/uipc_socket.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index ffaf5acdd05d..5063ae5a56e0 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -948,8 +948,9 @@ solisten_proto_check(struct socket *so)
 	mtx_lock(&so->so_rcv_mtx);
 
 	/* Interlock with soo_aio_queue(). */
-	if ((so->so_snd.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0 ||
-	   (so->so_rcv.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0) {
+	if (!SOLISTENING(so) &&
+	   ((so->so_snd.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0 ||
+	   (so->so_rcv.sb_flags & (SB_AIO | SB_AIO_RUNNING)) != 0)) {
 		solisten_proto_abort(so);
 		return (EINVAL);
 	}