Changeset View
Standalone View
contrib/ntp/ntpd/ntpd.c
Context not available. | |||||
# include <seccomp.h> | # include <seccomp.h> | ||||
#endif /* LIBSECCOMP and KERN_SECCOMP */ | #endif /* LIBSECCOMP and KERN_SECCOMP */ | ||||
#ifdef __FreeBSD__ | |||||
kib: Why not `#ifdef __FreeBSD` ? | |||||
Done Inline ActionsFreeBSD is not defined by llvm or gcc. FreeBSD_cc_version is defined by our cc, without including any headers. It's portable and can be shared with our ntp upline, nwtime.org. cy: __FreeBSD is not defined by llvm or gcc. __FreeBSD_cc_version is defined by our cc, without… | |||||
Not Done Inline ActionsUmmm, FreeBSD is defined to be the major version of FreeBSD without needing a header. FreeBSD_version needs sys/param.h.... imp: Ummm, __FreeBSD is defined to be the major version of FreeBSD without needing a header. | |||||
Not Done Inline ActionsFreeBSD is defined, I should have said imp: __FreeBSD__ is defined, I should have said | |||||
#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 | #ifdef HAVE_DNSREGISTRATION | ||||
# include <dns_sd.h> | # include <dns_sd.h> | ||||
DNSServiceRef mdns; | DNSServiceRef mdns; | ||||
Context not available. | |||||
char *argv[] | char *argv[] | ||||
) | ) | ||||
{ | { | ||||
#ifdef __FreeBSD__ | |||||
Not Done Inline ActionsIs there a PR for this problem? I think this whole block needs a comment, something simple like /* Must disable STACKGAP on FreeBSD to avoid <whatever the problem was>. See PR NNNN. */ ian: Is there a PR for this problem? I think this whole block needs a comment, something simple… | |||||
{ | |||||
/* | |||||
* We Must disable ASLR stack gap on FreeBSD to avoid a | |||||
* segfault. See PR/241421 and PR/241960. | |||||
*/ | |||||
int aslr_var = PROC_STACKGAP_DISABLE; | |||||
Not Done Inline ActionsI suggest to disable stack gap instead of ASLR. Use PROC_STACKGAP_CTL with DISABLE when available. If not available, it is safe to assume that stackgap is not supported as well. kib: I suggest to disable stack gap instead of ASLR. Use PROC_STACKGAP_CTL with DISABLE when… | |||||
pid_t my_pid = getpid(); | |||||
procctl(P_PID, my_pid, PROC_STACKGAP_CTL, &aslr_var); | |||||
} | |||||
#endif | |||||
Not Done Inline ActionsAnd if __FreeBSD_cc_version is undefined, this code is ending with the error. kib: And if __FreeBSD_cc_version is undefined, this code is ending with the error. | |||||
return ntpdmain(argc, argv); | return ntpdmain(argc, argv); | ||||
Not Done Inline ActionsI suggest to silently ignore the error from procctl(2). The only real situation where it can occur is when PROC_STACKGAP_CTL is not supported, because the kernel we running on is too old. Then there is no harm from the error, and running the daemon instead of abruptly terminating is much better outcome. I might even go further with this suggestion and propose to do e.g. #ifdef __FreeBSD__ #include <sys/procctl.h> #ifndef PROC_STACKGAP_CTL #define PROC_STACKGAP_CTL 17 #define PROC_STACKGAP_DISABLE 0x0002 #endif ... So that even if we compile on the older system, we still can run on newer kernels. That said, we probably need to allocate a bit for stack gap in image flags. Unfortunately, the image flag editor is still not installed. kib: I suggest to silently ignore the error from procctl(2). The only real situation where it can… | |||||
} | } | ||||
#endif /* !SYS_WINNT */ | #endif /* !SYS_WINNT */ | ||||
Context not available. |
Why not #ifdef __FreeBSD ?