Emit an audit record every time selected NTP parameters are modified from userspace (via adjtimex(2) or clock_adjtime(2)). These parameters may be used to indirectly change system clock, and thus their modifications should be audited. Such events will now generate records of type AUDIT_TIME_ADJNTPVAL containing the following fields: - op -- which value was adjusted: - offset -- corresponding to the time_offset variable - freq -- corresponding to the time_freq variable - status -- corresponding to the time_status variable - adjust -- corresponding to the time_adjust variable - tick -- corresponding to the tick_usec variable - tai -- corresponding to the timekeeping's TAI offset - old -- the old value - new -- the new value Example records: type=TIME_ADJNTPVAL msg=audit(1530616044.507:7): op=status old=64 new=8256 type=TIME_ADJNTPVAL msg=audit(1530616044.511:11): op=freq old=0 new=49180377088000 The records of this type will be associated with the corresponding syscall records. An overview of parameter changes that can be done via do_adjtimex() (based on information from Miroslav Lichvar) and whether they are audited: __timekeeping_set_tai_offset() -- sets the offset from the International Atomic Time (AUDITED) NTP variables: time_offset -- can adjust the clock by up to 0.5 seconds per call and also speed it up or slow down by up to about 0.05% (43 seconds per day) (AUDITED) time_freq -- can speed up or slow down by up to about 0.05% (AUDITED) time_status -- can insert/delete leap seconds and it also enables/ disables synchronization of the hardware real-time clock (AUDITED) time_maxerror, time_esterror -- change error estimates used to inform userspace applications (NOT AUDITED) time_constant -- controls the speed of the clock adjustments that are made when time_offset is set (NOT AUDITED) time_adjust -- can temporarily speed up or slow down the clock by up to 0.05% (AUDITED) tick_usec -- a more extreme version of time_freq; can speed up or slow down the clock by up to 10% (AUDITED)
Showing the changes to include/linux (1 of 6 files). Show all
Unified · Split
| @@ -86,6 +86,29 @@ struct audit_field { · 85 unmodified lines | |||
| 86 | u32 op; | 86 | u32 op; |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| 89 | enum audit_ntp_type { | ||
| 90 | AUDIT_NTP_OFFSET, | ||
| 91 | AUDIT_NTP_FREQ, | ||
| 92 | AUDIT_NTP_STATUS, | ||
| 93 | AUDIT_NTP_TAI, | ||
| 94 | AUDIT_NTP_TICK, | ||
| 95 | AUDIT_NTP_ADJUST, | ||
| 96 | |||
| 97 | AUDIT_NTP_NVALS /* count */ | ||
| 98 | }; | ||
| 99 | |||
| 100 | #ifdef CONFIG_AUDITSYSCALL | ||
| 101 | struct audit_ntp_val { | ||
| 102 | long long oldval, newval; | ||
| 103 | }; | ||
| 104 | |||
| 105 | struct audit_ntp_data { | ||
| 106 | struct audit_ntp_val vals[AUDIT_NTP_NVALS]; | ||
| 107 | }; | ||
| 108 | #else | ||
| 109 | struct audit_ntp_data {}; | ||
| 110 | #endif | ||
| 111 | |||
| 89 | extern int is_audit_feature_set(int which); | 112 | extern int is_audit_feature_set(int which); |
| 90 | 113 | ||
| 91 | extern int __init audit_register_class(int class, unsigned *list); | 114 | extern int __init audit_register_class(int class, unsigned *list); |
| @@ -366,6 +389,7 @@ extern void __audit_mmap_fd(int fd, int flags); · 274 unmodified lines | |||
| 366 | extern void __audit_log_kern_module(char *name); | 389 | extern void __audit_log_kern_module(char *name); |
| 367 | extern void __audit_fanotify(unsigned int response); | 390 | extern void __audit_fanotify(unsigned int response); |
| 368 | extern void __audit_tk_injoffset(struct timespec64 offset); | 391 | extern void __audit_tk_injoffset(struct timespec64 offset); |
| 392 | extern void __audit_ntp_log(const struct audit_ntp_data *ad); | ||
| 369 | 393 | ||
| 370 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) | 394 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) |
| 371 | { | 395 | { |
| @@ -478,6 +502,29 @@ static inline void audit_tk_injoffset(struct timespec64 offset) · 106 unmodified lines | |||
| 478 | __audit_tk_injoffset(offset); | 502 | __audit_tk_injoffset(offset); |
| 479 | } | 503 | } |
| 480 | 504 | ||
| 505 | static inline void audit_ntp_init(struct audit_ntp_data *ad) | ||
| 506 | { | ||
| 507 | memset(ad, 0, sizeof(*ad)); | ||
| 508 | } | ||
| 509 | |||
| 510 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, | ||
| 511 | enum audit_ntp_type type, long long val) | ||
| 512 | { | ||
| 513 | ad->vals[type].oldval = val; | ||
| 514 | } | ||
| 515 | |||
| 516 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, | ||
| 517 | enum audit_ntp_type type, long long val) | ||
| 518 | { | ||
| 519 | ad->vals[type].newval = val; | ||
| 520 | } | ||
| 521 | |||
| 522 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) | ||
| 523 | { | ||
| 524 | if (!audit_dummy_context()) | ||
| 525 | __audit_ntp_log(ad); | ||
| 526 | } | ||
| 527 | |||
| 481 | extern int audit_n_rules; | 528 | extern int audit_n_rules; |
| 482 | extern int audit_signals; | 529 | extern int audit_signals; |
| 483 | #else /* CONFIG_AUDITSYSCALL */ | 530 | #else /* CONFIG_AUDITSYSCALL */ |
| @@ -594,6 +641,20 @@ static inline void audit_fanotify(unsigned int response) · 110 unmodified lines | |||
| 594 | static inline void audit_tk_injoffset(struct timespec64 offset) | 641 | static inline void audit_tk_injoffset(struct timespec64 offset) |
| 595 | { } | 642 | { } |
| 596 | 643 | ||
| 644 | static inline void audit_ntp_init(struct audit_ntp_data *ad) | ||
| 645 | { } | ||
| 646 | |||
| 647 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, | ||
| 648 | enum audit_ntp_type type, long long val) | ||
| 649 | { } | ||
| 650 | |||
| 651 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, | ||
| 652 | enum audit_ntp_type type, long long val) | ||
| 653 | { } | ||
| 654 | |||
| 655 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) | ||
| 656 | { } | ||
| 657 | |||
| 597 | static inline void audit_ptrace(struct task_struct *t) | 658 | static inline void audit_ptrace(struct task_struct *t) |
| 598 | { } | 659 | { } |
| 599 | #define audit_n_rules 0 | 660 | #define audit_n_rules 0 |