* elf/elf.h: Add dynamic tag definitions for prelinking.

	* elf/rtld.c (process_envvars): Avoid using array of string pointers.
	Rewrite code to remove environment varables for SUID binaries.
	Small optimization in LD_PROFILE handling.
	* sysdeps/generic/unsecvars.h: Adjust format for process_envvars
	changes.
	* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.

	* sysdeps/generic/dl-sysdep.c: Don't initialize _dl_cpuclock_offset.
This commit is contained in:
Ulrich Drepper 2001-11-06 00:16:32 +00:00
parent ea41b9267d
commit c95f3fd42e
6 changed files with 54 additions and 41 deletions

View File

@ -1,5 +1,16 @@
2001-11-05 Ulrich Drepper <drepper@redhat.com> 2001-11-05 Ulrich Drepper <drepper@redhat.com>
* elf/elf.h: Add dynamic tag definitions for prelinking.
* elf/rtld.c (process_envvars): Avoid using array of string pointers.
Rewrite code to remove environment varables for SUID binaries.
Small optimization in LD_PROFILE handling.
* sysdeps/generic/unsecvars.h: Adjust format for process_envvars
changes.
* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.
* sysdeps/generic/dl-sysdep.c: Don't initialize _dl_cpuclock_offset.
* elf/dl-reloc.c (_dl_reloc_bad_type): Rewrite to not use writable * elf/dl-reloc.c (_dl_reloc_bad_type): Rewrite to not use writable
strings. Change type of second parameter. strings. Change type of second parameter.
* sysdeps/generic/ldsodefs.h: Adjust _dl_reloc_bad_type prototype * sysdeps/generic/ldsodefs.h: Adjust _dl_reloc_bad_type prototype

View File

@ -663,6 +663,9 @@ typedef struct
Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
approach. */ approach. */
#define DT_VALRNGLO 0x6ffffd00 #define DT_VALRNGLO 0x6ffffd00
#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
#define DT_CHECKSUM 0x6ffffdf8 #define DT_CHECKSUM 0x6ffffdf8
#define DT_PLTPADSZ 0x6ffffdf9 #define DT_PLTPADSZ 0x6ffffdf9
#define DT_MOVEENT 0x6ffffdfa #define DT_MOVEENT 0x6ffffdfa
@ -680,6 +683,8 @@ typedef struct
If any adjustment is made to the ELF object after it has been If any adjustment is made to the ELF object after it has been
built these entries will need to be adjusted. */ built these entries will need to be adjusted. */
#define DT_ADDRRNGLO 0x6ffffe00 #define DT_ADDRRNGLO 0x6ffffe00
#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
#define DT_CONFIG 0x6ffffefa /* Configuration information. */ #define DT_CONFIG 0x6ffffefa /* Configuration information. */
#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ #define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
#define DT_AUDIT 0x6ffffefc /* Object auditing. */ #define DT_AUDIT 0x6ffffefc /* Object auditing. */

View File

@ -1345,7 +1345,7 @@ process_envvars (enum mode *modep)
} }
/* Which shared object shall be profiled. */ /* Which shared object shall be profiled. */
if (memcmp (envline, "PROFILE", 7) == 0) if (memcmp (envline, "PROFILE", 7) == 0 && envline[8] != '\0')
_dl_profile = &envline[8]; _dl_profile = &envline[8];
break; break;
@ -1430,38 +1430,27 @@ process_envvars (enum mode *modep)
variables. */ variables. */
if (__builtin_expect (__libc_enable_secure, 0)) if (__builtin_expect (__libc_enable_secure, 0))
{ {
static const char *unsecure_envvars[] = static const char unsecure_envvars[] =
{
UNSECURE_ENVVARS,
#ifdef EXTRA_UNSECURE_ENVVARS #ifdef EXTRA_UNSECURE_ENVVARS
EXTRA_UNSECURE_ENVVARS EXTRA_UNSECURE_ENVVARS
#endif #endif
}; UNSECURE_ENVVARS;
size_t cnt; const char *nextp;
if (preloadlist != NULL) nextp = unsecure_envvars;
unsetenv ("LD_PRELOAD"); do
if (library_path != NULL) {
unsetenv ("LD_LIBRARY_PATH"); unsetenv (nextp);
if (_dl_origin_path != NULL) nextp = (char *) rawmemchr (nextp, '\0') + 1;
unsetenv ("LD_ORIGIN_PATH"); }
if (debug_output != NULL) while (*nextp != '\0');
unsetenv ("LD_DEBUG_OUTPUT");
if (_dl_profile != NULL)
unsetenv ("LD_PROFILE");
for (cnt = 0;
cnt < sizeof (unsecure_envvars) / sizeof (unsecure_envvars[0]);
++cnt)
unsetenv (unsecure_envvars[cnt]);
if (__access ("/etc/suid-debug", F_OK) != 0) if (__access ("/etc/suid-debug", F_OK) != 0)
unsetenv ("MALLOC_CHECK_"); unsetenv ("MALLOC_CHECK_");
} }
/* The name of the object to profile cannot be empty. */ /* The caller wants this information. */
if (_dl_profile != NULL && *_dl_profile == '\0') *modep = mode;
_dl_profile = NULL;
/* If we have to run the dynamic linker in debugging mode and the /* If we have to run the dynamic linker in debugging mode and the
LD_DEBUG_OUTPUT environment variable is given, we write the debug LD_DEBUG_OUTPUT environment variable is given, we write the debug
@ -1487,8 +1476,6 @@ process_envvars (enum mode *modep)
/* We use standard output if opening the file failed. */ /* We use standard output if opening the file failed. */
_dl_debug_fd = STDOUT_FILENO; _dl_debug_fd = STDOUT_FILENO;
} }
*modep = mode;
} }

View File

@ -63,7 +63,7 @@ void *__libc_stack_end;
static ElfW(auxv_t) *_dl_auxv; static ElfW(auxv_t) *_dl_auxv;
unsigned long int _dl_hwcap_mask = HWCAP_IMPORTANT; unsigned long int _dl_hwcap_mask = HWCAP_IMPORTANT;
#if HP_TIMING_AVAIL #if HP_TIMING_AVAIL
hp_timing_t _dl_cpuclock_offset = 0; hp_timing_t _dl_cpuclock_offset;
#endif #endif
#ifndef DL_FIND_ARG_COMPONENTS #ifndef DL_FIND_ARG_COMPONENTS

View File

@ -1,12 +1,19 @@
/* Environment variable to be removed for SUID programs. */ /* Environment variable to be removed for SUID programs. The names are
all stuffed in a single string which means they have to be terminated
with a '\0' explicitly. */
#define UNSECURE_ENVVARS \ #define UNSECURE_ENVVARS \
"GCONV_PATH", \ "LD_PRELOAD\0" \
"HOSTALIASES", \ "LD_LIBRARY_PATH\0" \
"LOCALDOMAIN", \ "LD_ORIGIN_PATH\0" \
"LOCPATH", \ "LD_DEBUG_OUTPUT\0" \
"MALLOC_TRACE", \ "LD_PROFILE\0" \
"NLSPATH", \ "GCONV_PATH\0" \
"RESOLV_HOST_CONF", \ "HOSTALIASES\0" \
"RES_OPTIONS", \ "LOCALDOMAIN\0" \
"TMPDIR", \ "LOCPATH\0" \
"TZDIR" "MALLOC_TRACE\0" \
"NLSPATH\0" \
"RESOLV_HOST_CONF\0" \
"RES_OPTIONS\0" \
"TMPDIR\0" \
"TZDIR\0"

View File

@ -78,7 +78,10 @@
break; \ break; \
} }
/* Extra unsecure variables. */ /* Extra unsecure variables. The names are all stuffed in a single
#define EXTRA_UNSECURE_ENVVARS "LD_AOUT_LIBRARY_PATH", "LD_AOUT_PRELOAD" string which means they have to be terminated with a '\0' explicitly. */
#define EXTRA_UNSECURE_ENVVARS \
"LD_AOUT_LIBRARY_PATH\0" \
"LD_AOUT_PRELOAD\0"
#endif /* dl-librecon.h */ #endif /* dl-librecon.h */