View | Details | Raw Unified | Return to bug 241421 | Differences between
and this patch

Collapse All | Expand All

(-)b/net/ntp/files/patch-ntpd_ntpd.c (-3 / +36 lines)
Lines 1-10 Link Here
1
--- ntpd/ntpd.c.orig	2019-02-20 09:21:44.000000000 -0800
1
--- ntpd/ntpd.c.orig	2019-02-20 09:21:44.000000000 -0800
2
+++ ntpd/ntpd.c	2019-09-20 12:11:54.469651000 -0700
2
+++ ntpd/ntpd.c	2019-10-24 19:21:44.229660000 -0700
3
@@ -999,7 +999,7 @@
3
@@ -137,6 +137,8 @@
4
 # include <sys/resource.h>
5
 # include <seccomp.h>
6
 #endif /* LIBSECCOMP and KERN_SECCOMP */
7
+#include <sys/types.h>
8
+#include <sys/sysctl.h>
9
 
10
 #ifdef HAVE_DNSREGISTRATION
11
 # include <dns_sd.h>
12
@@ -790,6 +792,13 @@
13
 	int		fd;
14
 	int		zero;
15
 # endif
16
+	int		aslr = 0;
17
+	int		aslr_len = sizeof(aslr);
18
+#ifdef __LP64__
19
+	char		*aslr_var = "kern.elf64.aslr.enable";
20
+#else
21
+	char		*aslr_var = "kern.elf32.aslr.enable";
22
+#endif
23
 
24
 # ifdef NEED_PTHREAD_WARMUP
25
 	my_pthread_warmup();
26
@@ -998,8 +1007,16 @@
27
 	/* Setup stack size in preparation for locking pages in memory. */
4
 # if defined(HAVE_MLOCKALL)
28
 # if defined(HAVE_MLOCKALL)
5
 #  ifdef HAVE_SETRLIMIT
29
 #  ifdef HAVE_SETRLIMIT
6
 	ntp_rlimit(RLIMIT_STACK, DFLT_RLIMIT_STACK * 4096, 4096, "4k");
30
-	ntp_rlimit(RLIMIT_STACK, DFLT_RLIMIT_STACK * 4096, 4096, "4k");
7
-#   ifdef RLIMIT_MEMLOCK
31
-#   ifdef RLIMIT_MEMLOCK
32
+	
33
+	if ((rc = sysctlbyname(aslr_var, &aslr, &aslr_len, NULL, 0)) != 0)
34
+		msyslog(LOG_ERR,
35
+			"sysctlbyname: %s: %s",
36
+			aslr_var,
37
+			strerror(rc));
38
+
39
+	if (aslr == 0)
40
+		ntp_rlimit(RLIMIT_STACK, DFLT_RLIMIT_STACK * 4096, 4096, "4k");
8
+#   if defined(RLIMIT_MEMLOCK) && defined(DFLT_RLIMIT_MEMLOCK) && DFLT_RLIMIT_MEMLOCK != -1
41
+#   if defined(RLIMIT_MEMLOCK) && defined(DFLT_RLIMIT_MEMLOCK) && DFLT_RLIMIT_MEMLOCK != -1
9
 	/*
42
 	/*
10
 	 * The default RLIMIT_MEMLOCK is very low on Linux systems.
43
 	 * The default RLIMIT_MEMLOCK is very low on Linux systems.

Return to bug 241421