Skip to content

Commit 4312e0e

Browse files
committed
Merge tag 'timers-urgent-2020-11-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Thomas Gleixner: "A few fixes for timers/timekeeping: - Prevent undefined behaviour in the timespec64_to_ns() conversion which is used for converting user supplied time input to nanoseconds. It lacked overflow protection. - Mark sched_clock_read_begin/retry() to prevent recursion in the tracer - Remove unused debug functions in the hrtimer and timerlist code" * tag 'timers-urgent-2020-11-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: time: Prevent undefined behaviour in timespec64_to_ns() timers: Remove unused inline funtion debug_timer_free() hrtimer: Remove unused inline function debug_hrtimer_free() time/sched_clock: Mark sched_clock_read_begin/retry() as notrace
2 parents 82423b4 + cb47755 commit 4312e0e

File tree

5 files changed

+6
-16
lines changed

5 files changed

+6
-16
lines changed

include/linux/time64.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ static inline bool timespec64_valid_settod(const struct timespec64 *ts)
124124
*/
125125
static inline s64 timespec64_to_ns(const struct timespec64 *ts)
126126
{
127+
/* Prevent multiplication overflow */
128+
if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
129+
return KTIME_MAX;
130+
127131
return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
128132
}
129133

kernel/time/hrtimer.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,6 @@ static inline void debug_hrtimer_deactivate(struct hrtimer *timer)
425425
debug_object_deactivate(timer, &hrtimer_debug_descr);
426426
}
427427

428-
static inline void debug_hrtimer_free(struct hrtimer *timer)
429-
{
430-
debug_object_free(timer, &hrtimer_debug_descr);
431-
}
432-
433428
static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
434429
enum hrtimer_mode mode);
435430

kernel/time/itimer.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
172172
u64 oval, nval, ointerval, ninterval;
173173
struct cpu_itimer *it = &tsk->signal->it[clock_id];
174174

175-
/*
176-
* Use the to_ktime conversion because that clamps the maximum
177-
* value to KTIME_MAX and avoid multiplication overflows.
178-
*/
179175
nval = timespec64_to_ns(&value->it_value);
180176
ninterval = timespec64_to_ns(&value->it_interval);
181177

kernel/time/sched_clock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift)
6868
return (cyc * mult) >> shift;
6969
}
7070

71-
struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
71+
notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
7272
{
7373
*seq = raw_read_seqcount_latch(&cd.seq);
7474
return cd.read_data + (*seq & 1);
7575
}
7676

77-
int sched_clock_read_retry(unsigned int seq)
77+
notrace int sched_clock_read_retry(unsigned int seq)
7878
{
7979
return read_seqcount_latch_retry(&cd.seq, seq);
8080
}

kernel/time/timer.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,6 @@ static inline void debug_timer_deactivate(struct timer_list *timer)
732732
debug_object_deactivate(timer, &timer_debug_descr);
733733
}
734734

735-
static inline void debug_timer_free(struct timer_list *timer)
736-
{
737-
debug_object_free(timer, &timer_debug_descr);
738-
}
739-
740735
static inline void debug_timer_assert_init(struct timer_list *timer)
741736
{
742737
debug_object_assert_init(timer, &timer_debug_descr);

0 commit comments

Comments
 (0)