Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Mar 2017 23:47:20 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315337 - head/libexec/rtld-elf
Message-ID:  <201703152347.v2FNlKws013824@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Mar 15 23:47:19 2017
New Revision: 315337
URL: https://svnweb.freebsd.org/changeset/base/315337

Log:
  Disable LD_BIND_NOT for setugid processes.
  
  Requested by:	jilles
  Sponsored by:	The FreeBSD Foundation
  MFC after:	2 weeks

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Wed Mar 15 23:08:11 2017	(r315336)
+++ head/libexec/rtld-elf/rtld.c	Wed Mar 15 23:47:19 2017	(r315337)
@@ -417,8 +417,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
     md_abi_variant_hook(aux_info);
 
     ld_bind_now = getenv(_LD("BIND_NOW"));
-    if (ld_bind_now == NULL)
-	    ld_bind_not = getenv(_LD("BIND_NOT")) != NULL;
 
     /* 
      * If the process is tainted, then we un-set the dangerous environment
@@ -429,7 +427,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
     if (!trust) {
 	if (unsetenv(_LD("PRELOAD")) || unsetenv(_LD("LIBMAP")) ||
 	    unsetenv(_LD("LIBRARY_PATH")) || unsetenv(_LD("LIBRARY_PATH_FDS")) ||
-	    unsetenv(_LD("LIBMAP_DISABLE")) ||
+	    unsetenv(_LD("LIBMAP_DISABLE")) || unsetenv(_LD("BIND_NOT")) ||
 	    unsetenv(_LD("DEBUG")) || unsetenv(_LD("ELF_HINTS_PATH")) ||
 	    unsetenv(_LD("LOADFLTR")) || unsetenv(_LD("LIBRARY_PATH_RPATH"))) {
 		_rtld_error("environment corrupt; aborting");
@@ -437,6 +435,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
 	}
     }
     ld_debug = getenv(_LD("DEBUG"));
+    if (ld_bind_now == NULL)
+	    ld_bind_not = getenv(_LD("BIND_NOT")) != NULL;
     libmap_disable = getenv(_LD("LIBMAP_DISABLE")) != NULL;
     libmap_override = getenv(_LD("LIBMAP"));
     ld_library_path = getenv(_LD("LIBRARY_PATH"));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703152347.v2FNlKws013824>