git: 8dc43f07dc66 - main - net/ntp: Reverse "Disable ntpd stack gap"

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Sat, 16 Oct 2021 03:59:19 UTC
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8dc43f07dc662e4e7404b5521ba03c2e7f25470a

commit 8dc43f07dc662e4e7404b5521ba03c2e7f25470a
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2021-10-16 03:50:11 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2021-10-16 03:59:14 +0000

    net/ntp: Reverse "Disable ntpd stack gap"
    
    120137c822c9697c19cf94461f436f8ccc372d24 (svn r517694) disabled ntpd
    ASLR stack gap, which caused ntpd to segfault. (The patch in
    120137c822c9697c19cf94461f436f8ccc372d24 was subsequently submitted
    to nwtime.org for inclusion into upstream ntp.) src commit
    889b56c8cd84c9a9f2d9e3b019c154d6f14d9021 addressed the underlying cause
    for the setrlimit segfault negating the need for this workaround. This
    commit removes the workaround.
    
    MFH:            2021Q4 (after a month)
---
 net/ntp/Makefile                |  1 +
 net/ntp/files/patch-ntpd_ntpd.c | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/net/ntp/Makefile b/net/ntp/Makefile
index caa8182f152f..35feccc13198 100644
--- a/net/ntp/Makefile
+++ b/net/ntp/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	ntp
 PORTVERSION=	4.2.8p15
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ \
 		http://archive.ntp.org/ntp4/ntp-4.2/ \
diff --git a/net/ntp/files/patch-ntpd_ntpd.c b/net/ntp/files/patch-ntpd_ntpd.c
new file mode 100644
index 000000000000..f6ab38ffc4f2
--- /dev/null
+++ b/net/ntp/files/patch-ntpd_ntpd.c
@@ -0,0 +1,39 @@
+--- ntpd/ntpd.c.orig	2020-06-23 02:17:48.000000000 -0700
++++ ntpd/ntpd.c	2021-10-15 19:52:05.945063000 -0700
+@@ -145,17 +145,6 @@
+ # include <seccomp.h>
+ #endif /* LIBSECCOMP and KERN_SECCOMP */
+ 
+-#ifdef __FreeBSD__
+-#include <sys/procctl.h>
+-#ifndef PROC_STACKGAP_CTL
+-/*
+- * Even if we compile on an older system we can still run on a newer one.
+- */
+-#define	PROC_STACKGAP_CTL	17
+-#define	PROC_STACKGAP_DISABLE	0x0002
+-#endif
+-#endif
+-
+ #ifdef HAVE_DNSREGISTRATION
+ # include <dns_sd.h>
+ DNSServiceRef mdns;
+@@ -438,18 +427,6 @@
+ 	char *argv[]
+ 	)
+ {
+-#   ifdef __FreeBSD__
+-	{
+-		/*
+-		 * We Must disable ASLR stack gap on FreeBSD to avoid a
+-		 * segfault. See PR/241421 and PR/241960.
+-		 */
+-		int aslr_var = PROC_STACKGAP_DISABLE;
+-
+-		pid_t my_pid = getpid();
+-		procctl(P_PID, my_pid, PROC_STACKGAP_CTL, &aslr_var); 
+-	}
+-#   endif
+ 	return ntpdmain(argc, argv);
+ }
+ #endif /* !SYS_WINNT */