From owner-svn-src-head@freebsd.org  Fri Sep 13 20:20:06 2019
Return-Path: <owner-svn-src-head@freebsd.org>
Delivered-To: svn-src-head@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id DD9D0D23A1;
 Fri, 13 Sep 2019 20:20:06 +0000 (UTC) (envelope-from cy@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org
 [IPv6:2610:1c1:1:606c::19:3])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 46VRny5ZFkz44n7;
 Fri, 13 Sep 2019 20:20:06 +0000 (UTC) (envelope-from cy@FreeBSD.org)
Received: from repo.freebsd.org (repo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A2ADECAEF;
 Fri, 13 Sep 2019 20:20:06 +0000 (UTC) (envelope-from cy@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x8DKK6oA025068;
 Fri, 13 Sep 2019 20:20:06 GMT (envelope-from cy@FreeBSD.org)
Received: (from cy@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8DKK62j025066;
 Fri, 13 Sep 2019 20:20:06 GMT (envelope-from cy@FreeBSD.org)
Message-Id: <201909132020.x8DKK62j025066@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org
 using -f
From: Cy Schubert <cy@FreeBSD.org>
Date: Fri, 13 Sep 2019 20:20:06 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r352304 - in head: . usr.sbin/ntp usr.sbin/ntp/ntpd
X-SVN-Group: head
X-SVN-Commit-Author: cy
X-SVN-Commit-Paths: in head: . usr.sbin/ntp usr.sbin/ntp/ntpd
X-SVN-Commit-Revision: 352304
X-SVN-Commit-Repository: base
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.29
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 13 Sep 2019 20:20:06 -0000

Author: cy
Date: Fri Sep 13 20:20:05 2019
New Revision: 352304
URL: https://svnweb.freebsd.org/changeset/base/352304

Log:
  No longer mlock() ntpd pages by default in memory thus allowing its
  pages to page as necessary.
  
  To restore historic BSD behaviour add the following to ntp.conf:
  	rlimit memlock 32
  
  Discussed on:	freebsd-current@ between Sept 6-9, 2019
  Reported by:	Users using ASLR with stack gap != 0
  Reviewed by:	ian, kib, rgrimes (all previous versions)
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D21581

Modified:
  head/UPDATING
  head/usr.sbin/ntp/config.h
  head/usr.sbin/ntp/ntpd/ntp.conf

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Fri Sep 13 20:17:14 2019	(r352303)
+++ head/UPDATING	Fri Sep 13 20:20:05 2019	(r352304)
@@ -26,6 +26,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
 	disable the most expensive debugging functionality run
 	"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20190913:
+	ntpd no longer by default locks its pages in memory, allowing them
+	to be paged out by the kernel. Use rlimit memlock to restore
+	historic BSD behaviour. For example, add "rlimit memlock 32"
+	to ntp.conf to lock up to 32 MB of ntpd address space in memory.
+
 20190823:
 	Several of ping6's options have been renamed for better consistency
 	with ping.  If you use any of -ARWXaghmrtwx, you must update your

Modified: head/usr.sbin/ntp/config.h
==============================================================================
--- head/usr.sbin/ntp/config.h	Fri Sep 13 20:17:14 2019	(r352303)
+++ head/usr.sbin/ntp/config.h	Fri Sep 13 20:20:05 2019	(r352304)
@@ -287,7 +287,7 @@
 #define DEFAULT_HZ 100
 
 /* Default number of megabytes for RLIMIT_MEMLOCK */
-#define DFLT_RLIMIT_MEMLOCK 32
+#define DFLT_RLIMIT_MEMLOCK -1
 
 /* Default number of 4k pages for RLIMIT_STACK */
 #define DFLT_RLIMIT_STACK 50

Modified: head/usr.sbin/ntp/ntpd/ntp.conf
==============================================================================
--- head/usr.sbin/ntp/ntpd/ntp.conf	Fri Sep 13 20:17:14 2019	(r352303)
+++ head/usr.sbin/ntp/ntpd/ntp.conf	Fri Sep 13 20:20:05 2019	(r352304)
@@ -102,3 +102,11 @@ restrict ::1
 # Use either leapfile in /etc/ntp or periodically updated leapfile in /var/db.
 #leapfile "/etc/ntp/leap-seconds"
 leapfile "/var/db/ntpd.leap-seconds.list"
+
+# Specify the number of megabytes of memory that should be allocated and
+# locked. -1 (default) means "do not lock the process into memory".
+# 0 means "lock whatever memory the process wants into memory". Any other
+# number means to lock up to that number of megabytes into memory.
+# 0 may result in a segfault when ASLR with stack gap randomization
+# is enabled.
+#rlimit memlock 32