public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] Allow access to /proc/$PID/fd after setuid()
@ 2007-02-01 15:04 Alexey Dobriyan
  2007-02-01 15:16 ` [Devel] " Kirill Korotaev
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2007-02-01 15:04 UTC (permalink / raw)
  To: akpm; +Cc: pasky, linux-kernel, devel

/proc/$PID/fd has r-x------ permissions, so if process does setuid(), it
will not be able to access /proc/*/fd/. This breaks fstatat() emulation
in glibc.

open("foo", O_RDONLY|O_DIRECTORY)       = 4
setuid32(65534)                         = 0
stat64("/proc/self/fd/4/bar", 0xbfafb298) = -1 EACCES (Permission denied)

Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
---

 fs/proc/base.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1413,11 +1413,27 @@ static struct file_operations proc_fd_op
 	.readdir	= proc_readfd,
 };
 
+static int proc_fd_permission(struct inode *inode, int mask, struct nameidata *nd)
+{
+	struct task_struct *tsk;
+	int rv;
+
+	rv = generic_permission(inode, mask, NULL);
+	if (rv == 0)
+		return 0;
+	tsk = get_proc_task(inode);
+	if (tsk == current)
+		rv = 0;
+	put_task_struct(tsk);
+	return rv;
+}
+
 /*
  * proc directories can do almost nothing..
  */
 static struct inode_operations proc_fd_inode_operations = {
 	.lookup		= proc_lookupfd,
+	.permission	= proc_fd_permission,
 	.setattr	= proc_setattr,
 };
 


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

* Re: [Devel] [RFC] Allow access to /proc/$PID/fd after setuid()
  2007-02-01 15:04 [RFC] Allow access to /proc/$PID/fd after setuid() Alexey Dobriyan
@ 2007-02-01 15:16 ` Kirill Korotaev
  0 siblings, 0 replies; 2+ messages in thread
From: Kirill Korotaev @ 2007-02-01 15:16 UTC (permalink / raw)
  To: devel; +Cc: akpm, pasky, linux-kernel

Acked-By: Kirill Korotaev <dev@openvz.org>

> /proc/$PID/fd has r-x------ permissions, so if process does setuid(), it
> will not be able to access /proc/*/fd/. This breaks fstatat() emulation
> in glibc.
> 
> open("foo", O_RDONLY|O_DIRECTORY)       = 4
> setuid32(65534)                         = 0
> stat64("/proc/self/fd/4/bar", 0xbfafb298) = -1 EACCES (Permission denied)
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
> ---
> 
>  fs/proc/base.c |   16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1413,11 +1413,27 @@ static struct file_operations proc_fd_op
>  	.readdir	= proc_readfd,
>  };
>  
> +static int proc_fd_permission(struct inode *inode, int mask, struct nameidata *nd)
> +{
> +	struct task_struct *tsk;
> +	int rv;
> +
> +	rv = generic_permission(inode, mask, NULL);
> +	if (rv == 0)
> +		return 0;
> +	tsk = get_proc_task(inode);
> +	if (tsk == current)
> +		rv = 0;
> +	put_task_struct(tsk);
> +	return rv;
> +}
> +
>  /*
>   * proc directories can do almost nothing..
>   */
>  static struct inode_operations proc_fd_inode_operations = {
>  	.lookup		= proc_lookupfd,
> +	.permission	= proc_fd_permission,
>  	.setattr	= proc_setattr,
>  };
>  
> 
> _______________________________________________
> Devel mailing list
> Devel@openvz.org
> https://openvz.org/mailman/listinfo/devel
> 


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

end of thread, other threads:[~2007-02-01 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-01 15:04 [RFC] Allow access to /proc/$PID/fd after setuid() Alexey Dobriyan
2007-02-01 15:16 ` [Devel] " Kirill Korotaev

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