-/* $OpenBSD: kern_sysctl.c,v 1.411 2023/01/22 12:05:44 mvs Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.412 2023/05/04 09:40:36 mvs Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
syscallarg(void *) new;
syscallarg(size_t) newlen;
} */ *uap = v;
- int error, dolock = 1;
+ int error, dokernellock = 1, dolock = 1;
size_t savelen = 0, oldlen = 0;
sysctlfn *fn;
int name[CTL_MAXNAME];
break;
case CTL_NET:
fn = net_sysctl;
+ dokernellock = 0;
break;
case CTL_FS:
fn = fs_sysctl;
if (SCARG(uap, oldlenp) &&
(error = copyin(SCARG(uap, oldlenp), &oldlen, sizeof(oldlen))))
return (error);
+ if (dokernellock)
+ KERNEL_LOCK();
if (SCARG(uap, old) != NULL) {
if ((error = rw_enter(&sysctl_lock, RW_WRITE|RW_INTR)) != 0)
- return (error);
+ goto unlock;
if (dolock) {
if (atop(oldlen) > uvmexp.wiredmax - uvmexp.wired) {
rw_exit_write(&sysctl_lock);
- return (ENOMEM);
+ error = ENOMEM;
+ goto unlock;
}
error = uvm_vslock(p, SCARG(uap, old), oldlen,
PROT_READ | PROT_WRITE);
if (error) {
rw_exit_write(&sysctl_lock);
- return (error);
+ goto unlock;
}
}
savelen = oldlen;
uvm_vsunlock(p, SCARG(uap, old), savelen);
rw_exit_write(&sysctl_lock);
}
+unlock:
+ if (dokernellock)
+ KERNEL_UNLOCK();
if (error)
return (error);
if (SCARG(uap, oldlenp))
-; $OpenBSD: syscalls.master,v 1.246 2023/02/25 09:55:46 mvs Exp $
+; $OpenBSD: syscalls.master,v 1.247 2023/05/04 09:40:36 mvs Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
199 OBSOL pad_lseek
200 OBSOL pad_truncate
201 OBSOL pad_ftruncate
-202 STD { int sys_sysctl(const int *name, u_int namelen, \
+202 STD NOLOCK { int sys_sysctl(const int *name, u_int namelen, \
void *old, size_t *oldlenp, void *new, \
size_t newlen); }
203 STD { int sys_mlock(const void *addr, size_t len); }
-/* $OpenBSD: uipc_domain.c,v 1.60 2022/08/14 01:58:28 jsg Exp $ */
+/* $OpenBSD: uipc_domain.c,v 1.61 2023/05/04 09:40:36 mvs Exp $ */
/* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
/*
newp, newlen));
#endif
#if NPFLOW > 0
- if (family == PF_PFLOW)
- return (pflow_sysctl(name + 1, namelen - 1, oldp, oldlenp,
- newp, newlen));
+ if (family == PF_PFLOW) {
+ KERNEL_LOCK();
+ error = pflow_sysctl(name + 1, namelen - 1, oldp, oldlenp,
+ newp, newlen);
+ KERNEL_UNLOCK();
+ return (error);
+ }
#endif
#ifdef PIPEX
if (family == PF_PIPEX)
newp, newlen));
#endif
#ifdef MPLS
- if (family == PF_MPLS)
- return (mpls_sysctl(name + 1, namelen - 1, oldp, oldlenp,
- newp, newlen));
+ if (family == PF_MPLS) {
+ KERNEL_LOCK();
+ error = mpls_sysctl(name + 1, namelen - 1, oldp, oldlenp,
+ newp, newlen);
+ KERNEL_UNLOCK();
+ return (error);
+ }
#endif
dp = pffinddomain(family);
if (dp == NULL)
protocol = name[1];
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_protocol == protocol && pr->pr_sysctl) {
+ KERNEL_LOCK();
error = (*pr->pr_sysctl)(name + 2, namelen - 2,
oldp, oldlenp, newp, newlen);
+ KERNEL_UNLOCK();
return (error);
}
return (ENOPROTOOPT);