lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue, 26 Apr 2011 01:01:16 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	akpm@...ux-foundation.org
Cc:	linux-kernel@...r.kernel.org, bookjovi@...il.com,
	kosaki.motohiro@...fujitsu.com, wilsons@...rt.ca
Subject: Re: +
 proc-put-check_mem_permission-before-__get_free_page-in-mem_read.patch added
 to -mm tree

On Mon, Apr 25, 2011 at 01:11:15PM -0700, akpm@...ux-foundation.org wrote:
> Subject: proc: put check_mem_permission before __get_free_page in mem_read
> From: Jovi Zhang <bookjovi@...il.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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ