linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs, kernel: Support disabling the uselib syscall
@ 2014-02-21 18:11 Josh Triplett
  2014-02-21 20:16 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Triplett @ 2014-02-21 18:11 UTC (permalink / raw)
  To: Alexander Viro, Paul E. McKenney, Frederic Weisbecker,
	Andrew Morton, Josh Triplett, Paul Gortmaker, Mike Frysinger,
	Kyungsik Lee, Jiri Slaby, Eric Paris, Dwight Engen, linux-fsdevel,
	linux-kernel

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

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
 fs/binfmt_elf.c | 9 ++++++++-
 fs/exec.c       | 2 ++
 init/Kconfig    | 9 +++++++++
 kernel/sys_ni.c | 1 +
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 67be295..0f59799 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -46,10 +46,15 @@
 #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
 /*
diff --git a/fs/exec.c b/fs/exec.c
index 3d78fcc..48eb039 100644
--- 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
 /*
diff --git a/init/Kconfig b/init/Kconfig
index 009a797..d205502 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -273,6 +273,15 @@ config FHANDLE
 	  get renamed. Enables open_by_handle_at(2) and name_to_handle_at(2)
 	  syscalls.
 
+config USELIB
+	bool "uselib syscall"
+	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
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 7078052..4177e3e 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -151,6 +151,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);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs, kernel: Support disabling the uselib syscall
  2014-02-21 18:11 [PATCH] fs, kernel: Support disabling the uselib syscall Josh Triplett
@ 2014-02-21 20:16 ` Andrew Morton
  2014-02-21 20:44   ` Josh Triplett
  2014-02-21 21:00   ` [PATCHv2] " Josh Triplett
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2014-02-21 20:16 UTC (permalink / raw)
  To: Josh Triplett
  Cc: Alexander Viro, Paul E. McKenney, Frederic Weisbecker,
	Paul Gortmaker, Mike Frysinger, Kyungsik Lee, Jiri Slaby,
	Eric Paris, Dwight Engen, linux-fsdevel, linux-kernel

On Fri, 21 Feb 2014 10:11:06 -0800 Josh Triplett <josh@joshtriplett.org> wrote:

> 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 patch disables CONFIG_USELIB by default.  This important decision
should be mentioned and justified in the changelog, please.

> +#ifdef CONFIG_USELIB

I wonder if CONFIG_SYS_USELIB would be a better identifier.  We haven't
done anything consistent here.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs, kernel: Support disabling the uselib syscall
  2014-02-21 20:16 ` Andrew Morton
@ 2014-02-21 20:44   ` Josh Triplett
  2014-02-21 21:00   ` [PATCHv2] " Josh Triplett
  1 sibling, 0 replies; 4+ messages in thread
From: Josh Triplett @ 2014-02-21 20:44 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Alexander Viro, Paul E. McKenney, Frederic Weisbecker,
	Paul Gortmaker, Mike Frysinger, Kyungsik Lee, Jiri Slaby,
	Eric Paris, Dwight Engen, Dave Hansen, linux-fsdevel,
	linux-kernel

On Fri, Feb 21, 2014 at 12:16:27PM -0800, Andrew Morton wrote:
> On Fri, 21 Feb 2014 10:11:06 -0800 Josh Triplett <josh@joshtriplett.org> wrote:
> > 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 patch disables CONFIG_USELIB by default.  This important decision
> should be mentioned and justified in the changelog, please.

Gah, that was not intentional.  Will fix in v2.  I did very
intentionally not make it require CONFIG_EXPERT or CONFIG_EMBEDDED,
since (like CONFIG_BINFMT_AOUT) almost everyone will want it disabled,
but I had intended to make it "default y".

> > +#ifdef CONFIG_USELIB
> 
> I wonder if CONFIG_SYS_USELIB would be a better identifier.  We haven't
> done anything consistent here.

As far as I can tell, there's no use of CONFIG_SYS_* or any other
consistent prefix for configuring out syscalls; all such symbols appear
unprefixed.  I think it would make sense to have a single common menu
and prefix for configuring out unused syscalls, but given the large
number of existing Kconfig options for that, I think that change ought
to occur as a separate patch series that isn't also trying to add a new
such option.

Perhaps Dave Hansen (CCed) might be interested in incorporating such a
change into his ongoing kconfig consolidation and reorganization?

- Josh Triplett

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv2] fs, kernel: Support disabling the uselib syscall
  2014-02-21 20:16 ` Andrew Morton
  2014-02-21 20:44   ` Josh Triplett
@ 2014-02-21 21:00   ` Josh Triplett
  1 sibling, 0 replies; 4+ messages in thread
From: Josh Triplett @ 2014-02-21 21:00 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Alexander Viro, Paul E. McKenney, Frederic Weisbecker,
	Paul Gortmaker, Mike Frysinger, Kyungsik Lee, Jiri Slaby,
	Eric Paris, Dwight Engen, linux-fsdevel, linux-kernel

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 as part of
the binfmt, 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

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
v2: Add "default y", unintentionally omitted from the first patch.

Andrew, can you please replace the patch in -mm with this one?

 fs/binfmt_elf.c |  9 ++++++++-
 fs/exec.c       |  2 ++
 init/Kconfig    | 10 ++++++++++
 kernel/sys_ni.c |  1 +
 4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 67be295..0f59799 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -46,10 +46,15 @@
 #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
 /*
diff --git a/fs/exec.c b/fs/exec.c
index 3d78fcc..48eb039 100644
--- 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
 /*
diff --git a/init/Kconfig b/init/Kconfig
index 009a797..7f295a3 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 7078052..4177e3e 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -151,6 +151,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);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-21 21:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-21 18:11 [PATCH] fs, kernel: Support disabling the uselib syscall Josh Triplett
2014-02-21 20:16 ` Andrew Morton
2014-02-21 20:44   ` Josh Triplett
2014-02-21 21:00   ` [PATCHv2] " Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).