fs, kernel: permit disabling the uselib syscall
authorJosh Triplett <josh@joshtriplett.org>
Thu, 3 Apr 2014 21:48:27 +0000 (14:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Apr 2014 23:21:05 +0000 (16:21 -0700)
uselib hasn't been used since libc5; glibc does not use it.  Support
turning it off.

When disabled, also omit the load_elf_library implementation from
binfmt_elf.c, which only uselib invokes.

bloat-o-meter:
add/remove: 0/4 grow/shrink: 0/1 up/down: 0/-785 (-785)
function                                     old     new   delta
padzero                                       39      36      -3
uselib_flags                                  20       -     -20
sys_uselib                                   168       -    -168
SyS_uselib                                   168       -    -168
load_elf_library                             426       -    -426

The new CONFIG_USELIB defaults to `y'.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/binfmt_elf.c
fs/exec.c
init/Kconfig
kernel/sys_ni.c

index 67be2951b98a4e6b5d6b28508f9b37fad6b06607..0f59799fa1050fc6e061f0f7273850bbc1297a0a 100644 (file)
 #endif
 
 static int load_elf_binary(struct linux_binprm *bprm);
-static int load_elf_library(struct file *);
 static unsigned long elf_map(struct file *, unsigned long, struct elf_phdr *,
                                int, int, unsigned long);
 
+#ifdef CONFIG_USELIB
+static int load_elf_library(struct file *);
+#else
+#define load_elf_library NULL
+#endif
+
 /*
  * If we don't support core dumping, then supply a NULL so we
  * don't even try.
@@ -1005,6 +1010,7 @@ out_free_ph:
        goto out;
 }
 
+#ifdef CONFIG_USELIB
 /* This is really simpleminded and specialized - we are loading an
    a.out library that is given an ELF header. */
 static int load_elf_library(struct file *file)
@@ -1083,6 +1089,7 @@ out_free_ph:
 out:
        return error;
 }
+#endif /* #ifdef CONFIG_USELIB */
 
 #ifdef CONFIG_ELF_CORE
 /*
index 4f59402fdda541bd22349aad786a95d12cc6d089..25dfeba6d55f8ce8752fa551fbc823535077ef0e 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -97,6 +97,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt)
        module_put(fmt->module);
 }
 
+#ifdef CONFIG_USELIB
 /*
  * Note that a shared library must be both readable and executable due to
  * security reasons.
@@ -156,6 +157,7 @@ exit:
 out:
        return error;
 }
+#endif /* #ifdef CONFIG_USELIB */
 
 #ifdef CONFIG_MMU
 /*
index e45cc62904b3e967b6c7dd08dc57592d52429cc8..8114a06117e3198f206653ee8d255afcd71e5d37 100644 (file)
@@ -273,6 +273,16 @@ config FHANDLE
          get renamed. Enables open_by_handle_at(2) and name_to_handle_at(2)
          syscalls.
 
+config USELIB
+       bool "uselib syscall"
+       default y
+       help
+         This option enables the uselib syscall, a system call used in the
+         dynamic linker from libc5 and earlier.  glibc does not use this
+         system call.  If you intend to run programs built on libc5 or
+         earlier, you may need to enable this syscall.  Current systems
+         running glibc can safely disable this.
+
 config AUDIT
        bool "Auditing support"
        depends on NET
index 74395a95b7e96e6094e3845400169a937249559e..bc8d1b74a6b95e5b247cf90c0ad5d8cd937745e2 100644 (file)
@@ -152,6 +152,7 @@ cond_syscall(sys_process_vm_readv);
 cond_syscall(sys_process_vm_writev);
 cond_syscall(compat_sys_process_vm_readv);
 cond_syscall(compat_sys_process_vm_writev);
+cond_syscall(sys_uselib);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);