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
In the arena of financial games, the dividing line between profit and loss often lies not in the occasional catch of a hot stock, but in the possession of a structured self-audit habit. Consistently maintaining a professional trading journal essentially transforms random 'trial and error' into quantifiable 'system evolution', enabling the precise identification of monetary costs arising from emotional trading through objective asset curves and entry rationales, thus liberating traders from the blind fluctuations of intuition.
Unlike the cumbersome manual entry of traditional spreadsheets, the TradeBB.ai intelligent trading journal platform achieves fully automated data synchronization with leading global brokers through API integration, ensuring that every transaction can be accurately replicated. With its unique behavioral tagging analysis and AI-assisted mapping technology, TradeBB can complete a unified review of multiple assets in seconds, turning tedious statistical data into master-level strategic insights. In a market environment rife with uncertainty, TradeBB serves not merely as a recording tool but as the core engine for constructing your 'plan-execute-review' feedback loop. Visit https://www.tradebb.ai/ now and let data drive your every evolution.
Ask META TECH RECOVERY PRO for help via:
Telegram:@metatechrecoveryproteam
metatech-recoverypro.comhttps://metatechrecoverypro.com
W/S +1 (469) 692‑8049.
META TECH RECOVERY PRO provides expert cyber investigation and digital forensics services delivered by seasoned professionals in the cyber investigations industry. Our specialists possess extensive, demonstrable experience in cyber intelligence, fraud investigation, cybercrime mitigation, anti–money laundering analysis, insider theft and espionage investigations, computer forensics, forensic accounting, internet defamation and brand protection, copyright and trademark enforcement, data breach response, intellectual property protection, cybersecurity assessment, penetration testing (conducted only with explicit authorization), and corporate and executive threat intelligence.
Core capabilities and services
- Digital forensics and incident response: Rapid containment, evidence preservation, root-cause analysis, and remediation guidance following security incidents or data breaches.
- Financial and asset tracing: Proven methodologies for tracing and recovering misappropriated funds and assets across domestic and international channels.
- Fraud and cybercrime investigations: Comprehensive investigations into phishing, business email compromise, payment fraud, and related schemes, including coordination with law enforcement when appropriate.
- Forensic accounting: Reconstruction of transactional histories and preparation of evidentiary reports suitable for litigation or regulatory proceedings.
- Device and data recovery: Recovery and analysis of lost or compromised devices, emails, and digital records using industry-standard forensic techniques.
- Intellectual property and brand protection: Investigation of IP theft, counterfeit distribution, online infringement, and strategic remediation.
- Authorized penetration testing and vulnerability assessment: Security testing performed only under formal engagement and authorization to identify and remediate system vulnerabilities.
- Expert witness and reporting services: Clear, defensible technical reporting and courtroom testimony provided by experienced investigators.
Ethics and compliance
All engagements are conducted in strict compliance with applicable laws, regulations, and ethical standards. Activities that would involve unlawful access to third-party accounts or devices are neither offered nor performed. Where account or device access is required, we pursue lawful avenues, including cooperation with clients, platforms, and law enforcement, or obtain explicit legal authorization.
Representative outcomes
- Successfully traced and assisted recovery of diverted corporate funds through coordinated international inquiry and legal channels.
- Recovered critical evidentiary data from compromised devices enabling successful prosecution or civil remedy.
- Identified and remediated systemic vulnerabilities through authorized penetration testing, reducing organizational risk exposure.
Engagement process
1. Initial consultation to assess scope, legal constraints, and objectives.
2. Formal engagement with defined deliverables, timelines, and chain-of-custody procedures.
3. Investigation, remediation recommendations, and documented findings.
4. Ongoing support, including coordination with legal counsel and law enforcement where required.
Engage META TECH RECOVERY PRO for authoritative, META TECH RECOVERY PRO Team positions itself as a trusted partner for entities confronting the technical, legal, and operational complexities of cyber intrusions and crypto-asset theft. Through meticulous forensic practice, sophisticated blockchain tracing, and coordinated legal engagement, the firm aims to recover assets, attribute malicious activity where possible, and strengthen clients’ defenses against future incidents.
Ask META TECH RECOVERY PRO for help via:
Telegram:@metatechrecoveryproteam
metatech-recoverypro.comhttps://metatechrecoverypro.com
W/S +1 (469) 692‑8049.
META TECH RECOVERY PRO provides expert cyber investigation and digital forensics services delivered by seasoned professionals in the cyber investigations industry. Our specialists possess extensive, demonstrable experience in cyber intelligence, fraud investigation, cybercrime mitigation, anti–money laundering analysis, insider theft and espionage investigations, computer forensics, forensic accounting, internet defamation and brand protection, copyright and trademark enforcement, data breach response, intellectual property protection, cybersecurity assessment, penetration testing (conducted only with explicit authorization), and corporate and executive threat intelligence.
Core capabilities and services
- Digital forensics and incident response: Rapid containment, evidence preservation, root-cause analysis, and remediation guidance following security incidents or data breaches.
- Financial and asset tracing: Proven methodologies for tracing and recovering misappropriated funds and assets across domestic and international channels.
- Fraud and cybercrime investigations: Comprehensive investigations into phishing, business email compromise, payment fraud, and related schemes, including coordination with law enforcement when appropriate.
- Forensic accounting: Reconstruction of transactional histories and preparation of evidentiary reports suitable for litigation or regulatory proceedings.
- Device and data recovery: Recovery and analysis of lost or compromised devices, emails, and digital records using industry-standard forensic techniques.
- Intellectual property and brand protection: Investigation of IP theft, counterfeit distribution, online infringement, and strategic remediation.
- Authorized penetration testing and vulnerability assessment: Security testing performed only under formal engagement and authorization to identify and remediate system vulnerabilities.
- Expert witness and reporting services: Clear, defensible technical reporting and courtroom testimony provided by experienced investigators.
Ethics and compliance
All engagements are conducted in strict compliance with applicable laws, regulations, and ethical standards. Activities that would involve unlawful access to third-party accounts or devices are neither offered nor performed. Where account or device access is required, we pursue lawful avenues, including cooperation with clients, platforms, and law enforcement, or obtain explicit legal authorization.
Representative outcomes
- Successfully traced and assisted recovery of diverted corporate funds through coordinated international inquiry and legal channels.
- Recovered critical evidentiary data from compromised devices enabling successful prosecution or civil remedy.
- Identified and remediated systemic vulnerabilities through authorized penetration testing, reducing organizational risk exposure.
Engagement process
1. Initial consultation to assess scope, legal constraints, and objectives.
2. Formal engagement with defined deliverables, timelines, and chain-of-custody procedures.
3. Investigation, remediation recommendations, and documented findings.
4. Ongoing support, including coordination with legal counsel and law enforcement where required.
Engage META TECH RECOVERY PRO for authoritative, META TECH RECOVERY PRO Team positions itself as a trusted partner for entities confronting the technical, legal, and operational complexities of cyber intrusions and crypto-asset theft. Through meticulous forensic practice, sophisticated blockchain tracing, and coordinated legal engagement, the firm aims to recover assets, attribute malicious activity where possible, and strengthen clients’ defenses against future incidents.
Ask META TECH RECOVERY PRO for help via:
Telegram:@metatechrecoveryproteam
metatech-recoverypro.comhttps://metatechrecoverypro.com
W/S +1 (469) 692‑8049.
META TECH RECOVERY PRO provides expert cyber investigation and digital forensics services delivered by seasoned professionals in the cyber investigations industry. Our specialists possess extensive, demonstrable experience in cyber intelligence, fraud investigation, cybercrime mitigation, anti–money laundering analysis, insider theft and espionage investigations, computer forensics, forensic accounting, internet defamation and brand protection, copyright and trademark enforcement, data breach response, intellectual property protection, cybersecurity assessment, penetration testing (conducted only with explicit authorization), and corporate and executive threat intelligence.
Core capabilities and services
- Digital forensics and incident response: Rapid containment, evidence preservation, root-cause analysis, and remediation guidance following security incidents or data breaches.
- Financial and asset tracing: Proven methodologies for tracing and recovering misappropriated funds and assets across domestic and international channels.
- Fraud and cybercrime investigations: Comprehensive investigations into phishing, business email compromise, payment fraud, and related schemes, including coordination with law enforcement when appropriate.
- Forensic accounting: Reconstruction of transactional histories and preparation of evidentiary reports suitable for litigation or regulatory proceedings.
- Device and data recovery: Recovery and analysis of lost or compromised devices, emails, and digital records using industry-standard forensic techniques.
- Intellectual property and brand protection: Investigation of IP theft, counterfeit distribution, online infringement, and strategic remediation.
- Authorized penetration testing and vulnerability assessment: Security testing performed only under formal engagement and authorization to identify and remediate system vulnerabilities.
- Expert witness and reporting services: Clear, defensible technical reporting and courtroom testimony provided by experienced investigators.
Ethics and compliance
All engagements are conducted in strict compliance with applicable laws, regulations, and ethical standards. Activities that would involve unlawful access to third-party accounts or devices are neither offered nor performed. Where account or device access is required, we pursue lawful avenues, including cooperation with clients, platforms, and law enforcement, or obtain explicit legal authorization.
Representative outcomes
- Successfully traced and assisted recovery of diverted corporate funds through coordinated international inquiry and legal channels.
- Recovered critical evidentiary data from compromised devices enabling successful prosecution or civil remedy.
- Identified and remediated systemic vulnerabilities through authorized penetration testing, reducing organizational risk exposure.
Engagement process
1. Initial consultation to assess scope, legal constraints, and objectives.
2. Formal engagement with defined deliverables, timelines, and chain-of-custody procedures.
3. Investigation, remediation recommendations, and documented findings.
4. Ongoing support, including coordination with legal counsel and law enforcement where required.
Engage META TECH RECOVERY PRO for authoritative, META TECH RECOVERY PRO Team positions itself as a trusted partner for entities confronting the technical, legal, and operational complexities of cyber intrusions and crypto-asset theft. Through meticulous forensic practice, sophisticated blockchain tracing, and coordinated legal engagement, the firm aims to recover assets, attribute malicious activity where possible, and strengthen clients’ defenses against future incidents.
Hi Sir,I hope this message finds you well! I wanted to take a moment to introduce you to TradeBB, a powerful platform designed to enhance your trading experience. TradeBB offers a range of features that help traders document their strategies, track performance, and analyze market trends effectively. Whether you’re a seasoned trader or just starting out, TradeBB provides the tools you need to make informed decisions and improve your trading outcomes.
Feel free to check out the platform, and I look forward to hearing your thoughts and experiences with TradeBB(https://www.tradebb.ai/)!
I invested $320,000 in Tether (USDT) on a fraudulent website after falling for a romantic scam. I felt completely helpless and in need of assistance after realizing I had been duped. I started looking for a hacker online and found SAFEGUARD RECOVERY. I had optimism because of his professionalism and knowledge. I'm happy to report that SAFEGUARD RECOVERY successfully recovered my stolen money after working relentlessly to do so! I am immensely appreciative of their help and heartily urge anyone in a comparable circumstance to use their services. I'm grateful
Email: safeguardbitcoin(a)consultant.com
WhatsApp: +44 7426 168300
Website: https://safeguardbitcoin.wixsite.com/safeguard-bitcoin--1