All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, bookjovi@gmail.com,
	kosaki.motohiro@jp.fujitsu.com, wilsons@start.ca
Subject: Re: + proc-put-check_mem_permission-before-__get_free_page-in-mem_read.patch added to -mm tree
Date: Tue, 26 Apr 2011 01:01:16 +0300	[thread overview]
Message-ID: <20110425220116.GA22006@p183> (raw)
In-Reply-To: <201104252011.p3PKBFTD005857@imap1.linux-foundation.org>

On Mon, Apr 25, 2011 at 01:11:15PM -0700, akpm@linux-foundation.org wrote:
> Subject: proc: put check_mem_permission before __get_free_page in mem_read
> From: Jovi Zhang <bookjovi@gmail.com>
> 
> It would be better to put check_mem_permission() before __get_free_page()
> in mem_read(), to be same as mem_write().

This can be done even more straightforward if you put task_struct right after
it isn't needed.

> --- a/fs/proc/base.c~proc-put-check_mem_permission-before-__get_free_page-in-mem_read
> +++ a/fs/proc/base.c
> @@ -831,23 +831,21 @@ static ssize_t mem_read(struct file * fi
>  	if (!task)
>  		goto out_no_task;
>  
> -	ret = -ENOMEM;
> -	page = (char *)__get_free_page(GFP_TEMPORARY);
> -	if (!page)
> -		goto out;
> -
>  	mm = check_mem_permission(task);
>  	ret = PTR_ERR(mm);
>  	if (IS_ERR(mm))
> -		goto out_free;
> +		goto out_task;
>  
>  	ret = -EIO;
> - 
>  	if (file->private_data != (void*)((long)current->self_exec_id))
> -		goto out_put;
> +		goto out_mm;
> +
> +	ret = -ENOMEM;
> +	page = (char *)__get_free_page(GFP_TEMPORARY);
> +	if (!page)
> +		goto out_mm;
>  
>  	ret = 0;
> - 
>  	while (count > 0) {
>  		int this_len, retval;
>  
> @@ -870,12 +868,10 @@ static ssize_t mem_read(struct file * fi
>  		count -= retval;
>  	}
>  	*ppos = src;
> -
> -out_put:
> -	mmput(mm);
> -out_free:
>  	free_page((unsigned long) page);
> -out:
> +out_mm:
> +	mmput(mm);
> +out_task:
>  	put_task_struct(task);
>  out_no_task:
>  	return ret;

      reply	other threads:[~2011-04-25 22:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-25 20:11 + proc-put-check_mem_permission-before-__get_free_page-in-mem_read.patch added to -mm tree akpm
2011-04-25 22:01 ` Alexey Dobriyan [this message]

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=20110425220116.GA22006@p183 \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bookjovi@gmail.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wilsons@start.ca \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.