| .. | .. | 
|---|
| 17 | 17 |  #include <linux/mm.h> | 
|---|
| 18 | 18 |  #include <linux/module.h> | 
|---|
| 19 | 19 |  #include <linux/rtc.h> | 
|---|
| 20 |  | -#include <linux/math64.h>  | 
|---|
 | 20 | +#include <linux/audit.h>  | 
|---|
| 21 | 21 |   | 
|---|
| 22 | 22 |  #include "ntp_internal.h" | 
|---|
| 23 | 23 |  #include "timekeeping_internal.h" | 
|---|
| .. | .. | 
|---|
| 190 | 190 |  			&& (status & (STA_PPSWANDER|STA_PPSERROR))); | 
|---|
| 191 | 191 |  } | 
|---|
| 192 | 192 |   | 
|---|
| 193 |  | -static inline void pps_fill_timex(struct timex *txc)  | 
|---|
 | 193 | +static inline void pps_fill_timex(struct __kernel_timex *txc)  | 
|---|
| 194 | 194 |  { | 
|---|
| 195 | 195 |  	txc->ppsfreq	   = shift_right((pps_freq >> PPM_SCALE_INV_SHIFT) * | 
|---|
| 196 | 196 |  					 PPM_SCALE_INV, NTP_SCALE_SHIFT); | 
|---|
| 197 | 197 |  	txc->jitter	   = pps_jitter; | 
|---|
| 198 | 198 |  	if (!(time_status & STA_NANO)) | 
|---|
| 199 |  | -		txc->jitter /= NSEC_PER_USEC;  | 
|---|
 | 199 | +		txc->jitter = pps_jitter / NSEC_PER_USEC;  | 
|---|
| 200 | 200 |  	txc->shift	   = pps_shift; | 
|---|
| 201 | 201 |  	txc->stabil	   = pps_stabil; | 
|---|
| 202 | 202 |  	txc->jitcnt	   = pps_jitcnt; | 
|---|
| .. | .. | 
|---|
| 222 | 222 |  	return status & (STA_UNSYNC|STA_CLOCKERR); | 
|---|
| 223 | 223 |  } | 
|---|
| 224 | 224 |   | 
|---|
| 225 |  | -static inline void pps_fill_timex(struct timex *txc)  | 
|---|
 | 225 | +static inline void pps_fill_timex(struct __kernel_timex *txc)  | 
|---|
| 226 | 226 |  { | 
|---|
| 227 | 227 |  	/* PPS is not implemented, so these are zero */ | 
|---|
| 228 | 228 |  	txc->ppsfreq	   = 0; | 
|---|
| .. | .. | 
|---|
| 556 | 556 |  } | 
|---|
| 557 | 557 |   | 
|---|
| 558 | 558 |  #ifdef CONFIG_GENERIC_CMOS_UPDATE | 
|---|
| 559 |  | -int __weak update_persistent_clock(struct timespec now)  | 
|---|
| 560 |  | -{  | 
|---|
| 561 |  | -	return -ENODEV;  | 
|---|
| 562 |  | -}  | 
|---|
| 563 |  | -  | 
|---|
| 564 | 559 |  int __weak update_persistent_clock64(struct timespec64 now64) | 
|---|
| 565 | 560 |  { | 
|---|
| 566 |  | -	struct timespec now;  | 
|---|
| 567 |  | -  | 
|---|
| 568 |  | -	now = timespec64_to_timespec(now64);  | 
|---|
| 569 |  | -	return update_persistent_clock(now);  | 
|---|
 | 561 | +	return -ENODEV;  | 
|---|
| 570 | 562 |  } | 
|---|
| 571 | 563 |  #endif | 
|---|
| 572 | 564 |   | 
|---|
| .. | .. | 
|---|
| 643 | 635 |  /* | 
|---|
| 644 | 636 |   * Propagate a new txc->status value into the NTP state: | 
|---|
| 645 | 637 |   */ | 
|---|
| 646 |  | -static inline void process_adj_status(const struct timex *txc)  | 
|---|
 | 638 | +static inline void process_adj_status(const struct __kernel_timex *txc)  | 
|---|
| 647 | 639 |  { | 
|---|
| 648 | 640 |  	if ((time_status & STA_PLL) && !(txc->status & STA_PLL)) { | 
|---|
| 649 | 641 |  		time_state = TIME_OK; | 
|---|
| .. | .. | 
|---|
| 666 | 658 |  } | 
|---|
| 667 | 659 |   | 
|---|
| 668 | 660 |   | 
|---|
| 669 |  | -static inline void process_adjtimex_modes(const struct timex *txc, s32 *time_tai)  | 
|---|
 | 661 | +static inline void process_adjtimex_modes(const struct __kernel_timex *txc,  | 
|---|
 | 662 | +					  s32 *time_tai)  | 
|---|
| 670 | 663 |  { | 
|---|
| 671 | 664 |  	if (txc->modes & ADJ_STATUS) | 
|---|
| 672 | 665 |  		process_adj_status(txc); | 
|---|
| .. | .. | 
|---|
| 718 | 711 |   * adjtimex mainly allows reading (and writing, if superuser) of | 
|---|
| 719 | 712 |   * kernel time-keeping variables. used by xntpd. | 
|---|
| 720 | 713 |   */ | 
|---|
| 721 |  | -int __do_adjtimex(struct timex *txc, const struct timespec64 *ts, s32 *time_tai)  | 
|---|
 | 714 | +int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts,  | 
|---|
 | 715 | +		  s32 *time_tai, struct audit_ntp_data *ad)  | 
|---|
| 722 | 716 |  { | 
|---|
| 723 | 717 |  	int result; | 
|---|
| 724 | 718 |   | 
|---|
| .. | .. | 
|---|
| 729 | 723 |  			/* adjtime() is independent from ntp_adjtime() */ | 
|---|
| 730 | 724 |  			time_adjust = txc->offset; | 
|---|
| 731 | 725 |  			ntp_update_frequency(); | 
|---|
 | 726 | +  | 
|---|
 | 727 | +			audit_ntp_set_old(ad, AUDIT_NTP_ADJUST,	save_adjust);  | 
|---|
 | 728 | +			audit_ntp_set_new(ad, AUDIT_NTP_ADJUST,	time_adjust);  | 
|---|
| 732 | 729 |  		} | 
|---|
| 733 | 730 |  		txc->offset = save_adjust; | 
|---|
| 734 | 731 |  	} else { | 
|---|
| 735 |  | -  | 
|---|
| 736 | 732 |  		/* If there are input parameters, then process them: */ | 
|---|
| 737 |  | -		if (txc->modes)  | 
|---|
 | 733 | +		if (txc->modes) {  | 
|---|
 | 734 | +			audit_ntp_set_old(ad, AUDIT_NTP_OFFSET,	time_offset);  | 
|---|
 | 735 | +			audit_ntp_set_old(ad, AUDIT_NTP_FREQ,	time_freq);  | 
|---|
 | 736 | +			audit_ntp_set_old(ad, AUDIT_NTP_STATUS,	time_status);  | 
|---|
 | 737 | +			audit_ntp_set_old(ad, AUDIT_NTP_TAI,	*time_tai);  | 
|---|
 | 738 | +			audit_ntp_set_old(ad, AUDIT_NTP_TICK,	tick_usec);  | 
|---|
 | 739 | +  | 
|---|
| 738 | 740 |  			process_adjtimex_modes(txc, time_tai); | 
|---|
 | 741 | +  | 
|---|
 | 742 | +			audit_ntp_set_new(ad, AUDIT_NTP_OFFSET,	time_offset);  | 
|---|
 | 743 | +			audit_ntp_set_new(ad, AUDIT_NTP_FREQ,	time_freq);  | 
|---|
 | 744 | +			audit_ntp_set_new(ad, AUDIT_NTP_STATUS,	time_status);  | 
|---|
 | 745 | +			audit_ntp_set_new(ad, AUDIT_NTP_TAI,	*time_tai);  | 
|---|
 | 746 | +			audit_ntp_set_new(ad, AUDIT_NTP_TICK,	tick_usec);  | 
|---|
 | 747 | +		}  | 
|---|
| 739 | 748 |   | 
|---|
| 740 | 749 |  		txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, | 
|---|
| 741 | 750 |  				  NTP_SCALE_SHIFT); | 
|---|
| 742 | 751 |  		if (!(time_status & STA_NANO)) | 
|---|
| 743 |  | -			txc->offset /= NSEC_PER_USEC;  | 
|---|
 | 752 | +			txc->offset = (u32)txc->offset / NSEC_PER_USEC;  | 
|---|
| 744 | 753 |  	} | 
|---|
| 745 | 754 |   | 
|---|
| 746 | 755 |  	result = time_state;	/* mostly `TIME_OK' */ | 
|---|
| .. | .. | 
|---|
| 762 | 771 |  	/* fill PPS status fields */ | 
|---|
| 763 | 772 |  	pps_fill_timex(txc); | 
|---|
| 764 | 773 |   | 
|---|
| 765 |  | -	txc->time.tv_sec = (time_t)ts->tv_sec;  | 
|---|
 | 774 | +	txc->time.tv_sec = ts->tv_sec;  | 
|---|
| 766 | 775 |  	txc->time.tv_usec = ts->tv_nsec; | 
|---|
| 767 | 776 |  	if (!(time_status & STA_NANO)) | 
|---|
| 768 |  | -		txc->time.tv_usec /= NSEC_PER_USEC;  | 
|---|
 | 777 | +		txc->time.tv_usec = ts->tv_nsec / NSEC_PER_USEC;  | 
|---|
| 769 | 778 |   | 
|---|
| 770 | 779 |  	/* Handle leapsec adjustments */ | 
|---|
| 771 | 780 |  	if (unlikely(ts->tv_sec >= ntp_next_leap_sec)) { | 
|---|