aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorPatrick Kelsey <pkelsey@FreeBSD.org>2015-07-06 16:07:21 +0000
committerPatrick Kelsey <pkelsey@FreeBSD.org>2015-07-06 16:07:21 +0000
commit6f99ea0520fb840822fe73d30f6f4e9b47c4db1b (patch)
tree103bfed2868f7ce74712bf15176a71bbb09cc159 /sys/kern/kern_sysctl.c
parent9889bbac2329dbd8e20de5a4932503c1a36645fa (diff)
downloadsrc-6f99ea0520fb840822fe73d30f6f4e9b47c4db1b.tar.gz
src-6f99ea0520fb840822fe73d30f6f4e9b47c4db1b.zip
Don't acquire sysctlmemlock in userland_sysctl() when the old value
pointer is NULL, as in that case there are no userland pages that could potentially be wired. It is common for old to be NULL and oldlenp to be non-NULL in calls to userland_sysctl(), as this is used to probe for the length of a variable-length sysctl entry before retrieving a value. Note that it is typical for such calls to be made with an uninitialized value in *oldlenp, so sysctlmemlock was essentially being acquired at random (depending on the uninitialized value in *oldlenp being > PAGE_SIZE or not) for these calls prior to this patch. Differential Revision: https://reviews.freebsd.org/D2987 Reviewed by: mjg, kib Approved by: jmallett (mentor) MFC after: 1 month
Notes
Notes: svn path=/head/; revision=285208
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index c09f5f393b45..52075e47045d 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1784,7 +1784,7 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
ktrsysctl(name, namelen);
#endif
- if (req.oldlen > PAGE_SIZE) {
+ if (req.oldptr && req.oldlen > PAGE_SIZE) {
memlocked = 1;
sx_xlock(&sysctlmemlock);
} else