From e5476f52dc2fdba76b5588198e91db5a59b6d73e Mon Sep 17 00:00:00 2001 From: kn Date: Wed, 30 Nov 2022 13:58:39 +0000 Subject: [PATCH] Use shared socket/net lock for IP sockets so{,un}lock_shared() take the shared net lock for PF_INET and PF_INET6 while sticking to the exclusive rwlock elsewhere. getsockopt(2), getsockname(2) and getpeername(2) (all UNLOCK) do not write, so the exclusive net lock is overkill here. OK mvs --- sys/kern/uipc_syscalls.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index ddb612a8043..900e6709ba2 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.204 2022/09/03 21:13:48 mbuhl Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.205 2022/11/30 13:58:39 kn Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -1268,9 +1268,9 @@ sys_getsockopt(struct proc *p, void *v, register_t *retval) valsize = 0; m = m_get(M_WAIT, MT_SOOPTS); so = fp->f_data; - solock(so); + solock_shared(so); error = sogetopt(so, SCARG(uap, level), SCARG(uap, name), m); - sounlock(so); + sounlock_shared(so); if (error == 0 && SCARG(uap, val) && valsize && m != NULL) { if (valsize > m->m_len) valsize = m->m_len; @@ -1320,9 +1320,9 @@ sys_getsockname(struct proc *p, void *v, register_t *retval) goto bad; } m = m_getclr(M_WAIT, MT_SONAME); - solock(so); + solock_shared(so); error = pru_sockaddr(so, m); - sounlock(so); + sounlock_shared(so); if (error) goto bad; error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); @@ -1367,9 +1367,9 @@ sys_getpeername(struct proc *p, void *v, register_t *retval) if (error) goto bad; m = m_getclr(M_WAIT, MT_SONAME); - solock(so); + solock_shared(so); error = pru_peeraddr(so, m); - sounlock(so); + sounlock_shared(so); if (error) goto bad; error = copyaddrout(p, m, SCARG(uap, asa), len, SCARG(uap, alen)); -- 2.20.1