diff mbox

[v3,09/12] binfmt_flat: use clear_user() rather than memset() to clear .bss

Message ID 1468988424-32671-10-git-send-email-nicolas.pitre@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Nicolas Pitre July 20, 2016, 4:20 a.m. UTC
This is needed on systems with a MMU.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Reviewed-by: Greg Ungerer <gerg@linux-m68k.org>
---
 fs/binfmt_flat.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Greg Ungerer July 20, 2016, 7:15 a.m. UTC | #1
On 20/07/16 14:20, Nicolas Pitre wrote:
> This is needed on systems with a MMU.
> 
> Signed-off-by: Nicolas Pitre <nico@linaro.org>
> Reviewed-by: Greg Ungerer <gerg@linux-m68k.org>
> ---
>  fs/binfmt_flat.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
> index 28fc272d9a..0d89830f76 100644
> --- a/fs/binfmt_flat.c
> +++ b/fs/binfmt_flat.c
> @@ -798,10 +798,11 @@ static int load_flat_file(struct linux_binprm * bprm,
>  	flush_icache_range(start_code, end_code);
>  
>  	/* zero the BSS,  BRK and stack areas */
> -	memset((void*)(datapos + data_len), 0, bss_len + 
> +	if (clear_user((void __user *)(datapos + data_len), bss_len + 

nit: this adds a trailing white space                                ^
(Yes, the memset did have this before as well)

Regards
Greg


>  			(memp + memp_size - stack_len -		/* end brk */
>  			libinfo->lib_list[id].start_brk) +	/* start brk */
> -			stack_len);
> +			stack_len))
> +		return -EFAULT;
>  
>  	return 0;
>  err:
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 28fc272d9a..0d89830f76 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -798,10 +798,11 @@  static int load_flat_file(struct linux_binprm * bprm,
 	flush_icache_range(start_code, end_code);
 
 	/* zero the BSS,  BRK and stack areas */
-	memset((void*)(datapos + data_len), 0, bss_len + 
+	if (clear_user((void __user *)(datapos + data_len), bss_len + 
 			(memp + memp_size - stack_len -		/* end brk */
 			libinfo->lib_list[id].start_brk) +	/* start brk */
-			stack_len);
+			stack_len))
+		return -EFAULT;
 
 	return 0;
 err: