Date: Thu, 19 Oct 2017 01:38:31 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324736 - head/sys/kern Message-ID: <201710190138.v9J1cV4B058373@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 (;;) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710190138.v9J1cV4B058373>