svn commit: r324736 - head/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Thu Oct 19 01:38:32 UTC 2017
Author: mjg
Date: Thu Oct 19 01:38:31 2017
New Revision: 324736
URL: https://svnweb.freebsd.org/changeset/base/324736
Log:
sysctl: only take mem lock if oldlen is > 4 * PAGE_SIZE
The previous limit of just one page is hit by ps.
The entire mechanism should be reworked, if not whacked. It seems the intent
is to reduce kernel dos-ability - some handlers wire the amount of memory
passed here. Handlers should probably stop wiring in the first place or in
the worst case indicate they are doing so so that the check is done only if
necessary. It should also probably be a counter, not a lock.
MFC after: 1 week
Modified:
head/sys/kern/kern_sysctl.c
Modified: head/sys/kern/kern_sysctl.c
==============================================================================
--- head/sys/kern/kern_sysctl.c Thu Oct 19 00:46:15 2017 (r324735)
+++ head/sys/kern/kern_sysctl.c Thu Oct 19 01:38:31 2017 (r324736)
@@ -2109,12 +2109,11 @@ userland_sysctl(struct thread *td, int *name, u_int na
if (KTRPOINT(curthread, KTR_SYSCTL))
ktrsysctl(name, namelen);
#endif
-
- if (req.oldptr && req.oldlen > PAGE_SIZE) {
+ memlocked = 0;
+ if (req.oldptr && req.oldlen > 4 * PAGE_SIZE) {
memlocked = 1;
sx_xlock(&sysctlmemlock);
- } else
- memlocked = 0;
+ }
CURVNET_SET(TD_TO_VNET(td));
for (;;) {
More information about the svn-src-all
mailing list