Skip to content

Commit 32a831d

Browse files
keesnasty007
authored andcommitted
time: Remove CONFIG_TIMER_STATS
Currently CONFIG_TIMER_STATS exposes process information across namespaces: kernel/time/timer_list.c print_timer(): SEQ_printf(m, ", %s/%d", tmp, timer->start_pid); /proc/timer_list: lg-devs#11: <0000000000000000>, hrtimer_wakeup, S:01, do_nanosleep, cron/2570 Given that the tracer can give the same information, this patch entirely removes CONFIG_TIMER_STATS. Change-Id: I5147c4c1b4319cdabbc6d635b0d63f701b24ac30 Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Kees Cook <[email protected]> Acked-by: John Stultz <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: [email protected] Cc: Lai Jiangshan <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Xing Gao <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Jessica Frazelle <[email protected]> Cc: [email protected] Cc: Nicolas Iooss <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Michal Marek <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Olof Johansson <[email protected]> Cc: Andrew Morton <[email protected]> Cc: [email protected] Cc: Arjan van de Ven <[email protected]> Link: http://lkml.kernel.org/r/20170208192659.GA32582@beast Signed-off-by: Thomas Gleixner <[email protected]> haggertk: Backported to 3.4 Signed-off-by: Kevin F. Haggerty <[email protected]> Fixes: CVE-2017-5967 Signed-off-by: Joel Stanley <[email protected]>
1 parent 8922d53 commit 32a831d

File tree

10 files changed

+4
-667
lines changed

10 files changed

+4
-667
lines changed

Documentation/timers/timer_stats.txt

Lines changed: 0 additions & 73 deletions
This file was deleted.

include/linux/hrtimer.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ enum hrtimer_restart {
9696
* @function: timer expiry callback function
9797
* @base: pointer to the timer base (per cpu and per clock)
9898
* @state: state information (See bit values above)
99-
* @start_site: timer statistics field to store the site where the timer
100-
* was started
101-
* @start_comm: timer statistics field to store the name of the process which
102-
* started the timer
103-
* @start_pid: timer statistics field to store the pid of the task which
104-
* started the timer
10599
*
106100
* The hrtimer structure must be initialized by hrtimer_init()
107101
*/
@@ -111,11 +105,6 @@ struct hrtimer {
111105
enum hrtimer_restart (*function)(struct hrtimer *);
112106
struct hrtimer_clock_base *base;
113107
unsigned long state;
114-
#ifdef CONFIG_TIMER_STATS
115-
int start_pid;
116-
void *start_site;
117-
char start_comm[16];
118-
#endif
119108
};
120109

121110
/**

include/linux/timer.h

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ struct timer_list {
2323

2424
int slack;
2525

26-
#ifdef CONFIG_TIMER_STATS
27-
int start_pid;
28-
void *start_site;
29-
char start_comm[16];
30-
#endif
3126
#ifdef CONFIG_LOCKDEP
3227
struct lockdep_map lockdep_map;
3328
#endif
@@ -229,49 +224,6 @@ extern void set_timer_slack(struct timer_list *time, int slack_hz);
229224
*/
230225
extern unsigned long get_next_timer_interrupt(unsigned long now);
231226

232-
/*
233-
* Timer-statistics info:
234-
*/
235-
#ifdef CONFIG_TIMER_STATS
236-
237-
extern int timer_stats_active;
238-
239-
#define TIMER_STATS_FLAG_DEFERRABLE 0x1
240-
241-
extern void init_timer_stats(void);
242-
243-
extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
244-
void *timerf, char *comm,
245-
unsigned int timer_flag);
246-
247-
extern void __timer_stats_timer_set_start_info(struct timer_list *timer,
248-
void *addr);
249-
250-
static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
251-
{
252-
if (likely(!timer_stats_active))
253-
return;
254-
__timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
255-
}
256-
257-
static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
258-
{
259-
timer->start_site = NULL;
260-
}
261-
#else
262-
static inline void init_timer_stats(void)
263-
{
264-
}
265-
266-
static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
267-
{
268-
}
269-
270-
static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
271-
{
272-
}
273-
#endif
274-
275227
extern void add_timer(struct timer_list *timer);
276228

277229
extern int try_to_del_timer_sync(struct timer_list *timer);

kernel/hrtimer.c

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -797,34 +797,6 @@ void hrtimers_resume(void)
797797
clock_was_set_delayed();
798798
}
799799

800-
static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer)
801-
{
802-
#ifdef CONFIG_TIMER_STATS
803-
if (timer->start_site)
804-
return;
805-
timer->start_site = __builtin_return_address(0);
806-
memcpy(timer->start_comm, current->comm, TASK_COMM_LEN);
807-
timer->start_pid = current->pid;
808-
#endif
809-
}
810-
811-
static inline void timer_stats_hrtimer_clear_start_info(struct hrtimer *timer)
812-
{
813-
#ifdef CONFIG_TIMER_STATS
814-
timer->start_site = NULL;
815-
#endif
816-
}
817-
818-
static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
819-
{
820-
#ifdef CONFIG_TIMER_STATS
821-
if (likely(!timer_stats_active))
822-
return;
823-
timer_stats_update_stats(timer, timer->start_pid, timer->start_site,
824-
timer->function, timer->start_comm, 0);
825-
#endif
826-
}
827-
828800
/*
829801
* Counterpart to lock_hrtimer_base above:
830802
*/
@@ -961,7 +933,6 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base)
961933
* rare case and less expensive than a smp call.
962934
*/
963935
debug_deactivate(timer);
964-
timer_stats_hrtimer_clear_start_info(timer);
965936
reprogram = base->cpu_base == &__get_cpu_var(hrtimer_bases);
966937
/*
967938
* We must preserve the CALLBACK state flag here,
@@ -988,8 +959,11 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
988959
/* Remove an active timer from the queue: */
989960
ret = remove_hrtimer(timer, base);
990961

962+
/* Switch the timer base, if necessary: */
963+
new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);
964+
991965
if (mode & HRTIMER_MODE_REL) {
992-
tim = ktime_add_safe(tim, base->get_time());
966+
tim = ktime_add_safe(tim, new_base->get_time());
993967
/*
994968
* CONFIG_TIME_LOW_RES is a temporary way for architectures
995969
* to signal that they simply return xtime in
@@ -1004,11 +978,6 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
1004978

1005979
hrtimer_set_expires_range_ns(timer, tim, delta_ns);
1006980

1007-
/* Switch the timer base, if necessary: */
1008-
new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);
1009-
1010-
timer_stats_hrtimer_set_start_info(timer);
1011-
1012981
leftmost = enqueue_hrtimer(timer, new_base);
1013982

1014983
/*
@@ -1197,12 +1166,6 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
11971166
base = hrtimer_clockid_to_base(clock_id);
11981167
timer->base = &cpu_base->clock_base[base];
11991168
timerqueue_init(&timer->node);
1200-
1201-
#ifdef CONFIG_TIMER_STATS
1202-
timer->start_site = NULL;
1203-
timer->start_pid = -1;
1204-
memset(timer->start_comm, 0, TASK_COMM_LEN);
1205-
#endif
12061169
}
12071170

12081171
/**
@@ -1250,7 +1213,6 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now)
12501213

12511214
debug_deactivate(timer);
12521215
__remove_hrtimer(timer, base, HRTIMER_STATE_CALLBACK, 0);
1253-
timer_stats_account_hrtimer(timer);
12541216
fn = timer->function;
12551217

12561218
/*

kernel/time/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += tick-broadcast.o
77
obj-$(CONFIG_GENERIC_SCHED_CLOCK) += sched_clock.o
88
obj-$(CONFIG_TICK_ONESHOT) += tick-oneshot.o
99
obj-$(CONFIG_TICK_ONESHOT) += tick-sched.o
10-
obj-$(CONFIG_TIMER_STATS) += timer_stats.o

kernel/time/timer_list.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,11 @@ static void
5050
print_timer(struct seq_file *m, struct hrtimer *taddr, struct hrtimer *timer,
5151
int idx, u64 now)
5252
{
53-
#ifdef CONFIG_TIMER_STATS
54-
char tmp[TASK_COMM_LEN + 1];
55-
#endif
5653
SEQ_printf(m, " #%d: ", idx);
5754
print_name_offset(m, taddr);
5855
SEQ_printf(m, ", ");
5956
print_name_offset(m, timer->function);
6057
SEQ_printf(m, ", S:%02lx", timer->state);
61-
#ifdef CONFIG_TIMER_STATS
62-
SEQ_printf(m, ", ");
63-
print_name_offset(m, timer->start_site);
64-
memcpy(tmp, timer->start_comm, TASK_COMM_LEN);
65-
tmp[TASK_COMM_LEN] = 0;
66-
SEQ_printf(m, ", %s/%d", tmp, timer->start_pid);
67-
#endif
6858
SEQ_printf(m, "\n");
6959
SEQ_printf(m, " # expires at %Lu-%Lu nsecs [in %Ld to %Ld nsecs]\n",
7060
(unsigned long long)ktime_to_ns(hrtimer_get_softexpires(timer)),

0 commit comments

Comments
 (0)