From: ebiederm@xmission.com (Eric W. Biederman)
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
pavel@ucw.cz
Subject: Re: [PATCH] procfs: make /proc style symlinks behave like "normal" symlinks
Date: Thu, 19 Nov 2009 09:07:16 -0800 [thread overview]
Message-ID: <m14ooq5tq3.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <1258638251-20034-1-git-send-email-jlayton@redhat.com> (Jeff Layton's message of "Thu\, 19 Nov 2009 08\:44\:11 -0500")
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;
> +}
next prev parent reply other threads:[~2009-11-19 17:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-19 13:44 [PATCH] procfs: make /proc style symlinks behave like "normal" symlinks Jeff Layton
2009-11-19 17:07 ` Eric W. Biederman [this message]
2009-11-19 18:28 ` Jeff Layton
2009-11-19 18:57 ` Eric W. Biederman
2009-11-19 19:35 ` Jeff Layton
2009-11-19 21:31 ` Eric W. Biederman
2009-11-19 21:39 ` Pavel Machek
2009-11-19 21:56 ` Eric W. Biederman
2009-11-19 22:30 ` Pavel Machek
2009-11-20 9:31 ` Miklos Szeredi
2009-11-20 9:51 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m14ooq5tq3.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox