The ELF loader needs to zero out part of the BSS explicitly. It also needs to read the program arguments directly from user memory when dumping a core file. In both cases we only have the address of the memory mapping / arguments to access, and need to create a valid user pointer to perform the uaccess.
uaddr_to_user_ptr_safe() should no longer be used for that purpose. Instead, we use make_user_ptr_for_{read,write}_uaccess() to create a user pointer with appropriate bounds and permissions (in PCuABI).
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com --- fs/binfmt_elf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 1d82465cb9e9..564aebce488c 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -144,7 +144,8 @@ static int padzero(unsigned long elf_bss) nbyte = ELF_PAGEOFFSET(elf_bss); if (nbyte) { nbyte = ELF_MIN_ALIGN - nbyte; - if (clear_user(uaddr_to_user_ptr_safe(elf_bss), nbyte)) + if (clear_user(make_user_ptr_for_write_uaccess(elf_bss, nbyte), + nbyte)) return -EFAULT; } return 0; @@ -1132,11 +1133,15 @@ static int load_elf_binary(struct linux_binprm *bprm) goto out_free_dentry; nbyte = ELF_PAGEOFFSET(elf_bss); if (nbyte) { + void __user *uptr; + nbyte = ELF_MIN_ALIGN - nbyte; if (nbyte > elf_brk - elf_bss) nbyte = elf_brk - elf_bss; - if (clear_user(uaddr_to_user_ptr_safe(elf_bss + - load_bias), nbyte)) { + + uptr = make_user_ptr_for_write_uaccess( + elf_bss + load_bias, nbyte); + if (clear_user(uptr, nbyte)) { /* * This bss-zeroing can fail if the ELF * file specifies odd protections. So @@ -1674,7 +1679,8 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, if (len >= ELF_PRARGSZ) len = ELF_PRARGSZ-1; if (copy_from_user(&psinfo->pr_psargs, - uaddr_to_user_ptr_safe(mm->arg_start), len)) + make_user_ptr_for_read_uaccess(mm->arg_start, len), + len)) return -EFAULT; for(i = 0; i < len; i++) if (psinfo->pr_psargs[i] == 0)