From: Tejun Heo <tj@kernel.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
Andrew Morton <akpm@linux-foundation.org>,
Pavel Emelyanov <xemul@parallels.com>,
linux-kernel@vger.kernel.org,
James Bottomley <jbottomley@parallels.com>,
containers@lists.osdl.org, Andi Kleen <andi@firstfloor.org>,
Nathan Lynch <ntl@pobox.com>,
LINUXFS-ML <linux-fsdevel@vger.kernel.org>,
Zan Lynx <zlynx@acm.org>, Daniel Lezcano <dlezcano@fr.ibm.com>,
Vasiliy Kulikov <segoon@openwall.com>
Subject: Re: [RFC] fs, proc: Introduce the /proc/<pid>/map_files/ directory v2
Date: Fri, 26 Aug 2011 16:06:20 +0200 [thread overview]
Message-ID: <20110826140620.GE2632@htj.dyndns.org> (raw)
In-Reply-To: <20110826131620.GM3903@sun>
Hello, Cyrill.
On Fri, Aug 26, 2011 at 05:16:20PM +0400, Cyrill Gorcunov wrote:
> Index: linux-2.6.git/fs/proc/base.c
> ===================================================================
> --- linux-2.6.git.orig/fs/proc/base.c
> +++ linux-2.6.git/fs/proc/base.c
> @@ -165,7 +165,7 @@ static int get_task_root(struct task_str
> return result;
> }
>
> -static int proc_cwd_link(struct inode *inode, struct path *path)
> +static int proc_cwd_link(struct dentry *dentry, struct inode *inode, struct path *path)
I don't think it's necessary to pass around both @dentry and @inode.
@inode can always be dereferenced from @dentry.
> +static int map_name_to_addr(const unsigned char *name, unsigned long *start, unsigned long *end)
> +{
> + int ret = -1;
Very minor but functions returning -1 for error bugs me a bit. Maybe
-EINVAL is better? Not a big deal either way.
> +static int map_files_d_revalidate(struct dentry *dentry, struct nameidata *nd)
> +{
...
> + if (vma) {
> + if (task_dumpable(task)) {
> + rcu_read_lock();
> + cred = __task_cred(task);
> + inode->i_uid = cred->euid;
> + inode->i_gid = cred->egid;
> + rcu_read_unlock();
> + } else {
> + inode->i_uid = 0;
> + inode->i_gid = 0;
> + }
> + security_task_to_inode(task, inode);
> + return 1;
Another minor point. Maybe it would be nice to factor this into a
function and share it w/ the fd one (and maybe sprinkle some comments
while at it too :)
> +struct map_files_info {
> + struct file *file;
> + unsigned char name[16+16+2]; /* max: %016lx-%016lx\0 */
> + unsigned long len;
> +};
That's slightly above 50 bytes.
> +static struct dentry *proc_map_files_lookup(struct inode *dir,
> + struct dentry *dentry, struct nameidata *nd)
> +{
> + unsigned long vm_start, vm_end;
> + struct task_struct *task;
> + struct vm_area_struct *vma;
> + struct mm_struct *mm;
> + struct dentry *result;
> +
> + result = ERR_PTR(-ENOENT);
> + task = get_proc_task(dir);
> + if (!task)
> + goto out_no_task;
> +
> + result = ERR_PTR(-EPERM);
> + if (!ptrace_may_access(task, PTRACE_MODE_READ));
> + goto out_no_mm;
> +
> + result = ERR_PTR(-ENOENT);
> + if (map_name_to_addr(dentry->d_name.name,
> + &vm_start, &vm_end))
> + goto out_no_mm;
Another nitpick: Maybe factor out the above three steps?
> +static int proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
> +{
...
> + if (nr_files) {
> + info = kmalloc(nr_files * sizeof(*info), GFP_KERNEL);
I think we can just put this on stack.
All my comments are pretty cosmetic, so it generally looks good to me.
Andrew, what do you think?
Thanks.
--
tejun
next prev parent reply other threads:[~2011-08-26 14:06 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-24 8:53 [RFC] fs, proc: Introduce the /proc/<pid>/map_files/ directory v2 Cyrill Gorcunov
2011-08-24 9:21 ` Pekka Enberg
2011-08-24 9:33 ` Pavel Emelyanov
2011-08-24 9:34 ` Tejun Heo
2011-08-24 9:37 ` Cyrill Gorcunov
2011-08-24 9:41 ` Cyrill Gorcunov
2011-08-24 11:18 ` Vasiliy Kulikov
2011-08-24 11:31 ` Cyrill Gorcunov
2011-08-25 8:29 ` Cyrill Gorcunov
2011-08-25 17:01 ` Tejun Heo
2011-08-25 17:05 ` Pavel Emelyanov
2011-08-25 17:21 ` Cyrill Gorcunov
2011-08-25 17:25 ` Pavel Emelyanov
2011-08-25 17:27 ` Tejun Heo
2011-08-25 17:34 ` Cyrill Gorcunov
2011-08-25 17:07 ` Cyrill Gorcunov
2011-08-25 20:54 ` Tejun Heo
2011-08-25 21:12 ` Tejun Heo
2011-08-25 21:34 ` Cyrill Gorcunov
2011-08-25 21:39 ` Tejun Heo
2011-08-26 6:58 ` Cyrill Gorcunov
2011-08-26 11:29 ` Cyrill Gorcunov
2011-08-26 12:28 ` Kirill A. Shutemov
2011-08-26 12:39 ` Cyrill Gorcunov
2011-08-26 13:16 ` Cyrill Gorcunov
2011-08-26 14:06 ` Tejun Heo [this message]
2011-08-26 14:23 ` Kirill A. Shutemov
2011-08-26 14:27 ` Tejun Heo
2011-08-25 17:11 ` Cyrill Gorcunov
2011-08-25 17:36 ` Vasiliy Kulikov
2011-08-25 17:39 ` Cyrill Gorcunov
2011-08-25 17:54 ` Vasiliy Kulikov
2011-08-25 18:13 ` Cyrill Gorcunov
2011-08-24 15:05 ` Zan Lynx
2011-08-24 15:19 ` Pavel Emelyanov
2011-08-24 17:36 ` Andi Kleen
2011-08-25 6:42 ` Pavel Emelyanov
2011-08-25 14:04 ` Andi Kleen
2011-08-25 14:30 ` Cyrill Gorcunov
2011-08-25 14:47 ` Pavel Emelyanov
2011-08-24 15:22 ` Cyrill Gorcunov
2011-09-13 14:14 ` Pavel Machek
2011-09-13 14:20 ` Pavel Emelyanov
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=20110826140620.GE2632@htj.dyndns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=containers@lists.osdl.org \
--cc=dlezcano@fr.ibm.com \
--cc=gorcunov@gmail.com \
--cc=jbottomley@parallels.com \
--cc=kirill@shutemov.name \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntl@pobox.com \
--cc=segoon@openwall.com \
--cc=xemul@parallels.com \
--cc=zlynx@acm.org \
/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;
as well as URLs for NNTP newsgroup(s).