Skip to contentSkip to conversation

kernel/time: Make /proc/timer_list mode 0400

PATCH In review Marcus Meissner 7 participants 10 messages Nov 17, 2010 – Nov 30, 2010 High-resolution timers, timer wheel, clockevents

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/time: Make /proc/timer_list mode 0400

Hi,

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Avoid leaking them to user space to make writing kernel exploits a bit harder.

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

Ciao, Marcus

---
 kernel/time/timer_list.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/timer_list.c +1 -1
index ab8f5e3..5ae1ce3 100644
@@ -293,7 +293,7 @@ static int __init init_timer_list_procfs(void)
 {
 	struct proc_dir_entry *pe;
 
-	pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
+	pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
 	if (!pe)
 		return -ENOMEM;
 	return 0;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 10 lines · Marcus Meissner

Hi,

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Avoid leaking them to user space to make writing kernel exploits a bit harder.

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

iirc powertop parses this..

#2 lore raw
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Marcus Meissner

Hi,

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Quoted 6 lines
Quoted 4 lines

Avoid leaking them to user space to make writing kernel exploits a bit harder.

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

iirc powertop parses this..

powertop already says on startup:

PowerTOP needs to be run as root to collect enough information

And as developer tool it usually is for people having root access.

Ciao, Marcus

#3 lore raw
Quoted 10 lines · Marcus Meissner
Quoted 9 lines · Peter Zijlstra
Quoted 8 lines · Marcus Meissner

Hi,

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Avoid leaking them to user space to make writing kernel exploits a bit harder.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

iirc powertop parses this..

powertop already says on startup:

PowerTOP needs to be run as root to collect enough information

I know, but you said you didn't know of a tool that used the file.. now you do ;-)

#5 lore raw
In reply to Peter Zijlstra
Quoted 7 lines · On Wed, 17 Nov 2010 18:18:32 +0100 Peter Zijlstra <[email protected]>…
Quoted 6 lines · Marcus Meissner

Hi,

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Quoted 6 lines
Quoted 4 lines

Avoid leaking them to user space to make writing kernel exploits a bit harder.

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

iirc powertop parses this..

I bet it doesn't look at the kernel address (why was that added in the first place, anyway?)

I'd suggest that the risk of breakage would be much less if we left the file permissions alone and arranged for those addresses to be 0000000000000000 for non-root readers.

#6 lore raw
Quoted 15 lines · Andrew Morton
Quoted 12 lines · On Wed, 17 Nov 2010 18:18:32 +0100 Peter Zijlstra <[email protected]>…
Quoted 10 lines · Marcus Meissner

Hi,

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Avoid leaking them to user space to make writing kernel exploits a bit harder.

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

Quoted 8 lines
Quoted 1 line

iirc powertop parses this..

I bet it doesn't look at the kernel address (why was that added in the first place, anyway?)

I'd suggest that the risk of breakage would be much less if we left the file permissions alone and arranged for those addresses to be 0000000000000000 for non-root readers.

You beat me to it. Having the full information is quite helpful at times.

Thanks,

tglx

#7 lore raw
Quoted 22 lines · Thomas Gleixner
Quoted 20 lines · Andrew Morton
Quoted 7 lines · On Wed, 17 Nov 2010 18:18:32 +0100 Peter Zijlstra <[email protected]>…
Quoted 6 lines · Marcus Meissner

Hi,

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Quoted 6 lines
Quoted 4 lines

Avoid leaking them to user space to make writing kernel exploits a bit harder.

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

iirc powertop parses this..

I bet it doesn't look at the kernel address (why was that added in the first place, anyway?)

Quoted 6 lines
Quoted 3 lines

I'd suggest that the risk of breakage would be much less if we left the file permissions alone and arranged for those addresses to be 0000000000000000 for non-root readers.

You beat me to it. Having the full information is quite helpful at times.

We should do something like:

	if (!capable(CAP_SYS_ADMIN))
		print_ptr = NULL;

	sprintf(s, "%p", print_ptr);

Thanks,

Ingo

#8 lore raw
Quoted 6 lines · Ingo Molnar

We should do something like:

	if (!capable(CAP_SYS_ADMIN))
		print_ptr = NULL;

	sprintf(s, "%p", print_ptr);

A while ago, Thomas suggested following idea :

<quote>

Considering the amount of duplication you are about to do, you may want to think about adding a new pointer format extension then. We already have special '%p' modes for IPv6 addresse, MAC addresses and various other pointer types. It wouldn't be hard to add one which does not print (null).

</quote>

http://www.spinics.net/lists/netdev/msg146606.html

So the if (!capable(CAP_SYS_ADMIN)) could be centralized in %pX handling (X being a new letter, not actually 'X')

#4 lore raw
In reply to Marcus Meissner

Hi!

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

/proc/timer_list contains kernel addresses, like e.g.:
#0: <c000000001404158>, tick_sched_timer, S:01, .tick_nohz_restart_sched_tick, swapper/0
...

Avoid leaking them to user space to make writing kernel exploits a bit harder.

(I currently cannot think of a userland tool that uses this, this is likely pretty much root-only.)

Quoted 7 lines
Quoted 1 line

iirc powertop parses this..

powertop already says on startup:

PowerTOP needs to be run as root to collect enough information

And as developer tool it usually is for people having root access.

.....and now you are actively decreasing security.

Yes, developers usally have root access, but no, developers do not like to work as root.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw
In reply to Ingo Molnar

Hi!

Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 1 line

iirc powertop parses this..

I bet it doesn't look at the kernel address (why was that added in the first place, anyway?)

I'd suggest that the risk of breakage would be much less if we left the file permissions alone and arranged for those addresses to be 0000000000000000 for non-root readers.

You beat me to it. Having the full information is quite helpful at times.

Quoted 6 lines

We should do something like:

	if (!capable(CAP_SYS_ADMIN))
		print_ptr = NULL;

	sprintf(s, "%p", print_ptr);

Having single file that contains different stuff based on capable() is very very ugly.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html