From owner-svn-src-head@freebsd.org Mon Jul 6 16:07:22 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ABA92A688; Mon, 6 Jul 2015 16:07:22 +0000 (UTC) (envelope-from pkelsey@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B6BF12F3; Mon, 6 Jul 2015 16:07:22 +0000 (UTC) (envelope-from pkelsey@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t66G7M6s037819; Mon, 6 Jul 2015 16:07:22 GMT (envelope-from pkelsey@FreeBSD.org) Received: (from pkelsey@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t66G7M72037818; Mon, 6 Jul 2015 16:07:22 GMT (envelope-from pkelsey@FreeBSD.org) Message-Id: <201507061607.t66G7M72037818@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pkelsey set sender to pkelsey@FreeBSD.org using -f From: Patrick Kelsey Date: Mon, 6 Jul 2015 16:07:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285208 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2015 16:07:22 -0000 Author: pkelsey Date: Mon Jul 6 16:07:21 2015 New Revision: 285208 URL: https://svnweb.freebsd.org/changeset/base/285208 Log: 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 Modified: head/sys/kern/kern_sysctl.c Modified: head/sys/kern/kern_sysctl.c ============================================================================== --- head/sys/kern/kern_sysctl.c Mon Jul 6 14:09:00 2015 (r285207) +++ head/sys/kern/kern_sysctl.c Mon Jul 6 16:07:21 2015 (r285208) @@ -1784,7 +1784,7 @@ userland_sysctl(struct thread *td, int * ktrsysctl(name, namelen); #endif - if (req.oldlen > PAGE_SIZE) { + if (req.oldptr && req.oldlen > PAGE_SIZE) { memlocked = 1; sx_xlock(&sysctlmemlock); } else