From: mvs Date: Fri, 26 Jan 2024 18:24:23 +0000 (+0000) Subject: Unlock listen(2). `somaxconn_local' and `sominconn_local' used X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=adfdc7a52fc7d5ca602f95183be7a5f0c1ce2893;p=openbsd Unlock listen(2). `somaxconn_local' and `sominconn_local' used respectively to cache values as we do in other places. ok bluhm --- diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index c30a0f92e57..0400b8ea8d4 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.256 2023/12/21 19:34:07 miod Exp $ +; $OpenBSD: syscalls.master,v 1.257 2024/01/26 18:24:23 mvs Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -223,7 +223,7 @@ socklen_t namelen); } 105 STD NOLOCK { int sys_setsockopt(int s, int level, int name, \ const void *val, socklen_t valsize); } -106 STD { int sys_listen(int s, int backlog); } +106 STD NOLOCK { int sys_listen(int s, int backlog); } 107 STD { int sys_chflagsat(int fd, const char *path, \ u_int flags, int atflags); } 108 STD NOLOCK { int sys_pledge(const char *promises, \ diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 9da3bdd2040..41a6bd7045d 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.314 2024/01/12 10:48:03 bluhm Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.315 2024/01/26 18:24:23 mvs Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -226,6 +226,8 @@ sobind(struct socket *so, struct mbuf *nam, struct proc *p) int solisten(struct socket *so, int backlog) { + int somaxconn_local = READ_ONCE(somaxconn); + int sominconn_local = READ_ONCE(sominconn); int error; soassertlocked(so); @@ -241,10 +243,10 @@ solisten(struct socket *so, int backlog) return (error); if (TAILQ_FIRST(&so->so_q) == NULL) so->so_options |= SO_ACCEPTCONN; - if (backlog < 0 || backlog > somaxconn) - backlog = somaxconn; - if (backlog < sominconn) - backlog = sominconn; + if (backlog < 0 || backlog > somaxconn_local) + backlog = somaxconn_local; + if (backlog < sominconn_local) + backlog = sominconn_local; so->so_qlimit = backlog; return (0); }