The code to check the adjtimex() or clock_adjtime() arguments is spread
out across multiple files for presumably only historic reasons. As a
preparatation for a rework to get rid of the use of 'struct timeval'
and 'struct timespec' in there, this moves all the portions into
kernel/time/timekeeping.c and marks them as 'static'.
The warp_clock() function here is not as closely related as the others,
but I feel it still makes sense to move it here in order to consolidate
all callers of timekeeping_inject_offset().
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
include/linux/time.h | 26 ----------
kernel/time/ntp.c | 61 ----------------------
kernel/time/ntp_internal.h | 1 -
kernel/time/time.c | 36 +------------
kernel/time/timekeeping.c | 123 ++++++++++++++++++++++++++++++++++++++++++++-
kernel/time/timekeeping.h | 2 +-
6 files changed, 123 insertions(+), 126 deletions(-)
diff --git a/include/linux/time.h b/include/linux/time.h
index 9bc1f945777c..c0fbad08448f 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -134,32 +134,6 @@ static inline bool timeval_valid(const struct timeval *tv)
extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
-/*
- * Validates if a timespec/timeval used to inject a time offset is valid.
- * Offsets can be postive or negative. The value of the timeval/timespec
- * is the sum of its fields, but *NOTE*: the field tv_usec/tv_nsec must
- * always be non-negative.
- */
-static inline bool timeval_inject_offset_valid(const struct timeval *tv)
-{
- /* We don't check the tv_sec as it can be positive or negative */
-
- /* Can't have more microseconds then a second */
- if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
- return false;
- return true;
-}
-
-static inline bool timespec_inject_offset_valid(const struct timespec *ts)
-{
- /* We don't check the tv_sec as it can be positive or negative */
-
- /* Can't have more nanoseconds then a second */
- if (ts->tv_nsec < 0 || ts->tv_nsec >= NSEC_PER_SEC)
- return false;
- return true;
-}
-
/* Some architectures do not supply their own clocksource.
* This is mainly the case in architectures that get their
* inter-tick times by reading the counter on their interval
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index edf19cc53140..a5e702669d84 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -653,67 +653,6 @@ static inline void process_adjtimex_modes(struct timex *txc,
}
-
-/**
- * ntp_validate_timex - Ensures the timex is ok for use in do_adjtimex
- */
-int ntp_validate_timex(struct timex *txc)
-{
- if (txc->modes & ADJ_ADJTIME) {
- /* singleshot must not be used with any other mode bits */
- if (!(txc->modes & ADJ_OFFSET_SINGLESHOT))
- return -EINVAL;
- if (!(txc->modes & ADJ_OFFSET_READONLY) &&
- !capable(CAP_SYS_TIME))
- return -EPERM;
- } else {
- /* In order to modify anything, you gotta be super-user! */
- if (txc->modes && !capable(CAP_SYS_TIME))
- return -EPERM;
- /*
- * if the quartz is off by more than 10% then
- * something is VERY wrong!
- */
- if (txc->modes & ADJ_TICK &&
- (txc->tick < 900000/USER_HZ ||
- txc->tick > 1100000/USER_HZ))
- return -EINVAL;
- }
-
- if (txc->modes & ADJ_SETOFFSET) {
- /* In order to inject time, you gotta be super-user! */
- if (!capable(CAP_SYS_TIME))
- return -EPERM;
-
- if (txc->modes & ADJ_NANO) {
- struct timespec ts;
-
- ts.tv_sec = txc->time.tv_sec;
- ts.tv_nsec = txc->time.tv_usec;
- if (!timespec_inject_offset_valid(&ts))
- return -EINVAL;
-
- } else {
- if (!timeval_inject_offset_valid(&txc->time))
- return -EINVAL;
- }
- }
-
- /*
- * Check for potential multiplication overflows that can
- * only happen on 64-bit systems:
- */
- if ((txc->modes & ADJ_FREQUENCY) && (BITS_PER_LONG == 64)) {
- if (LLONG_MIN / PPM_SCALE > txc->freq)
- return -EINVAL;
- if (LLONG_MAX / PPM_SCALE < txc->freq)
- return -EINVAL;
- }
-
- return 0;
-}
-
-
/*
* adjtimex mainly allows reading (and writing, if superuser) of
* kernel time-keeping variables. used by xntpd.
diff --git a/kernel/time/ntp_internal.h b/kernel/time/ntp_internal.h
index d8a7c11fa71a..74b52cd48209 100644
--- a/kernel/time/ntp_internal.h
+++ b/kernel/time/ntp_internal.h
@@ -7,7 +7,6 @@ extern void ntp_clear(void);
extern u64 ntp_tick_length(void);
extern ktime_t ntp_get_next_leap(void);
extern int second_overflow(time64_t secs);
-extern int ntp_validate_timex(struct timex *);
extern int __do_adjtimex(struct timex *, struct timespec64 *, s32 *);
extern void __hardpps(const struct timespec64 *, const struct timespec64 *);
#endif /* _LINUX_NTP_INTERNAL_H */
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 44a8c1402133..04684e294f00 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -158,40 +158,6 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
}
/*
- * Indicates if there is an offset between the system clock and the hardware
- * clock/persistent clock/rtc.
- */
-int persistent_clock_is_local;
-
-/*
- * Adjust the time obtained from the CMOS to be UTC time instead of
- * local time.
- *
- * This is ugly, but preferable to the alternatives. Otherwise we
- * would either need to write a program to do it in /etc/rc (and risk
- * confusion if the program gets run more than once; it would also be
- * hard to make the program warp the clock precisely n hours) or
- * compile in the timezone information into the kernel. Bad, bad....
- *
- * - TYT, 1992-01-01
- *
- * The best thing to do is to keep the CMOS clock in universal time (UTC)
- * as real UNIX machines always do it. This avoids all headaches about
- * daylight saving times and warping kernel clocks.
- */
-static inline void warp_clock(void)
-{
- if (sys_tz.tz_minuteswest != 0) {
- struct timespec adjust;
-
- persistent_clock_is_local = 1;
- adjust.tv_sec = sys_tz.tz_minuteswest * 60;
- adjust.tv_nsec = 0;
- timekeeping_inject_offset(&adjust);
- }
-}
-
-/*
* In case for some reason the CMOS clock has not already been running
* in UTC, but in some local time: The first time we set the timezone,
* we will warp the clock so that it is ticking UTC time instead of
@@ -224,7 +190,7 @@ int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz
if (firsttime) {
firsttime = 0;
if (!tv)
- warp_clock();
+ timekeeping_warp_clock();
}
}
if (tv)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 8af77006e937..679dbfbea419 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1300,13 +1300,39 @@ int do_settimeofday64(const struct timespec64 *ts)
}
EXPORT_SYMBOL(do_settimeofday64);
+/*
+ * Validates if a timespec/timeval used to inject a time offset is valid.
+ * Offsets can be postive or negative. The value of the timeval/timespec
+ * is the sum of its fields, but *NOTE*: the field tv_usec/tv_nsec must
+ * always be non-negative.
+ */
+static inline bool timeval_inject_offset_valid(const struct timeval *tv)
+{
+ /* We don't check the tv_sec as it can be positive or negative */
+
+ /* Can't have more microseconds then a second */
+ if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
+ return false;
+ return true;
+}
+
+static inline bool timespec_inject_offset_valid(const struct timespec *ts)
+{
+ /* We don't check the tv_sec as it can be positive or negative */
+
+ /* Can't have more nanoseconds then a second */
+ if (ts->tv_nsec < 0 || ts->tv_nsec >= NSEC_PER_SEC)
+ return false;
+ return true;
+}
+
/**
* timekeeping_inject_offset - Adds or subtracts from the current time.
* @tv: pointer to the timespec variable containing the offset
*
* Adds or subtracts an offset value from the current time.
*/
-int timekeeping_inject_offset(struct timespec *ts)
+static int timekeeping_inject_offset(struct timespec *ts)
{
struct timekeeper *tk = &tk_core.timekeeper;
unsigned long flags;
@@ -1345,7 +1371,40 @@ int timekeeping_inject_offset(struct timespec *ts)
return ret;
}
-EXPORT_SYMBOL(timekeeping_inject_offset);
+
+/*
+ * Indicates if there is an offset between the system clock and the hardware
+ * clock/persistent clock/rtc.
+ */
+int persistent_clock_is_local;
+
+/*
+ * Adjust the time obtained from the CMOS to be UTC time instead of
+ * local time.
+ *
+ * This is ugly, but preferable to the alternatives. Otherwise we
+ * would either need to write a program to do it in /etc/rc (and risk
+ * confusion if the program gets run more than once; it would also be
+ * hard to make the program warp the clock precisely n hours) or
+ * compile in the timezone information into the kernel. Bad, bad....
+ *
+ * - TYT, 1992-01-01
+ *
+ * The best thing to do is to keep the CMOS clock in universal time (UTC)
+ * as real UNIX machines always do it. This avoids all headaches about
+ * daylight saving times and warping kernel clocks.
+ */
+void timekeeping_warp_clock(void)
+{
+ if (sys_tz.tz_minuteswest != 0) {
+ struct timespec adjust;
+
+ persistent_clock_is_local = 1;
+ adjust.tv_sec = sys_tz.tz_minuteswest * 60;
+ adjust.tv_nsec = 0;
+ timekeeping_inject_offset(&adjust);
+ }
+}
/**
* __timekeeping_set_tai_offset - Sets the TAI offset from UTC and monotonic
@@ -2290,6 +2349,66 @@ ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_real,
}
/**
+ * ntp_validate_timex - Ensures the timex is ok for use in do_adjtimex
+ */
+static int ntp_validate_timex(struct timex *txc)
+{
+ if (txc->modes & ADJ_ADJTIME) {
+ /* singleshot must not be used with any other mode bits */
+ if (!(txc->modes & ADJ_OFFSET_SINGLESHOT))
+ return -EINVAL;
+ if (!(txc->modes & ADJ_OFFSET_READONLY) &&
+ !capable(CAP_SYS_TIME))
+ return -EPERM;
+ } else {
+ /* In order to modify anything, you gotta be super-user! */
+ if (txc->modes && !capable(CAP_SYS_TIME))
+ return -EPERM;
+ /*
+ * if the quartz is off by more than 10% then
+ * something is VERY wrong!
+ */
+ if (txc->modes & ADJ_TICK &&
+ (txc->tick < 900000/USER_HZ ||
+ txc->tick > 1100000/USER_HZ))
+ return -EINVAL;
+ }
+
+ if (txc->modes & ADJ_SETOFFSET) {
+ /* In order to inject time, you gotta be super-user! */
+ if (!capable(CAP_SYS_TIME))
+ return -EPERM;
+
+ if (txc->modes & ADJ_NANO) {
+ struct timespec ts;
+
+ ts.tv_sec = txc->time.tv_sec;
+ ts.tv_nsec = txc->time.tv_usec;
+ if (!timespec_inject_offset_valid(&ts))
+ return -EINVAL;
+
+ } else {
+ if (!timeval_inject_offset_valid(&txc->time))
+ return -EINVAL;
+ }
+ }
+
+ /*
+ * Check for potential multiplication overflows that can
+ * only happen on 64-bit systems:
+ */
+ if ((txc->modes & ADJ_FREQUENCY) && (BITS_PER_LONG == 64)) {
+ if (LLONG_MIN / PPM_SCALE > txc->freq)
+ return -EINVAL;
+ if (LLONG_MAX / PPM_SCALE < txc->freq)
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
+/**
* do_adjtimex() - Accessor function to NTP __do_adjtimex function
*/
int do_adjtimex(struct timex *txc)
diff --git a/kernel/time/timekeeping.h b/kernel/time/timekeeping.h
index d0914676d4c5..44aec7893cdd 100644
--- a/kernel/time/timekeeping.h
+++ b/kernel/time/timekeeping.h
@@ -10,7 +10,7 @@ extern ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq,
extern int timekeeping_valid_for_hres(void);
extern u64 timekeeping_max_deferment(void);
-extern int timekeeping_inject_offset(struct timespec *ts);
+extern void timekeeping_warp_clock(void);
extern int timekeeping_suspend(void);
extern void timekeeping_resume(void);
--
2.9.0
致: lists.linaro.org 尊敬的y2038 antonio medina给您发送了一封询盘,请尽快登录平台回复,避免错失商机。 antonio medina Spain | IP 94.73.35.*(Spain) Inquiry about your products... hi,distributor in Spain for retail purchase, pls give us your best price according to selected items.port of destination Valenciaport.best regards, 立即回复 进入中国制造网App(供应商版) ,随时随地处理消息,斩获商机更高效! 注意: 1. 请在Virtual Office后台跟进买家,可查看更多买家信息和
;行为数据,保障交易安全。 2. 如果您收到可疑消息,可以在Virtual Office收件箱中向我们检举,一经核实,我们将严肃处理。
Notification: Business Message from Mr. John Doe body { font-family: Arial, sans-serif; background-color: #ffffff; margin: 0; padding: 20px; color: #333333; } .page-title { font-size: 16px; font-weight: bold; font-family: Times, "Times New Roman", serif; margin-bottom: 15px; } .main-container { max-width: 650px; margin: 0 auto; border: 2px solid #ffcc00; font-size: 12px; } .header-brand { padding: 10px; display: flex; justify-content: space-between; align-items: center; } .logo { font-style: italic; font-weight: bold; font-size: 18px; color: #cc0000; } .logo span { color: #333; } .orange-banner { background-color: #ffb900; color: #ffffff; padding: 8px 15px; font-weight: bold; font-size: 14px; text-align: right; } .inner-content { padding: 20px; } .intro-text { line-height: 1.6; margin-bottom: 20px; color: #444; } .section-title { background-color: #eaeaea; padding: 4px 8px; font-weight: bold; font-size: 13px; color: #333; margin-top: 20px; margin-bottom: 10px; } .data-table {
width: 100%; border-collapse: collapse; margin-bottom: 15px; } .data-table td { padding: 6px; vertical-align: top; } .label-col { width: 25%; color: #666; } .value-col { width: 75%; } .link-text { color: #0055aa; text-decoration: underline; } .red-note { color: #ff0000; font-size: 11px; margin-top: 5px; font-weight: normal; } .btn-container { text-align: center; margin: 30px 0 15px 0; } .reply-btn { display: inline-block; background: linear-gradient(to bottom, #ffea9f, #ffb900); border: 1px solid #d49b00; border-radius: 4px; padding: 6px 25px; text-align: center; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,0.1); } .btn-title { color: #4e3400; font-weight: bold; font-size: 14px; margin: 0; } .btn-sub { color: #6d4c00; font-size: 10px; margin: 0; } .bottom-notes { background-color: #f7f7f7; border-top: 1px solid #e5e5e5; padding: 15px; font-size: 11px; color: #666; line-height: 1.5; } .yellow-footer { background-color: #ffb900; color: #000000; font-weight: bold; f
ont-size: 11px; padding: 6px; text-align: right; } Made-in-China.com™ ✉ Message Notification Made-in-China.com would like to let you know that you have just received a new business message which is saved in the Inquiry Inbox of your member home (Virtual Office) within the next 1 year. We suggest you sign in with your Email to view or reply the message. For your convenience, a copy of this message is also provided below. Message Details Message Subject Inquiry regarding wholesale distribution catalog Message Content We are looking for a reliable industrial supplier in China for long-term contract procurement. Please provide your current export price list and technical catalog based on high-standard component manufacturing specs.- Destination Port: Port of Manzanillo - Initial Trial Target: 3,000+ unitsRegards, Mendoza Group. Message Basics and Contact Details Date & time sent 2026-05-24 14:22:15 (GMT-07:00) Mexico Sender alejandro_mendoza Company Mendoza Group
. Email To view the email address, please sign in in your account. (NOTE: Please login your Virtual Office to reply the message but DO NOT REPLY to en-notification(a)made-in-china.com) Telephone +52-677-574-7347 Fax +52-677-574-7347 Country/Region Mexico Homepage http://www.mendoza_group.de Sender's IP Address 187.130.22.* Sender's IP Location Mexico ✉ Reply Now ! Click to reply in Virtual Office Note:1) Sender's IP Information is for reference only, but NOT guaranteed or verified by Made-in-China.com;2) Send us complaint if you are receiving unsolicited messages (SPAM and/or Duplicate Messages), threatening or harassing messages, suspicious messages about fee advance or money transfer...etc. * This notification service is provided by http://www.made-in-china.com Source Quality Products Made in China
With continuous industrial development, air quality problems have arisen. Globally, 80% of the population now faces respiratory issues. Large amounts of industrial waste gas and vehicle exhaust are destroying our living environment, making fresh air a luxury. A reliable air filter is entering your life to change your air
quality.
Learn more at: https://hifinefilter.com/
● Vous avez reçu une information
Merci d'en prendre connaissance dans les meilleurs délais. Une prise d’initiative de votre part pourrait être nécessaire.
Cliquez ci-dessous pour y accéder :
Accéder à mon compte
Mentions Légales
Vous recevez ce message parce que vous nous avez communiqué votre adresse e-mail. Nous recueillons des statistiques d'ouverture des emails grâce à l'affichage des images incluses dans le message. Lorsque votre application email le permet, vous pouvez à tout moment les accepter ou les refuser en paramétrant leur affichage. Le CIC garantit l'utilisation de vos données personnelles dans le respect de la législation. Si vous ne souhaitez plus recevoir de communication commerciale de notre part, cliquez ici.
Ce message et toutes les pièces jointes sont confidentiels et établis à l'intention exclusive de son ou ses destinataires. Si vous avez reçu ce message par erreur, merci d'en avertir immédiatement l'émetteur et de détruire le message.
Une banque qui appartient à ses clients, ça change tout.
● Vous avez reçu une information
Merci d'en prendre connaissance dans les meilleurs délais. Une prise d’initiative de votre part pourrait être nécessaire.
Cliquez ci-dessous pour y accéder :
Accéder à mon compte
Mentions Légales
Vous recevez ce message parce que vous nous avez communiqué votre adresse e-mail. Nous recueillons des statistiques d'ouverture des emails grâce à l'affichage des images incluses dans le message. Lorsque votre application email le permet, vous pouvez à tout moment les accepter ou les refuser en paramétrant leur affichage. Le CIC garantit l'utilisation de vos données personnelles dans le respect de la législation. Si vous ne souhaitez plus recevoir de communication commerciale de notre part, cliquez ici.
Ce message et toutes les pièces jointes sont confidentiels et établis à l'intention exclusive de son ou ses destinataires. Si vous avez reçu ce message par erreur, merci d'en avertir immédiatement l'émetteur et de détruire le message.
Une banque qui appartient à ses clients, ça change tout.