This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch google/grte/v5-2.27/master updated. glibc-2.27-67-g58f3bc0


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, google/grte/v5-2.27/master has been updated
       via  58f3bc06905f1dc59740649a62bde39166efe605 (commit)
       via  213dc5389dc685a2622efe3dbbba8e7993b65338 (commit)
       via  8fa201f8f222306f0b9ae35e026f6da422b3c3b8 (commit)
       via  87da87ce64b786e05060fbb2f66ea911c7f96e96 (commit)
      from  5c0823e1b96883a60114e8dd93ece4ec61c7fd86 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=58f3bc06905f1dc59740649a62bde39166efe605

commit 58f3bc06905f1dc59740649a62bde39166efe605
Author: Stan Shebs <stanshebs@google.com>
Date:   Mon Mar 19 11:04:23 2018 -0700

    Add empty NSS borg and cache abi lists, to make testsuite work

diff --git a/sysdeps/generic/libnss_borg.abilist b/sysdeps/generic/libnss_borg.abilist
new file mode 100644
index 0000000..e69de29
diff --git a/sysdeps/generic/libnss_cache.abilist b/sysdeps/generic/libnss_cache.abilist
new file mode 100644
index 0000000..e69de29

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=213dc5389dc685a2622efe3dbbba8e7993b65338

commit 213dc5389dc685a2622efe3dbbba8e7993b65338
Author: Stan Shebs <stanshebs@google.com>
Date:   Mon Mar 19 09:41:11 2018 -0700

    Fix out-of-date bits in EXEC_ORIGIN patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 50cbed2..4d8af1d 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -275,9 +275,9 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result)
 	    repl = GLRO(dl_platform);
 	  else if ((len = is_dst (start, name, "LIB", 0)) != 0)
 	    repl = DL_DST_LIB;
-	  else if ((len = is_dst (start, name, "EXEC_ORIGIN", is_path, 0)) != 0)
+	  else if ((len = is_dst (start, name, "EXEC_ORIGIN", 0)) != 0)
 	    {
-	      if (INTUSE(__libc_enable_secure) != 0)
+	      if (__libc_enable_secure)
 		_dl_fatal_printf ("$EXEC_ORIGIN rpath entry not allowed in setuid/setgid executables.\n");
 
 	      repl = GLRO(google_exec_origin_dir);
diff --git a/elf/rtld.c b/elf/rtld.c
index ca24cab..4c3ad4c 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1051,7 +1051,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 			in LIST\n\
   --audit LIST          use objects named in LIST as auditors\n");
 
-      set_exec_origin_dir (INTUSE(_dl_argv)[1]);
+      set_exec_origin_dir (_dl_argv[1]);
 
       ++_dl_skip_args;
       --_dl_argc;

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=8fa201f8f222306f0b9ae35e026f6da422b3c3b8

commit 8fa201f8f222306f0b9ae35e026f6da422b3c3b8
Author: Brooks Moses <bmoses@google.com>
Date:   Fri Apr 11 13:37:15 2014 -0700

    For b/12342355, remove inappropriate assert in EXEC_ORIGIN support.

diff --git a/elf/rtld.c b/elf/rtld.c
index 6423430..ca24cab 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -2877,10 +2877,6 @@ get_directory (const char *file_path)
     dest = __mempcpy (dest, file_path, path_len);
   *dest = '\0';
 
-  /* Confirm that the constructed path is valid.  */
-  struct stat64 st;
-  assert (__xstat64 (_STAT_VER, full_dir_path, &st) == 0);
-
   return full_dir_path;
 }
 

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=87da87ce64b786e05060fbb2f66ea911c7f96e96

commit 87da87ce64b786e05060fbb2f66ea911c7f96e96
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Sat Mar 8 15:12:52 2014 -0800

    For b/4074041, add EXEC_ORIGIN support. Forward-ported from cl/56955623 and http://cl/59961863.

diff --git a/elf/dl-dst.h b/elf/dl-dst.h
index 32de5d2..f00c8e2 100644
--- a/elf/dl-dst.h
+++ b/elf/dl-dst.h
@@ -65,8 +65,13 @@
 	else								      \
 	  dst_len = (l)->l_origin == (char *) -1			      \
 	    ? 0 : strlen ((l)->l_origin);				      \
-	dst_len = MAX (MAX (dst_len, GLRO(dl_platformlen)),		      \
-		       strlen (DL_DST_LIB));				      \
+                                                                              \
+	char *exec_origin = GLRO(google_exec_origin_dir);		      \
+	size_t exec_origin_len =					      \
+	  (exec_origin == NULL) ? 0 : strlen (exec_origin);		      \
+									      \
+	dst_len = MAX (MAX (MAX (dst_len, GLRO(dl_platformlen)),	      \
+			    strlen (DL_DST_LIB)), exec_origin_len);	      \
 	if (dst_len > 4)						      \
 	  __len += __cnt * (dst_len - 4);				      \
       }									      \
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 7554a99..50cbed2 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -232,7 +232,8 @@ _dl_dst_count (const char *name)
       ++name;
       if ((len = is_dst (start, name, "ORIGIN", __libc_enable_secure)) != 0
 	  || (len = is_dst (start, name, "PLATFORM", 0)) != 0
-	  || (len = is_dst (start, name, "LIB", 0)) != 0)
+	  || (len = is_dst (start, name, "LIB", 0)) != 0
+	  || (len = is_dst (start, name, "EXEC_ORIGIN", 0)) != 0)
 	++cnt;
 
       name = strchr (name + len, '$');
@@ -274,6 +275,13 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result)
 	    repl = GLRO(dl_platform);
 	  else if ((len = is_dst (start, name, "LIB", 0)) != 0)
 	    repl = DL_DST_LIB;
+	  else if ((len = is_dst (start, name, "EXEC_ORIGIN", is_path, 0)) != 0)
+	    {
+	      if (INTUSE(__libc_enable_secure) != 0)
+		_dl_fatal_printf ("$EXEC_ORIGIN rpath entry not allowed in setuid/setgid executables.\n");
+
+	      repl = GLRO(google_exec_origin_dir);
+	    }
 
 	  if (repl != NULL && repl != (const char *) -1)
 	    {
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 12270f0..5df69a6 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -67,6 +67,9 @@ void *__libc_stack_end;
 /* Path where the binary is found.  */
 const char *_dl_origin_path;
 
+/* Directory where the AT_EXECFN is found.  */
+const char *_google_exec_origin_dir;
+
 /* Nonzero if runtime lookup should not update the .got/.plt.  */
 int _dl_bind_not;
 
diff --git a/elf/rtld.c b/elf/rtld.c
index 1fe343e..6423430 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -51,6 +51,12 @@ extern __typeof (__mempcpy) __mempcpy attribute_hidden;
 extern __typeof (_exit) exit_internal asm ("_exit") attribute_hidden;
 #define _exit exit_internal
 
+/* Iterate over auxv, find AT_EXECFN if any.  */
+static char * get_at_execfn(ElfW(auxv_t) *auxv);
+
+/* Given file path, return fully resolved directory path.  */
+static char * get_directory (const char *file_path);
+
 /* Helper function to handle errors while resolving symbols.  */
 static void print_unresolved (int errcode, const char *objname,
 			      const char *errsting);
@@ -73,6 +79,9 @@ enum mode { normal, list, verify, trace };
    all the entries.  */
 static void process_envvars (enum mode *modep);
 
+/* Set GLRO(google_exec_origin_dir).  */
+static void set_exec_origin_dir(const char *exe_path);
+
 #ifdef DL_ARGV_NOT_RELRO
 int _dl_argc attribute_hidden;
 char **_dl_argv = NULL;
@@ -1042,6 +1051,8 @@ of this helper program; chances are you did not intend to run this program.\n\
 			in LIST\n\
   --audit LIST          use objects named in LIST as auditors\n");
 
+      set_exec_origin_dir (INTUSE(_dl_argv)[1]);
+
       ++_dl_skip_args;
       --_dl_argc;
       ++_dl_argv;
@@ -1136,6 +1147,8 @@ of this helper program; chances are you did not intend to run this program.\n\
     }
   else
     {
+      set_exec_origin_dir (get_at_execfn (auxv));
+
       /* Create a link_map for the executable itself.
 	 This will be what dlopen on "" returns.  */
       main_map = _dl_new_object ((char *) "", "", lt_executable, NULL,
@@ -2821,6 +2834,81 @@ print_statistics (hp_timing_t *rtld_total_timep)
 #endif
 }
 
+/* Given file path, return an absolute directory path.
+   Examples: in: "/foo/bar/a.out", out: "/foo/bar/";
+   in: "./a.out", out: "/dot/resolved/to/full/path/./".  */
+static char *
+get_directory (const char *file_path)
+{
+  assert (file_path != NULL);
+
+  /* Find the end of the directory substring in file_path.  */
+  size_t path_len = strlen (file_path);
+  while (path_len > 0 && file_path[path_len - 1] != '/')
+    --path_len;
+
+  /* Allocate space and set the path prefix according to whether or not
+     this is an absolute path.  */
+  char *dest;
+  char *full_dir_path;
+  if (file_path[0] == '/')
+    {
+      full_dir_path = malloc (path_len + 1);
+      assert (full_dir_path != NULL);
+      dest = full_dir_path;
+    }
+  else
+    {
+      /* For a relative path, we need to include space for the largest
+	 possible current path, a joining '/', the relevant part of
+	 file_path, and a trailing '\0'.  */
+      full_dir_path = malloc (PATH_MAX + path_len + 2);
+      assert (full_dir_path != NULL);
+
+      char *status = __getcwd (full_dir_path, PATH_MAX);
+      assert (status != NULL);
+
+      dest = __rawmemchr (full_dir_path, '\0');
+      if (dest[-1] != '/')
+	*dest++ = '/';
+    }
+
+  if (path_len > 0)
+    dest = __mempcpy (dest, file_path, path_len);
+  *dest = '\0';
+
+  /* Confirm that the constructed path is valid.  */
+  struct stat64 st;
+  assert (__xstat64 (_STAT_VER, full_dir_path, &st) == 0);
+
+  return full_dir_path;
+}
+
+/* Set GLRO(google_exec_origin_dir).  */
+static void
+set_exec_origin_dir (const char *exe_path)
+{
+  assert (GLRO(google_exec_origin_dir) == NULL);
+
+  if (GLRO(dl_origin_path) != NULL)
+    GLRO(google_exec_origin_dir) = strdup (GLRO(dl_origin_path));
+  else if (exe_path != NULL)
+    GLRO(google_exec_origin_dir) = get_directory (exe_path);
+}
+
+/* Iterate over auxv, find AT_EXECFN if any.  */
+static char *
+get_at_execfn (ElfW(auxv_t) *auxv)
+{
+  assert (auxv != NULL);
+
+  for (; auxv->a_type != AT_NULL; ++auxv)
+    if (auxv->a_type == AT_EXECFN)
+      return (char *) auxv->a_un.a_val;
+
+  return NULL;
+}
+
 #ifndef NESTING
 char *dummy1 = (char *)elf_get_dynamic_info;
 # if ! ELF_MACHINE_NO_REL
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index a9c2b08..caa5f1d 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -544,6 +544,9 @@ struct rtld_global_ro
   /* Location of the binary.  */
   EXTERN const char *_dl_origin_path;
 
+  /* Directory where the AT_EXECFN is found.  */
+  EXTERN const char *_google_exec_origin_dir;
+
   /* -1 if the dynamic linker should honor library load bias,
      0 if not, -2 use the default (honor biases for normal
      binaries, don't honor for PIEs).  */

-----------------------------------------------------------------------

Summary of changes:
 elf/dl-dst.h                                       |    9 ++-
 elf/dl-load.c                                      |   10 ++-
 elf/dl-support.c                                   |    3 +
 elf/rtld.c                                         |   84 ++++++++++++++++++++
 sysdeps/generic/ldsodefs.h                         |    3 +
 .../generic/{ld.abilist => libnss_borg.abilist}    |    0
 .../generic/{ld.abilist => libnss_cache.abilist}   |    0
 7 files changed, 106 insertions(+), 3 deletions(-)
 copy sysdeps/generic/{ld.abilist => libnss_borg.abilist} (100%)
 copy sysdeps/generic/{ld.abilist => libnss_cache.abilist} (100%)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]