lkml.org 
[lkml]   [2009]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] procfs: make /proc style symlinks behave like "normal" symlinks
From
Date

Nacked-by: "Eric W. Biederman" <ebiederm@xmission.com>

This is broken. If the referenced file is in a different mount namespace
the path returned could point to a completely different path in your
own mount namespace. Even in your own mount namespace this makes the
proc symlinks racy and not guaranteed to return the file of interest.

I don't see any hope of this approach ever working.

Eric


Jeff Layton <jlayton@redhat.com> writes:

> -static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int buflen)
> -{
> - int error = -EACCES;
> - struct inode *inode = dentry->d_inode;
> + struct page *page = NULL;
> struct path path;
> + int error;
>
> /* Are we allowed to snoop on the tasks file descriptors? */
> - if (!proc_fd_access_allowed(inode))
> + if (!proc_fd_access_allowed(inode)) {
> + pathname = ERR_PTR(-EACCES);
> goto out;
> + }
>
> error = PROC_I(inode)->op.proc_get_link(inode, &path);
> - if (error)
> + if (error) {
> + pathname = ERR_PTR(error);
> goto out;
> + }
> +
> + page = alloc_page(GFP_HIGHUSER);
> + if (!page) {
> + pathname = ERR_PTR(-ENOMEM);
> + goto out_path_put;
> + }
> +
> + pathname = kmap(page);
> + pathname = d_path(&path, pathname, PAGE_SIZE);

This is just nonsense.


> + if (IS_ERR(pathname)) {
> + kunmap(page);
> + __free_page(page);
> + page = NULL;
> + }
>
> - error = do_proc_readlink(&path, buffer, buflen);
> +out_path_put:
> path_put(&path);
> out:
> - return error;
> + nd_set_link(nd, pathname);
> + return page;
> +}


\
 
 \ /
  Last update: 2009-11-19 18:09    [W:0.061 / U:1.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site