Index: contrib/ntp/ntpd/ntpd.c =================================================================== --- contrib/ntp/ntpd/ntpd.c +++ contrib/ntp/ntpd/ntpd.c @@ -138,6 +138,10 @@ # include #endif /* LIBSECCOMP and KERN_SECCOMP */ +#ifdef __FreeBSD__ +#include +#endif + #ifdef HAVE_DNSREGISTRATION # include DNSServiceRef mdns; @@ -402,6 +406,23 @@ 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; + + pid_t my_pid = getpid(); + + aslr_var = PROC_STACKGAP_DISABLE; + if (procctl(P_PID, my_pid, PROC_STACKGAP_CTL, &aslr_var) != 0) { + msyslog(LOG_ERR,"procctl set aslr mode failed"); + exit(255); + } + } +#endif return ntpdmain(argc, argv); } #endif /* !SYS_WINNT */