public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* procfs permissions on 2.6.x
@ 2004-07-03 20:22 Herbert Poetzl
  2004-07-03 20:25 ` Christoph Hellwig
  0 siblings, 1 reply; 18+ messages in thread
From: Herbert Poetzl @ 2004-07-03 20:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel


Hi Andrew!

stumbled over the following detail ...

usually when somebody tries to modify an inode,
notify_change() calls inode_change_ok() to verify
the user's permissions ... now it seems that
somewhere around 2.5.41, a patch similar to this
one was included into the mainline, and remained
almost unmodified ...

http://www.uwsg.iu.edu/hypermail/linux/kernel/0210.1/1002.html

this probably unintentionally circumvents the 
inode_change_ok() check, so that now any user
can modify inodes of the procfs. 

example:

  $ chmod a-rwx /proc/cmdline

the following patch hopefully fixes this, so
please consider for inclusion ...

TIA,
Herbert


diff -NurpP --minimal linux-2.6.7/fs/proc/generic.c linux-2.6.7-fix/fs/proc/generic.c
--- linux-2.6.7/fs/proc/generic.c	2004-06-16 07:20:26.000000000 +0200
+++ linux-2.6.7-fix/fs/proc/generic.c	2004-07-03 21:50:30.000000000 +0200
@@ -241,8 +241,20 @@ static int proc_notify_change(struct den
 	return error;
 }
 
+static int proc_setattr(struct dentry *dentry, struct iattr *iattr)
+{
+        struct inode *inode = dentry->d_inode;
+        int error;
+
+        error = inode_change_ok(inode, iattr);
+        if (error)
+                return error;
+	error = proc_notify_change(dentry, iattr);
+	return error;
+}
+
 static struct inode_operations proc_file_inode_operations = {
-	.setattr	= proc_notify_change,
+	.setattr	= proc_setattr,
 };
 
 /*
@@ -472,7 +484,7 @@ static struct file_operations proc_dir_o
  */
 static struct inode_operations proc_dir_inode_operations = {
 	.lookup		= proc_lookup,
-	.setattr	= proc_notify_change,
+	.setattr	= proc_setattr,
 };
 
 static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)

^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <2dZjc-7BP-15@gated-at.bofh.it>]

end of thread, other threads:[~2004-07-06  3:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-03 20:22 procfs permissions on 2.6.x Herbert Poetzl
2004-07-03 20:25 ` Christoph Hellwig
2004-07-03 20:35   ` Andrew Morton
2004-07-03 21:04     ` Christoph Hellwig
2004-07-03 21:35       ` Andrew Morton
2004-07-04 21:35         ` viro
2004-07-04 21:55           ` Andrew Morton
2004-07-04 22:13             ` viro
2004-07-04 22:43               ` Andrew Morton
2004-07-06  3:31                 ` Andy Lutomirski
2004-07-05  1:50               ` Clemens Schwaighofer
2004-07-05  1:55                 ` viro
2004-07-05  8:05                 ` Duncan Sands
2004-07-05  8:14                   ` Clemens Schwaighofer
2004-07-04  1:27     ` bert hubert
     [not found] <2dZjc-7BP-15@gated-at.bofh.it>
     [not found] ` <2dZjf-7BP-27@gated-at.bofh.it>
     [not found]   ` <2dZsQ-7GF-23@gated-at.bofh.it>
     [not found]     ` <2dZVV-867-33@gated-at.bofh.it>
     [not found]       ` <2e0oZ-8lm-35@gated-at.bofh.it>
     [not found]         ` <2emSs-6R8-17@gated-at.bofh.it>
     [not found]           ` <2enbS-72q-19@gated-at.bofh.it>
     [not found]             ` <2env9-7li-9@gated-at.bofh.it>
2004-07-04 22:25               ` Andi Kleen
2004-07-04 22:37                 ` FabF
2004-07-04 23:30                   ` Paul Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox