History

ntp: Audit NTP parameters adjustment

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)

Ondrej Mosnacek committed 7 years ago

Commit 7e8eda71 parent 2d87a066 files · +112 −5Browse files

Showing the changes to include/linux (1 of 6 files). Show all

Unified · Split

include/linux/audit.h+61−0
@@ -86,6 +86,29 @@ struct audit_field { · 85 unmodified lines
86 u32 op;86 u32 op;
87};87};
88 88
89enum 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
101struct audit_ntp_val {
102 long long oldval, newval;
103};
104
105struct audit_ntp_data {
106 struct audit_ntp_val vals[AUDIT_NTP_NVALS];
107};
108#else
109struct audit_ntp_data {};
110#endif
111
89extern int is_audit_feature_set(int which);112extern int is_audit_feature_set(int which);
90 113
91extern int __init audit_register_class(int class, unsigned *list);114extern 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
366extern void __audit_log_kern_module(char *name);389extern void __audit_log_kern_module(char *name);
367extern void __audit_fanotify(unsigned int response);390extern void __audit_fanotify(unsigned int response);
368extern void __audit_tk_injoffset(struct timespec64 offset);391extern void __audit_tk_injoffset(struct timespec64 offset);
392extern void __audit_ntp_log(const struct audit_ntp_data *ad);
369 393
370static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)394static 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
505static inline void audit_ntp_init(struct audit_ntp_data *ad)
506{
507 memset(ad, 0, sizeof(*ad));
508}
509
510static 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
516static 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
522static inline void audit_ntp_log(const struct audit_ntp_data *ad)
523{
524 if (!audit_dummy_context())
525 __audit_ntp_log(ad);
526}
527
481extern int audit_n_rules;528extern int audit_n_rules;
482extern int audit_signals;529extern 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
594static inline void audit_tk_injoffset(struct timespec64 offset)641static inline void audit_tk_injoffset(struct timespec64 offset)
595{ }642{ }
596 643
644static inline void audit_ntp_init(struct audit_ntp_data *ad)
645{ }
646
647static inline void audit_ntp_set_old(struct audit_ntp_data *ad,
648 enum audit_ntp_type type, long long val)
649{ }
650
651static inline void audit_ntp_set_new(struct audit_ntp_data *ad,
652 enum audit_ntp_type type, long long val)
653{ }
654
655static inline void audit_ntp_log(const struct audit_ntp_data *ad)
656{ }
657
597static inline void audit_ptrace(struct task_struct *t)658static inline void audit_ptrace(struct task_struct *t)
598{ }659{ }
599#define audit_n_rules 0660#define audit_n_rules 0

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t