Skip to contentSkip to conversation

proc: drop write permission on 'timer_list' and 'slabinfo'

PATCH In review Amerigo Wang 6 participants 17 messages Aug 17, 2009 – Aug 20, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: drop write permission on 'timer_list' and 'slabinfo'

/proc/timer_list and /proc/slabinfo are not supposed to be written, so there should be no write permissions on it.

Cc Thomas Gleixner <[email protected]>
Cc Arjan van de Ven <[email protected]>
Cc Matt Mackall <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Eduard - Gabriel Munteanu <[email protected]>
Cc Vegard Nossum <[email protected]>
Cc David Rientjes <[email protected]>

---

kernel/time/timer_list.c +1 -1
index a999b92..fddd69d 100644
@@ -286,7 +286,7 @@ static int __init init_timer_list_procfs(void)
 {
 	struct proc_dir_entry *pe;
 
-	pe = proc_create("timer_list", 0644, NULL, &timer_list_fops);
+	pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
 	if (!pe)
 		return -ENOMEM;
 	return 0;
mm/slab.c +1 -1
index 7b5d4de..a19e4be 100644
@@ -4473,7 +4473,7 @@ static const struct file_operations proc_slabstats_operations = {
 
 static int __init slab_proc_init(void)
 {
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
 #ifdef CONFIG_DEBUG_SLAB_LEAK
 	proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
 #endif
mm/slub.c +1 -1
index b9f1491..aba2c1b 100644
@@ -4726,7 +4726,7 @@ static const struct file_operations proc_slabinfo_operations = {
 
 static int __init slab_proc_init(void)
 {
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
 	return 0;
 }
 module_init(slab_proc_init);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 2 lines · Amerigo Wang

/proc/timer_list and /proc/slabinfo are not supposed to be written, so there should be no write permissions on it.

good catch!

kernel/time/timer_list.c

Quoted 2 lines
kernel/time/timer_list.c +0 -0

I have applied the timer_list bits to the timer tree. The SLUB/SLAB bits should go into the SLAB tree i guess.

Thanks,

Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#16 lore raw

[tip:timers/urgent] timers: Drop write permission on /proc/timer_list

In reply to Amerigo Wang
Commit-ID:  de809347aeef0a68c04576c464414d0e4dce59fc
Gitweb:     http://git.kernel.org/tip/de809347aeef0a68c04576c464414d0e4dce59fc
Author:     Amerigo Wang <[email protected]>
AuthorDate: Mon, 17 Aug 2009 05:43:01 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 17 Aug 2009 11:47:31 +0200

timers: Drop write permission on /proc/timer_list

/proc/timer_list and /proc/slabinfo are not supposed to be written, so there should be no write permissions on it.

Cc Pekka Enberg <[email protected]>
Cc Vegard Nossum <[email protected]>
Cc Eduard - Gabriel Munteanu <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Rientjes <[email protected]>
Cc Amerigo Wang <[email protected]>
Cc Matt Mackall <[email protected]>
Cc Arjan van de Ven <[email protected]>

LKML-Reference: <[email protected]>

---
 kernel/time/timer_list.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/timer_list.c +1 -1
index a999b92..fddd69d 100644
@@ -286,7 +286,7 @@ static int __init init_timer_list_procfs(void)
 {
 	struct proc_dir_entry *pe;
 
-	pe = proc_create("timer_list", 0644, NULL, &timer_list_fops);
+	pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
 	if (!pe)
 		return -ENOMEM;
 	return 0;
#2 lore raw
In reply to Ingo Molnar
Quoted 5 lines · Ingo Molnar
Quoted 2 lines · Amerigo Wang

/proc/timer_list and /proc/slabinfo are not supposed to be written, so there should be no write permissions on it.

Quoted 7 lines

good catch!

kernel/time/timer_list.c

Quoted 2 lines
kernel/time/timer_list.c +0 -0

I have applied the timer_list bits to the timer tree. The SLUB/SLAB bits should go into the SLAB tree i guess.

Yeah, I'll grab the slab parts to slab.git if I don't see a separate patch in my inbox when I get home. Thanks!

Pekka

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
Quoted 5 lines · Pekka Enberg
Quoted 2 lines

I have applied the timer_list bits to the timer tree. The SLUB/SLAB bits should go into the SLAB tree i guess.

Yeah, I'll grab the slab parts to slab.git if I don't see a separate patch in my inbox when I get home. Thanks!

slab needs the write permissions for tuning!

#4 lore raw

Hi Christoph,

Quoted 8 lines · Christoph Lameter
Quoted 4 lines · Pekka Enberg
Quoted 2 lines

I have applied the timer_list bits to the timer tree. The SLUB/SLAB bits should go into the SLAB tree i guess.

Yeah, I'll grab the slab parts to slab.git if I don't see a separate patch in my inbox when I get home. Thanks!

slab needs the write permissions for tuning!

Oh, crap, you're right, I had forgotten about that. It's probably best to keep slub permissions as-is, no?

Pekka

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 4 lines · Pekka Enberg
Quoted 1 line

slab needs the write permissions for tuning!

Oh, crap, you're right, I had forgotten about that. It's probably best to keep slub permissions as-is, no?

slub perms can be changed. The patch is okay for that. But there is no write method in slub. Effectively it makes no difference. Just the display is nicer in /proc.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
Quoted 8 lines · Christoph Lameter
Quoted 5 lines · Pekka Enberg
Quoted 2 lines

slab needs the write permissions for tuning!

Oh, crap, you're right, I had forgotten about that. It's probably best to keep slub permissions as-is, no?

Oops! I misread the code... sorry.

Quoted 7 lines

slub perms can be changed. The patch is okay for that. But there is no write method in slub. Effectively it makes no difference. Just the display is nicer in /proc.

Ah, ok, I update this part of patch, attached.

Thanks!

mm/slub.c +1 -1
index b9f1491..aba2c1b 100644
@@ -4726,7 +4726,7 @@ static const struct file_operations proc_slabinfo_operations = {
 
 static int __init slab_proc_init(void)
 {
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
 	return 0;
 }
 module_init(slab_proc_init);
#7 lore raw

mm/slub.c static const struct file_operations proc_slabinfo_operations = { · line 4729

Quoted 4 lines

static int __init slab_proc_init(void)
{

mm/slub.c +1 -1
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUSR|S_IRUGO,NULL,&proc_slabinfo_operations);

S_IRUSR|S_IRUGO == S_IRUGO

Quoted 3 lines

return 0;
}
module_init(slab_proc_init);

#8 lore raw
Quoted 9 lines · Li Zefan

Review

Quoted 5 lines

static int __init slab_proc_init(void)
{

(quoted diff) +1 -1
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUSR|S_IRUGO,NULL,&proc_slabinfo_operations);

S_IRUSR|S_IRUGO == S_IRUGO

Ah, yeah. Thanks!

Update it.

mm/slub.c +1 -1
index b9f1491..61398c0 100644
@@ -4726,7 +4726,7 @@ static const struct file_operations proc_slabinfo_operations = {
 
 static int __init slab_proc_init(void)
 {
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);
 	return 0;
 }
 module_init(slab_proc_init);
#9 lore raw

mm/slub.c static const struct file_operations proc_slabinfo_operations = { · line 4729

Quoted 2 lines · Amerigo Wang
mm/slub.c +1 -1
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);

Style nitpick. The spaces were packed to fit into 80-col I guess.

ERROR: space required after that ',' (ctx:VxV)
#10: FILE: mm/slub.c:4729:

+       proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);
                              ^

ERROR: space required after that ',' (ctx:VxV)
#10: FILE: mm/slub.c:4729:

+       proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);
                                      ^

ERROR: space required after that ',' (ctx:VxO)
#10: FILE: mm/slub.c:4729:

+       proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);
                                           ^

ERROR: space required before that '&' (ctx:OxV)
#10: FILE: mm/slub.c:4729:

+       proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);
                                            ^

Thanks,
Fengguang

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw
In reply to Li Zefan
Quoted 11 lines · Li Zefan

mm/slub.c static const struct file_operations proc_slabinfo_operations = { · line 4729

Quoted 4 lines

static int __init slab_proc_init(void)
{

mm/slub.c +1 -1
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUSR|S_IRUGO,NULL,&proc_slabinfo_operations);

S_IRUSR|S_IRUGO == S_IRUGO

Quoted 3 lines

return 0;
}
module_init(slab_proc_init);

I went ahead and fixed that. Applied, thanks everyone!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw
In reply to Wu Fengguang
Quoted 10 lines · Wu Fengguang

mm/slub.c static const struct file_operations proc_slabinfo_operations = { · line 4729

Quoted 3 lines · Amerigo Wang
mm/slub.c +1 -1
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);

Style nitpick. The spaces were packed to fit into 80-col I guess.

Yeah, I noticed this too, the reason I didn't fix this is that I don't want to mix coding style fix with this one. We can fix it in another patch, if you want. :)

Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw
Quoted 12 lines · Amerigo Wang
Quoted 10 lines · Wu Fengguang

mm/slub.c static const struct file_operations proc_slabinfo_operations = { · line 4729

Quoted 3 lines · Amerigo Wang
mm/slub.c +1 -1
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);

Style nitpick. The spaces were packed to fit into 80-col I guess.

Quoted 3 lines

Yeah, I noticed this too, the reason I didn't fix this is that I don't want to mix coding style fix with this one. We can fix it in another patch, if you want. :)

Why not? This don't hurt readability of the patch, hehe.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw
Quoted 16 lines · Wu Fengguang
Quoted 14 lines · Amerigo Wang
Quoted 12 lines · Wu Fengguang

Review

Quoted 4 lines · Amerigo Wang
(quoted diff) +1 -1
-	proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);

Style nitpick. The spaces were packed to fit into 80-col I guess.

Quoted 5 lines
Quoted 2 lines

Yeah, I noticed this too, the reason I didn't fix this is that I don't want to mix coding style fix with this one. We can fix it in another patch, if you want. :)

Why not? This don't hurt readability of the patch, hehe.

Here we go.

Pekka, could you please also take the patch attached below? It is just a trivial coding style fix. And it is based on the my previous patch.

Thanks!

mm/slub.c +3 -4
index 61398c0..1cd60ff 100644
@@ -1109,8 +1109,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
 	}
 
 	if (kmemcheck_enabled
-		&& !(s->flags & (SLAB_NOTRACK | DEBUG_DEFAULT_FLAGS)))
-	{
+		&& !(s->flags & (SLAB_NOTRACK | DEBUG_DEFAULT_FLAGS))) {
 		int pages = 1 << oo_order(oo);
 
 		kmemcheck_alloc_shadow(page, oo_order(oo), flags, node);
@@ -2001,7 +2000,7 @@ static inline int calculate_order(int size)
 				return order;
 			fraction /= 2;
 		}
-		min_objects --;
+		min_objects--;
 	}
 
 	/*
@@ -4726,7 +4725,7 @@ static const struct file_operations proc_slabinfo_operations = {
 
 static int __init slab_proc_init(void)
 {
-	proc_create("slabinfo",S_IRUGO,NULL,&proc_slabinfo_operations);
+	proc_create("slabinfo", S_IRUGO, NULL, &proc_slabinfo_operations);
 	return 0;
 }
 module_init(slab_proc_init);
#13 lore raw
Quoted 1 line · Amerigo Wang

Pekka, could you please also take the patch attached below? It is just a trivial coding style fix. And it is based on the my previous patch.

The last hunk was already in slab.git because I fixed your patch up by hand. I applied the rest but can you please send proper patches in the future? That is, no attachments and a "git am" friendly subject line. Thanks!

Pekka

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#14 lore raw
Quoted 4 lines · Pekka Enberg
Quoted 1 line · Amerigo Wang

Pekka, could you please also take the patch attached below? It is just a trivial coding style fix. And it is based on the my previous patch.

The last hunk was already in slab.git because I fixed your patch up by hand. I applied the rest but can you please send proper patches in the future? That is, no attachments and a "git am" friendly subject line. Thanks!

Nice. Thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>