Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sysctl.c
Show First 20 Lines • Show All 2,349 Lines • ▼ Show 20 Lines | if (error != 0) | ||||
return (error); | return (error); | ||||
if (uap->oldlenp != NULL) | if (uap->oldlenp != NULL) | ||||
error = copyout(&rv, uap->oldlenp, sizeof(rv)); | error = copyout(&rv, uap->oldlenp, sizeof(rv)); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* Some systems, in particular those without swap, do not benefit from a | |||||
* restriction on user page wiring. | |||||
*/ | |||||
static bool __read_mostly g_sysctl_do_memlock = true; | |||||
SYSCTL_BOOL(_kern, OID_AUTO, sysctl_memlock, CTLFLAG_RWTUN, | |||||
&g_sysctl_do_memlock, 0, "Limit user memory wired for sysctl requests"); | |||||
/* | |||||
* This is used from various compatibility syscalls too. That's why name | * This is used from various compatibility syscalls too. That's why name | ||||
* must be in kernel space. | * must be in kernel space. | ||||
*/ | */ | ||||
int | int | ||||
userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, | userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, | ||||
size_t *oldlenp, int inkernel, const void *new, size_t newlen, | size_t *oldlenp, int inkernel, const void *new, size_t newlen, | ||||
size_t *retval, int flags) | size_t *retval, int flags) | ||||
{ | { | ||||
Show All 26 Lines | userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, | ||||
req.newfunc = sysctl_new_user; | req.newfunc = sysctl_new_user; | ||||
req.lock = REQ_UNWIRED; | req.lock = REQ_UNWIRED; | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (KTRPOINT(curthread, KTR_SYSCTL)) | if (KTRPOINT(curthread, KTR_SYSCTL)) | ||||
ktrsysctl(name, namelen); | ktrsysctl(name, namelen); | ||||
#endif | #endif | ||||
memlocked = 0; | memlocked = 0; | ||||
if (req.oldptr && req.oldlen > 4 * PAGE_SIZE) { | if (req.oldptr != NULL && req.oldlen > 4 * PAGE_SIZE && | ||||
g_sysctl_do_memlock) { | |||||
error = sx_xlock_sig(&sysctlmemlock); | |||||
if (error) | |||||
return (error); | |||||
memlocked = 1; | memlocked = 1; | ||||
sx_xlock(&sysctlmemlock); | |||||
} | } | ||||
CURVNET_SET(TD_TO_VNET(td)); | CURVNET_SET(TD_TO_VNET(td)); | ||||
for (;;) { | for (;;) { | ||||
req.oldidx = 0; | req.oldidx = 0; | ||||
req.newidx = 0; | req.newidx = 0; | ||||
error = sysctl_root(0, name, namelen, &req); | error = sysctl_root(0, name, namelen, &req); | ||||
if (error != EAGAIN) | if (error != EAGAIN) | ||||
▲ Show 20 Lines • Show All 575 Lines • Show Last 20 Lines |