mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	jarod@redhat.com, jstancek@redhat.com
Subject: Re: [PATCH 2/2] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline
Date: Thu, 28 May 2015 01:14:35 +0300	[thread overview]
Message-ID: <20150527221435.GG17625@uranus.sw.swsoft.com> (raw)
In-Reply-To: <20150527214953.GB12863@p183.telecom.by>

On Thu, May 28, 2015 at 12:49:53AM +0300, Alexey Dobriyan wrote:
...
> -static int proc_pid_cmdline(struct seq_file *m, struct pid_namespace *ns,
> -			    struct pid *pid, struct task_struct *task)
> +static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
> +				     size_t _count, loff_t *pos)
>  {
> +	struct task_struct *tsk;
> +	struct mm_struct *mm;
> +	char *page;
> +	unsigned long count = _count;
> +	unsigned long arg_start, arg_end, env_start, env_end;
> +	unsigned long len1, len2, len;
> +	unsigned long p;
> +	char c;
> +	ssize_t rv;
> +
> +	BUG_ON(*pos < 0);
> +
> +	tsk = get_proc_task(file_inode(file));
> +	if (!tsk)
> +		return -ESRCH;
> +	mm = get_task_mm(tsk);
> +	put_task_struct(tsk);
> +	if (!mm)
> +		return 0;
> +	/* Check if process spawned far enough to have cmdline. */
> +	if (!mm->env_end) {
> +		rv = 0;
> +		goto out_mmput;
> +	}
> +
> +	page = (char *)__get_free_page(GFP_TEMPORARY);
> +	if (!page) {
> +		rv = -ENOMEM;
> +		goto out_mmput;
> +	}
> +
> +	down_read(&mm->mmap_sem);
> +	arg_start = mm->arg_start;
> +	arg_end = mm->arg_end;
> +	env_start = mm->env_start;
> +	env_end = mm->env_end;
> +	up_read(&mm->mmap_sem);

Could you please explain why this down/up is needed?
(the rest is hard to review at night :)

  reply	other threads:[~2015-05-27 22:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 21:47 [PATCH 1/2] prctl: more prctl(PR_SET_MM_*) checks Alexey Dobriyan
2015-05-27 21:49 ` [PATCH 2/2] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline Alexey Dobriyan
2015-05-27 22:14   ` Cyrill Gorcunov [this message]
2015-05-27 22:29     ` Alexey Dobriyan
2015-05-27 22:48       ` Cyrill Gorcunov
2015-05-27 23:12         ` Alexey Dobriyan
2015-05-28  6:59           ` Cyrill Gorcunov
2015-05-28 11:14             ` Alexey Dobriyan
2015-05-28 11:35               ` Cyrill Gorcunov
2015-05-28 12:00                 ` Cyrill Gorcunov
2015-05-28 11:57   ` Jan Stancek
2015-05-27 22:02 ` [PATCH 1/2] prctl: more prctl(PR_SET_MM_*) checks Cyrill Gorcunov
2015-05-27 22:12   ` Alexey Dobriyan
2015-05-27 22:20     ` Cyrill Gorcunov

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=20150527221435.GG17625@uranus.sw.swsoft.com \
    --to=gorcunov@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jarod@redhat.com \
    --cc=jstancek@redhat.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®