Merge branch 'akpm' (patches from Andrew)
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Nov 2015 05:05:13 +0000 (21:05 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Nov 2015 05:05:13 +0000 (21:05 -0800)
Merge third patch-bomb from Andrew Morton:
 "We're pretty much done over here - I'm still waiting for a nouveau
  merge so I can cleanly finish up Christoph's dma-mapping rework.

   - bunch of small misc stuff

   - fold abs64() into abs(), remove abs64()

   - new_valid_dev() cleanups

   - binfmt_elf_fdpic feature work"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (24 commits)
  fs/binfmt_elf_fdpic.c: provide NOMMU loader for regular ELF binaries
  fs/stat.c: remove unnecessary new_valid_dev() check
  fs/reiserfs/namei.c: remove unnecessary new_valid_dev() check
  fs/nilfs2/namei.c: remove unnecessary new_valid_dev() check
  fs/ncpfs/dir.c: remove unnecessary new_valid_dev() check
  fs/jfs: remove unnecessary new_valid_dev() checks
  fs/hpfs/namei.c: remove unnecessary new_valid_dev() check
  fs/f2fs/namei.c: remove unnecessary new_valid_dev() check
  fs/ext2/namei.c: remove unnecessary new_valid_dev() check
  fs/exofs/namei.c: remove unnecessary new_valid_dev() check
  fs/btrfs/inode.c: remove unnecessary new_valid_dev() check
  fs/9p: remove unnecessary new_valid_dev() checks
  include/linux/kdev_t.h: old/new_valid_dev() can return bool
  include/linux/kdev_t.h: remove unused huge_valid_dev()
  kmap_atomic_to_page() has no users, remove it
  drivers/scsi/cxgbi: fix build with EXTRA_CFLAGS
  dma: remove external references to dma_supported
  Documentation/sysctl/vm.txt: fix misleading code reference of overcommit_memory
  remove abs64()
  kernel.h: make abs() work with 64-bit types
  ...

1  2 
fs/binfmt_elf_fdpic.c

diff --combined fs/binfmt_elf_fdpic.c
index d2b079afed0e627e817d061c8861da4bcb4755df,20462069e513ea7683616bb80d8b93af116155bf..50d15b7b0ca9f11953209bff7e03b8fb40358a57
@@@ -103,19 -103,36 +103,36 @@@ static void __exit exit_elf_fdpic_binfm
  core_initcall(init_elf_fdpic_binfmt);
  module_exit(exit_elf_fdpic_binfmt);
  
- static int is_elf_fdpic(struct elfhdr *hdr, struct file *file)
+ static int is_elf(struct elfhdr *hdr, struct file *file)
  {
        if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0)
                return 0;
        if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN)
                return 0;
-       if (!elf_check_arch(hdr) || !elf_check_fdpic(hdr))
+       if (!elf_check_arch(hdr))
                return 0;
        if (!file->f_op->mmap)
                return 0;
        return 1;
  }
  
+ #ifndef elf_check_fdpic
+ #define elf_check_fdpic(x) 0
+ #endif
+ #ifndef elf_check_const_displacement
+ #define elf_check_const_displacement(x) 0
+ #endif
+ static int is_constdisp(struct elfhdr *hdr)
+ {
+       if (!elf_check_fdpic(hdr))
+               return 1;
+       if (elf_check_const_displacement(hdr))
+               return 1;
+       return 0;
+ }
  /*****************************************************************************/
  /*
   * read the program headers table into memory
@@@ -191,8 -208,18 +208,18 @@@ static int load_elf_fdpic_binary(struc
  
        /* check that this is a binary we know how to deal with */
        retval = -ENOEXEC;
-       if (!is_elf_fdpic(&exec_params.hdr, bprm->file))
+       if (!is_elf(&exec_params.hdr, bprm->file))
                goto error;
+       if (!elf_check_fdpic(&exec_params.hdr)) {
+ #ifdef CONFIG_MMU
+               /* binfmt_elf handles non-fdpic elf except on nommu */
+               goto error;
+ #else
+               /* nommu can only load ET_DYN (PIE) ELF */
+               if (exec_params.hdr.e_type != ET_DYN)
+                       goto error;
+ #endif
+       }
  
        /* read the program header table */
        retval = elf_fdpic_fetch_phdrs(&exec_params, bprm->file);
  
        }
  
-       if (elf_check_const_displacement(&exec_params.hdr))
+       if (is_constdisp(&exec_params.hdr))
                exec_params.flags |= ELF_FDPIC_FLAG_CONSTDISP;
  
        /* perform insanity checks on the interpreter */
        if (interpreter_name) {
                retval = -ELIBBAD;
-               if (!is_elf_fdpic(&interp_params.hdr, interpreter))
+               if (!is_elf(&interp_params.hdr, interpreter))
                        goto error;
  
                interp_params.flags = ELF_FDPIC_FLAG_PRESENT;
  
        retval = -ENOEXEC;
        if (stack_size == 0)
-               goto error;
+               stack_size = 131072UL; /* same as exec.c's default commit */
  
-       if (elf_check_const_displacement(&interp_params.hdr))
+       if (is_constdisp(&interp_params.hdr))
                interp_params.flags |= ELF_FDPIC_FLAG_CONSTDISP;
  
        /* flush all traces of the currently running executable */
        /* there's now no turning back... the old userspace image is dead,
         * defunct, deceased, etc.
         */
-       set_personality(PER_LINUX_FDPIC);
+       if (elf_check_fdpic(&exec_params.hdr))
+               set_personality(PER_LINUX_FDPIC);
+       else
+               set_personality(PER_LINUX);
        if (elf_read_implies_exec(&exec_params.hdr, executable_stack))
                current->personality |= READ_IMPLIES_EXEC;
  
                PAGE_ALIGN(current->mm->start_brk);
  
  #else
 -      /* create a stack and brk area big enough for everyone
 -       * - the brk heap starts at the bottom and works up
 -       * - the stack starts at the top and works down
 -       */
 +      /* create a stack area and zero-size brk area */
        stack_size = (stack_size + PAGE_SIZE - 1) & PAGE_MASK;
        if (stack_size < PAGE_SIZE * 2)
                stack_size = PAGE_SIZE * 2;
  
        current->mm->brk = current->mm->start_brk;
        current->mm->context.end_brk = current->mm->start_brk;
 -      current->mm->context.end_brk +=
 -              (stack_size > PAGE_SIZE) ? (stack_size - PAGE_SIZE) : 0;
        current->mm->start_stack = current->mm->start_brk + stack_size;
  #endif