NTP审计 - adjtimex系统调用失败?

时间:2017-01-05 09:33:17

标签: system-calls audit ntp system-administration ntpd

作为新PCI-DSS服务器部署的一部分,我正在配置完全可审计的NTP时间更改历史记录。一切都按预期工作,但我现在看到与时间变化操作有关的每秒写入的审计日志。经过大量的搜索,我仍然无法理解发生了什么。该问题在/ var / log / messages中显示,其中正在连续写入审计消息。

我的研究表明系统调用"退出= 5"消息表示时钟未正确同步:

adjtimex()系统调用响应" #define TIME_BAD 5 / *时钟未同步* /"。

因此,总而言之,似乎时钟正确同步(据我理解的情况而定),但它会不断变化 - 轮询间隔设置为默认64秒时出现意外行为。

有人能提供建议吗?我已经包含了尽可能详细的信息,如下所示:

审核时间规则:

[09:31] callum pci-fram-ipa1 ~ $ sudo cat /etc/audit/rules.d/audit_time_rules.rules
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time-change
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -k time-change
-a always,exit -F arch=b64 -S clock_settime -k time-change
-a always,exit -F arch=b32 -S clock_settime -k time-change
-w /etc/localtime -p wa -k time-change

系统时间与时钟时间:

[09:14] callum pci-fram-ipa1 ~ $ sudo clock;date
Thu 05 Jan 2017 09:14:01 GMT  -0.500708 seconds
Thu  5 Jan 09:14:01 GMT 2017

审计输出示例:

[09:15] callum pci-fram-ipa1 ~ $ sudo tail -f /var/log/messages|grep time
Jan  5 09:15:25 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607725.390:2328215): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:26 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607726.390:2328216): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:27 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607727.390:2328217): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:28 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607728.390:2328218): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:29 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607729.390:2328219): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:30 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607730.390:2328220): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:31 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607731.390:2328221): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:32 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607732.390:2328222): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:33 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607733.390:2328223): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"
Jan  5 09:15:34 pci-fram-ipa1 audispd: node=pci-fram-ipa1.x.net type=SYSCALL msg=audit(1483607734.390:2328224): arch=c000003e syscall=159 success=yes exit=5 a0=7ffe85ddc320 a1=7ffe85ddc410 a2=861 a3=2 items=0 ppid=1 pid=11479 auid=4294967295 uid=38 gid=38 euid=38 suid=38 fsuid=38 egid=38 sgid=38 fsgid=38 tty=(none) ses=4294967295 comm="ntpd" exe="/usr/sbin/ntpd" subj=system_u:system_r:ntpd_t:s0 key="time-change"

同步统计信息:

[09:15] callum pci-fram-ipa1 ~ $ sudo ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*neon.trippett.o 131.188.3.221    2 u  112  256  377   17.924   -0.704   0.252
+uno.alvm.me     193.79.237.14    2 u  196  256  377   19.737    0.505   0.436
+greenore.zeip.e 140.203.204.77   2 u  165  256  377   19.616    0.019   0.252
+devrandom.pl    87.124.126.49    3 u  124  256  377   19.675    0.371   0.572

其他信息:

[09:17] callum pci-fram-ipa1 ~ $ ntpdc -c sysinfo
system peer:          neon.trippett.org
system peer mode:     client
leap indicator:       00
stratum:              3
precision:            -23
root distance:        0.03258 s
root dispersion:      0.04211 s
reference ID:         [178.62.6.103]
reference time:       dc188cec.d9ea15c5  Thu, Jan  5 2017  9:14:20.851
system flags:         auth ntp stats
jitter:               0.000320 s
stability:            0.000 ppm
broadcastdelay:       0.000000 s
authdelay:            0.000000 s

1 个答案:

答案 0 :(得分:1)

听起来这可能是预期的行为,基于NTP歪曲时钟的频率

来自NTP documentation

<强> 5.1.3.2。系统时钟的更新频率是多久?

由于时间应该是一个连续而稳定的流,ntpd会少量更新时钟。但是,为了跟上时钟误差,必须经常应用这种校正。如果使用adjtime(),ntpd将更新系统时钟 TIME_ERROR The system clock is not synchronized to a reliable server. This value is returned when any of the following holds true: * Either STA_UNSYNC or STA_CLOCKERR is set. * STA_PPSSIGNAL is clear and either STA_PPSFREQ or STA_PPSTIME is set. * STA_PPSTIME and STA_PPSJITTER are both set. * STA_PPSFREQ is set and either STA_PPSWANDER or STA_PPSJITTER is set. The symbolic name TIME_BAD is a synonym for TIME_ERROR, provided for backward compatibility. (我知道这不是adjtimex,但adjtimex可以在ADJ_OFFSET_SINGLESHOT模式下作为adjtime运行:请参阅adjtimex手册页) 。如果ntp_adjtime()可用,操作系统可以自动补偿时钟错误,只需要不经常更新。另见第5.2节和Q:5.1.6.1 ..

轮询间隔与此无关。相反,上游(较低时间层)时间服务器经常被查询的频率是多少?&#34;供参考。

如果问题是您查看了审核条目,并且您不希望为ntp用户看到它们 - 并且您只想看到恶劣的时间偏差,请遵循建议来自this link,并排除ntp uid / auid。

此外,从adjtimex man page开始,您看到的TIME_BAD错误似乎并不意味着时间从未正确转换过:

http://wkpviana.net 
http://vianahosting.ir