linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] subsystem: proc filesystem
@ 2012-12-13 13:15 tux2002
  2012-12-13 16:22 ` Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: tux2002 @ 2012-12-13 13:15 UTC (permalink / raw)
  To: linux-kernel



This patch strengthens file permissions of pid record in proc filesystem. When pid and pidentry records created, his permissions strengthens by creator umask.



./scripts/get_maintainer.pl: No supported VCS found.  Add --nogit to options?

Using a git repository produces better results.

Try Linus Torvalds' latest git repository using:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

linux-kernel@vger.kernel.org (open list)





---

--- linux-3.7/fs/proc/base.c.orig	2012-12-11 06:30:57.000000000 +0300

+++ linux-3.7/fs/proc/base.c	2012-12-13 16:48:59.000000000 +0300

@@ -2035,6 +2035,7 @@ static struct dentry *proc_pident_instan

 

 	ei = PROC_I(inode);

 	inode->i_mode = p->mode;

+	inode->i_mode &= ~(mode_t) get_current()->fs->umask;

 	if (S_ISDIR(inode->i_mode))

 		set_nlink(inode, 2);	/* Use getattr to fix if necessary */

 	if (p->iop)

@@ -2856,7 +2857,8 @@ static struct dentry *proc_pid_instantia

 	if (!inode)

 		goto out;

 

-	inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;

+	inode->i_mode = S_IFDIR|S_IRUGO|S_IWUSR|S_IXUGO;

+	inode->i_mode &= ~(mode_t) get_current()->fs->umask;

 	inode->i_op = &proc_tgid_base_inode_operations;

 	inode->i_fop = &proc_tgid_base_operations;

 	inode->i_flags|=S_IMMUTABLE;

---

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] subsystem: proc filesystem
  2012-12-13 13:15 [PATCH] subsystem: proc filesystem tux2002
@ 2012-12-13 16:22 ` Al Viro
  2012-12-16 12:02   ` Re: [PATCH] subsystem: pr­oc filesystem tux2002
  0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2012-12-13 16:22 UTC (permalink / raw)
  To: tux2002; +Cc: linux-kernel

On Thu, Dec 13, 2012 at 05:15:44PM +0400, tux2002@front.ru wrote:
> 
> 
> This patch strengthens file permissions of pid record in proc filesystem. When pid and pidentry records created, his permissions strengthens by creator umask.
> 

NAK.  "Creator" in this case means "whoever had done lookup first".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] subsystem: pr­oc filesystem
  2012-12-13 16:22 ` Al Viro
@ 2012-12-16 12:02   ` tux2002
  2012-12-16 14:28     ` Re: [PATCH] subsystem: pr??oc filesystem Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: tux2002 @ 2012-12-16 12:02 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

Not, this permissions saved for all users for later, check please.



Чтв 13 Дек 2012 20:22:10 +0400, Al Viro <viro@ZenIV.linux.org.uk> написал:

> On Thu, Dec 13, 2012 at 05:15:44PM +0400, tux2002@front.ru wrote:

> > 

> > 

> > This patch strengthens file permissions of pid record in proc filesystem. When pid and pidentry records created, his permissions strengthens by creator umask.

> > 

> 

> NAK.  "Creator" in this case means "whoever had done lookup first".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] subsystem: pr??oc filesystem
  2012-12-16 12:02   ` Re: [PATCH] subsystem: pr­oc filesystem tux2002
@ 2012-12-16 14:28     ` Al Viro
  0 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2012-12-16 14:28 UTC (permalink / raw)
  To: tux2002; +Cc: linux-kernel

On Sun, Dec 16, 2012 at 04:02:03PM +0400, tux2002@front.ru wrote:
> Not, this permissions saved for all users for later, check please.

... and that's why it's bogus.  umask of whoever had done lookup for
/proc/<something> affects everybody else.  For as long as the thing stays
in dcache.  At which point it's up for grabs (in that sense) again.
Do (umask 777; ls -l /proc) with your kernel and watch the results.
Note that you don't need to be root to cause that - anyone can do it.

Realize that dentries and inodes in /proc/<pid>/* are created on demand
whenever somebody does a lookup.  So running ps(1) suddenly makes you
a creator of a bunch of those.  Unless somebody else had done ps(1) (or
ls -l /proc, or...) first.  Basing any security decisions on _that_ is
insane.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-16 14:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13 13:15 [PATCH] subsystem: proc filesystem tux2002
2012-12-13 16:22 ` Al Viro
2012-12-16 12:02   ` Re: [PATCH] subsystem: pr­oc filesystem tux2002
2012-12-16 14:28     ` Re: [PATCH] subsystem: pr??oc filesystem Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).