]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Never expand $ORIGIN in privileged programs
authorAndreas Schwab <schwab@redhat.com>
Mon, 18 Oct 2010 09:46:00 +0000 (11:46 +0200)
committerAndreas Schwab <schwab@redhat.com>
Thu, 21 Oct 2010 09:49:24 +0000 (11:49 +0200)
ChangeLog
elf/dl-load.c

index ccbba2f04bcca8e619c67e2110003dcabbae886f..690f7aa9c0bbaa6c2412d518d67dba8c2c0a358f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-18  Andreas Schwab  <schwab@redhat.com>
+
+       * elf/dl-load.c (is_dst): Remove last parameter.
+       (_dl_dst_count): Ignore $ORIGIN in privileged programs.
+       (_dl_dst_substitute): Likewise.
+
 2010-05-26  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #11640]
index 597193c043463be8ebea5fca6fe7989ec8d25e03..7115c683a5679566529d1f8d03d23fd8f2cc0929 100644 (file)
@@ -169,8 +169,7 @@ local_strdup (const char *s)
 
 
 static size_t
-is_dst (const char *start, const char *name, const char *str,
-       int is_path, int secure)
+is_dst (const char *start, const char *name, const char *str, int is_path)
 {
   size_t len;
   bool is_curly = false;
@@ -199,11 +198,6 @@ is_dst (const char *start, const char *name, const char *str,
           && (!is_path || name[len] != ':'))
     return 0;
 
-  if (__builtin_expect (secure, 0)
-      && ((name[len] != '\0' && (!is_path || name[len] != ':'))
-         || (name != start + 1 && (!is_path || name[-2] != ':'))))
-    return 0;
-
   return len;
 }
 
@@ -218,13 +212,12 @@ _dl_dst_count (const char *name, int is_path)
     {
       size_t len;
 
-      /* $ORIGIN is not expanded for SUID/GUID programs (except if it
-        is $ORIGIN alone) and it must always appear first in path.  */
+      /* $ORIGIN is not expanded for SUID/GUID programs.  */
       ++name;
-      if ((len = is_dst (start, name, "ORIGIN", is_path,
-                        INTUSE(__libc_enable_secure))) != 0
-         || (len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0
-         || (len = is_dst (start, name, "LIB", is_path, 0)) != 0)
+      if (((len = is_dst (start, name, "ORIGIN", is_path)) != 0
+          && !INTUSE(__libc_enable_secure))
+         || (len = is_dst (start, name, "PLATFORM", is_path)) != 0
+         || (len = is_dst (start, name, "LIB", is_path)) != 0)
        ++cnt;
 
       name = strchr (name + len, '$');
@@ -256,9 +249,12 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
          size_t len;
 
          ++name;
-         if ((len = is_dst (start, name, "ORIGIN", is_path,
-                            INTUSE(__libc_enable_secure))) != 0)
+         if ((len = is_dst (start, name, "ORIGIN", is_path)) != 0)
            {
+             /* Ignore this path element in SUID/SGID programs.  */
+             if (INTUSE(__libc_enable_secure))
+               repl = (const char *) -1;
+             else
 #ifndef SHARED
              if (l == NULL)
                repl = _dl_get_origin ();
@@ -266,9 +262,9 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 #endif
                repl = l->l_origin;
            }
-         else if ((len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0)
+         else if ((len = is_dst (start, name, "PLATFORM", is_path)) != 0)
            repl = GLRO(dl_platform);
-         else if ((len = is_dst (start, name, "LIB", is_path, 0)) != 0)
+         else if ((len = is_dst (start, name, "LIB", is_path)) != 0)
            repl = DL_DST_LIB;
 
          if (repl != NULL && repl != (const char *) -1)