Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1449169

[PATCH v5 09/15] binfmt_flat: use clear_user() rather than memset() to clear .bss

From Nicolas Pitre <nicolas.pitre@linaro.org>
Newsgroups linux.kernel
Subject [PATCH v5 09/15] binfmt_flat: use clear_user() rather than memset() to clear .bss
Date 2016-07-24 17:40 +0200
Message-ID <rYtFx-19R-35@gated-at.bofh.it> (permalink)
References <rYtFw-19R-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 63756ca6a7..92c1530a2c 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -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:
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 00/15] allow BFLT executables on systems with a MMU Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-07-24 17:40 +0200
  [PATCH v5 09/15] binfmt_flat: use clear_user() rather than memset() to clear .bss Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-07-24 17:40 +0200
  [PATCH v5 02/15] binfmt_flat: convert printk invocations to their modern form Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-07-24 17:40 +0200
  [PATCH v5 04/15] elf_fdpic_transfer_args_to_stack(): make it generic Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-07-24 17:40 +0200
  [PATCH v5 13/15] m68k: fix bFLT executable running on MMU enabled systems Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-07-24 17:40 +0200

csiph-web