# ntpd SIGSEGV on 13.0-p5



## cmoerz (Jan 7, 2022)

Has anybody gotten `ntpd` to correctly work on a recent fresh install? I'm on stock kernel, fully patched, `ntpdate` works but any variation of `ntpd` just segfaults:


```
root@svc1:~ # ntpd -I 10.10.0.89 -n -c /etc/ntp.conf 
 7 Jan 10:33:35 ntpd[22262]: ntpd 4.2.8p15-a (1): Starting
 7 Jan 10:33:35 ntpd[22262]: Command line: ntpd -I 10.10.0.89 -n -c /etc/ntp.conf
 7 Jan 10:33:35 ntpd[22262]: ----------------------------------------------------
 7 Jan 10:33:35 ntpd[22262]: ntp-4 is maintained by Network Time Foundation,
 7 Jan 10:33:35 ntpd[22262]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
 7 Jan 10:33:35 ntpd[22262]: corporation.  Support and training for ntp-4 are
 7 Jan 10:33:35 ntpd[22262]: available at https://www.nwtime.org/support
 7 Jan 10:33:35 ntpd[22262]: ----------------------------------------------------
Segmentation fault (core dumped)
root@svc1:~ # lldb --core ntpd.core /usr/sbin/ntpd
ntpd*    ntpdate* ntpdc*   
root@svc1:~ # lldb --core ntpd.core /usr/sbin/ntpd
(lldb) target create "/usr/sbin/ntpd" --core "ntpd.core"
Core file '/root/ntpd.core' (x86_64) was loaded.

(lldb) bt
* thread #1, name = 'ntpd', stop reason = signal SIGSEGV
  * frame #0: 0x00000008034d99e0
(lldb)
```

I'd appreciate any suggestions for troubleshooting. Obviously, the core dump doesn't help. The log justs says the same as the console:


```
Jan  7 10:33:35 svc1 ntpd[22262]: ntpd 4.2.8p15-a (1): Starting
Jan  7 10:33:35 svc1 ntpd[22262]: Command line: ntpd -I 10.10.0.89 -n -c /etc/ntp.conf
Jan  7 10:33:35 svc1 ntpd[22262]: ----------------------------------------------------
Jan  7 10:33:35 svc1 ntpd[22262]: ntp-4 is maintained by Network Time Foundation,
Jan  7 10:33:35 svc1 ntpd[22262]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
Jan  7 10:33:35 svc1 ntpd[22262]: corporation.  Support and training for ntp-4 are
Jan  7 10:33:35 svc1 ntpd[22262]: available at https://www.nwtime.org/support
Jan  7 10:33:35 svc1 ntpd[22262]: ----------------------------------------------------
Jan  7 10:33:35 svc1 kernel: pid 22262 (ntpd), jid 0, uid 0: exited on signal 11 (core dumped)
```


----------



## SirDice (Jan 7, 2022)

Try running it from the command line and add the `-d` and `-D` switches. That might provide some clues.


```
-d, --debug-level
             Increase debug verbosity level.  This option may appear an
             unlimited number of times.


     -D number, --set-debug-level=number
             Set the debug verbosity level.  This option may appear an
             unlimited number of times.  This option takes an integer number
             as its argument.
```


----------



## cmoerz (Jan 7, 2022)

Thanks, good point.

Unfortunately, not much more:

```
root@svc1:~ # ntpd -D 9 -n
 7 Jan 10:50:45 ntpd[44302]: ntpd 4.2.8p15-a (1): Starting
 7 Jan 10:50:45 ntpd[44302]: Command line: ntpd -D 9 -n
 7 Jan 10:50:45 ntpd[44302]: ----------------------------------------------------
 7 Jan 10:50:45 ntpd[44302]: ntp-4 is maintained by Network Time Foundation,
 7 Jan 10:50:45 ntpd[44302]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
 7 Jan 10:50:45 ntpd[44302]: corporation.  Support and training for ntp-4 are
 7 Jan 10:50:45 ntpd[44302]: available at https://www.nwtime.org/support
 7 Jan 10:50:45 ntpd[44302]: ----------------------------------------------------
Segmentation fault (core dumped)
```


----------



## rootbert (Jan 7, 2022)

do you have kern.elf64.aslr.enable=1 in your sysctl?


----------



## cmoerz (Jan 7, 2022)

Yes, that's it! You're the man, rootbert!
Thanks for saving the few hairs left on my head!


----------



## mer (Jan 7, 2022)

rootbert said:


> do you have kern.elf64.aslr.enable=1 in your sysctl?


That's not the default setting, is it?


----------



## cmoerz (Jan 7, 2022)

No, I enabled it, figuring it'll be better security. Did not consider it would break ntpd.
I've worked around for now with changing sysctl before and after starting ntpd. Hack'ish but it works.


----------



## rootbert (Jan 7, 2022)

then in /etc/rc.conf put `ntpd_prepend="/usr/bin/proccontrol -m aslr -s disable"`. My guess is that this workaround is not needed any more with FreeBSD14 when ASLR is enabled by default


----------

