Skip to content

Commit

Permalink
[PATCH] binfmt: fix uaccess handling
Browse files Browse the repository at this point in the history
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Heiko Carstens authored and Linus Torvalds committed Dec 7, 2006
1 parent fec1d01 commit 841d5fb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fs/binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
if (interp_aout) {
argv = sp + 2;
envp = argv + argc + 1;
__put_user((elf_addr_t)(unsigned long)argv, sp++);
__put_user((elf_addr_t)(unsigned long)envp, sp++);
if (__put_user((elf_addr_t)(unsigned long)argv, sp++) ||
__put_user((elf_addr_t)(unsigned long)envp, sp++))
return -EFAULT;
} else {
argv = sp;
envp = argv + argc + 1;
Expand All @@ -254,7 +255,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
p = current->mm->arg_end = current->mm->arg_start;
while (argc-- > 0) {
size_t len;
__put_user((elf_addr_t)p, argv++);
if (__put_user((elf_addr_t)p, argv++))
return -EFAULT;
len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
return 0;
Expand All @@ -265,7 +267,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
current->mm->arg_end = current->mm->env_start = p;
while (envc-- > 0) {
size_t len;
__put_user((elf_addr_t)p, envp++);
if (__put_user((elf_addr_t)p, envp++))
return -EFAULT;
len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
return 0;
Expand Down

0 comments on commit 841d5fb

Please sign in to comment.