binfmt_flat: use clear_user() rather than memset() to clear .bss
authorNicolas Pitre <nicolas.pitre@linaro.org>
Sun, 24 Jul 2016 15:30:23 +0000 (11:30 -0400)
committerGreg Ungerer <gerg@linux-m68k.org>
Thu, 28 Jul 2016 03:29:11 +0000 (13:29 +1000)
This is needed on systems with a MMU.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Reviewed-by: Greg Ungerer <gerg@linux-m68k.org>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
fs/binfmt_flat.c

index 8e812d7a62e00aa42759b6749e7f23bd19efe878..eb747a266537970633ca5bedac758574325831d3 100644 (file)
@@ -795,10 +795,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 +
-                       (memp + memp_size - stack_len -         /* end brk */
-                       libinfo->lib_list[id].start_brk) +      /* start brk */
-                       stack_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))
+               return -EFAULT;
 
        return 0;
 err: