svn commit: r352865 - in stable: 11 11/contrib/ntp/ntpd 11/etc 11/usr.sbin/ntp 12 12/contrib/ntp/ntpd 12/usr.sbin/ntp 12/usr.sbin/ntp/ntpd

Cy Schubert cy at FreeBSD.org
Sun Sep 29 03:36:52 UTC 2019


Author: cy
Date: Sun Sep 29 03:36:50 2019
New Revision: 352865
URL: https://svnweb.freebsd.org/changeset/base/352865

Log:
  MFC r352304, r352540
  
  r352304:
  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)
  Differential Revision:	https://reviews.freebsd.org/D21581
  
  r352540:
  Follow up on r352304 which disabled default mlockall() at startup.
  Unfortunately though the original tarball supports this in ./configure
  (for Linux), to fully support disabling of mlockall() by default requires
  a little extra help otherwise the following is logged in syslog:
  
  	Cannot set RLIMIT_MEMLOCK: Operation not permitted

Modified:
  stable/11/UPDATING
  stable/11/contrib/ntp/ntpd/ntpd.c
  stable/11/etc/ntp.conf
  stable/11/usr.sbin/ntp/config.h
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/UPDATING
  stable/12/contrib/ntp/ntpd/ntpd.c
  stable/12/usr.sbin/ntp/config.h
  stable/12/usr.sbin/ntp/ntpd/ntp.conf
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/UPDATING
==============================================================================
--- stable/11/UPDATING	Sun Sep 29 03:26:29 2019	(r352864)
+++ stable/11/UPDATING	Sun Sep 29 03:36:50 2019	(r352865)
@@ -16,6 +16,12 @@ from older versions of FreeBSD, try WITHOUT_CLANG and 
 the tip of head, and then rebuild without this option. The bootstrap process
 from older version of current across the gcc/clang cutover is a bit fragile.
 
+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.
+
 20190723:
 	Clang, llvm, lld, lldb, compiler-rt, libc++, libunwind and openmp have
 	been upgraded to 8.0.1.  Please see the 20141231 entry below for

Modified: stable/11/contrib/ntp/ntpd/ntpd.c
==============================================================================
--- stable/11/contrib/ntp/ntpd/ntpd.c	Sun Sep 29 03:26:29 2019	(r352864)
+++ stable/11/contrib/ntp/ntpd/ntpd.c	Sun Sep 29 03:36:50 2019	(r352865)
@@ -991,7 +991,7 @@ ntpdmain(
 # if defined(HAVE_MLOCKALL)
 #  ifdef HAVE_SETRLIMIT
 	ntp_rlimit(RLIMIT_STACK, DFLT_RLIMIT_STACK * 4096, 4096, "4k");
-#   ifdef RLIMIT_MEMLOCK
+#   if defined(RLIMIT_MEMLOCK) && defined(DFLT_RLIMIT_MEMLOCK) && DFLT_RLIMIT_MEMLOCK != -1
 	/*
 	 * The default RLIMIT_MEMLOCK is very low on Linux systems.
 	 * Unless we increase this limit malloc calls are likely to

Modified: stable/11/etc/ntp.conf
==============================================================================
--- stable/11/etc/ntp.conf	Sun Sep 29 03:26:29 2019	(r352864)
+++ stable/11/etc/ntp.conf	Sun Sep 29 03:36:50 2019	(r352865)
@@ -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

Modified: stable/11/usr.sbin/ntp/config.h
==============================================================================
--- stable/11/usr.sbin/ntp/config.h	Sun Sep 29 03:26:29 2019	(r352864)
+++ stable/11/usr.sbin/ntp/config.h	Sun Sep 29 03:36:50 2019	(r352865)
@@ -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


More information about the svn-src-all mailing list