From: Paul Pluzhnikov Date: Tue, 4 Mar 2014 00:18:01 +0000 (-0800) Subject: For b/3133396, ignore system ld.so.cache when looking for nss and iconv modules. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33838f184a353da60d4bb11c390e2e01a545889f;p=thirdparty%2Fglibc.git For b/3133396, ignore system ld.so.cache when looking for nss and iconv modules. --- diff --git a/README.google b/README.google index dfa4bfd71c8..8710245a5ac 100644 --- a/README.google +++ b/README.google @@ -177,3 +177,13 @@ sysdeps/generic/unsecvars.h Forward-ported from cl/51433387 (from cl/38694-p2, cl/38725-p2, and cl/38741-p2). (ppluzhnikov, google-local) + +elf/dl-cache.c +elf/dl-load.c +include/dlfcn.h +sysdeps/generic/ldsodefs.h + For b/3133396, ignore system ld.so.cache when looking for + nss and iconv modules. + Forward-ported from cl/51433604 (from cl/44863-p2). + (ppluzhnikov, google-local) + diff --git a/elf/dl-cache.c b/elf/dl-cache.c index 34de935000e..c5db4639e61 100644 --- a/elf/dl-cache.c +++ b/elf/dl-cache.c @@ -353,7 +353,7 @@ _dl_alloc_cache_info (const char *const cache_list) file name stored there, or null if none is found. */ const char * internal_function -_dl_load_cache_lookup (const char *name) +_dl_load_cache_lookup (const char *name, int mode) { struct cache_info *info; @@ -362,6 +362,16 @@ _dl_load_cache_lookup (const char *name) /* Caches have not been initialized yet. */ cache_info = _dl_alloc_cache_info (GLRO(google_ld_so_cache_list)); + if (mode & __RTLD_GOOGLE_IGNORE_HOST_LD_SO_CACHE) + { + /* We are loading a component of glibc itself (e.g. nss or iconv). + Such components must not be loaded from host, only from this + glibc compilation (which must always be the first component of + the cache list). See b/3133396 */ + + return _dl_load_cache_lookup_2 (name, cache_info); + } + for (info = cache_info; info->ld_so_cache != NULL; ++info) { const char *result; diff --git a/elf/dl-load.c b/elf/dl-load.c index 1be7a3ca967..cf49641dfc9 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -2229,7 +2229,7 @@ _dl_map_object (struct link_map *loader, const char *name, { /* Check the list of libraries in the file /etc/ld.so.cache, for compatibility with Linux's ldconfig program. */ - const char *cached = _dl_load_cache_lookup (name); + const char *cached = _dl_load_cache_lookup (name, mode); if (cached != NULL) { diff --git a/include/dlfcn.h b/include/dlfcn.h index a67b2e3251e..666ee605961 100644 --- a/include/dlfcn.h +++ b/include/dlfcn.h @@ -13,6 +13,10 @@ #define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */ #define __RTLD_NOIFUNC 0x02000000 /* Suppress calling ifunc functions. */ +/* Google-local; use only $prefix/etc/ld.so.cache. + See b/3133396 */ +#define __RTLD_GOOGLE_IGNORE_HOST_LD_SO_CACHE 0x01000000 + #define __LM_ID_CALLER -2 #ifdef SHARED @@ -32,7 +36,8 @@ extern char **__libc_argv attribute_hidden; /* Now define the internal interfaces. */ #define __libc_dlopen(name) \ - __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN) + __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN | \ + __RTLD_GOOGLE_IGNORE_HOST_LD_SO_CACHE) extern void *__libc_dlopen_mode (const char *__name, int __mode); extern void *__libc_dlsym (void *__map, const char *__name); extern int __libc_dlclose (void *__map); diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 5afa8468597..2cddbf1d74a 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -939,7 +939,7 @@ extern const struct r_strlenpair *_dl_important_hwcaps (const char *platform, /* Look up NAME in ld.so.cache and return the file name stored there, or null if none is found. */ -extern const char *_dl_load_cache_lookup (const char *name) +extern const char *_dl_load_cache_lookup (const char *name, int mode) internal_function; /* If the system does not support MAP_COPY we cannot leave the file open