* sysdeps/unix/sysv/linux/ldsodefs.h (HAVE_AUX_XID): Define if
	__ASSUME_AT_XID is defined.
	* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_AT_XID): Define
	for 2.4.1 and up.
	* sysdeps/generic/dl-sysdep.c (_dl_sysdep_start): Optimize handling
	of AT_UID, AT_EUID, AT_GID, and AT_EGID.
This commit is contained in:
Ulrich Drepper 2002-07-20 17:31:30 +00:00
parent 864dd9b2d0
commit 846c6907d0
4 changed files with 31 additions and 20 deletions

View File

@ -1,5 +1,12 @@
2002-07-20 Ulrich Drepper <drepper@redhat.com> 2002-07-20 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/ldsodefs.h (HAVE_AUX_XID): Define if
__ASSUME_AT_XID is defined.
* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_AT_XID): Define
for 2.4.1 and up.
* sysdeps/generic/dl-sysdep.c (_dl_sysdep_start): Optimize handling
of AT_UID, AT_EUID, AT_GID, and AT_EGID.
* wcsmbs/Makefile (CFLAGS-wcstod.c): Add -I../stdlib. * wcsmbs/Makefile (CFLAGS-wcstod.c): Add -I../stdlib.
(CFLAGS-wcstof.c): Likewise. (CFLAGS-wcstof.c): Likewise.
(CFLAGS-wcstold.c): Likewise. (CFLAGS-wcstold.c): Likewise.

View File

@ -79,9 +79,7 @@ _dl_sysdep_start (void **start_argptr,
ElfW(Addr) user_entry; ElfW(Addr) user_entry;
ElfW(auxv_t) *av; ElfW(auxv_t) *av;
uid_t uid = 0; uid_t uid = 0;
uid_t euid = 0;
gid_t gid = 0; gid_t gid = 0;
gid_t egid = 0;
#ifdef HAVE_AUX_XID #ifdef HAVE_AUX_XID
# define set_seen(tag) (tag) /* Evaluate for the side effects. */ # define set_seen(tag) (tag) /* Evaluate for the side effects. */
#else #else
@ -117,16 +115,12 @@ _dl_sysdep_start (void **start_argptr,
break; break;
#endif #endif
case AT_UID: case AT_UID:
uid = av->a_un.a_val; case AT_EUID:
uid ^= av->a_un.a_val;
break; break;
case AT_GID: case AT_GID:
gid = av->a_un.a_val;
break;
case AT_EUID:
euid = av->a_un.a_val;
break;
case AT_EGID: case AT_EGID:
egid = av->a_un.a_val; gid ^= av->a_un.a_val;
break; break;
case AT_PLATFORM: case AT_PLATFORM:
GL(dl_platform) = av->a_un.a_ptr; GL(dl_platform) = av->a_un.a_ptr;
@ -146,18 +140,20 @@ _dl_sysdep_start (void **start_argptr,
DL_SYSDEP_OSCHECK (dl_fatal); DL_SYSDEP_OSCHECK (dl_fatal);
#endif #endif
/* Linux doesn't provide us with any of these values on the stack /* Fill in the values we have not gotten from the kernel through the
when the dynamic linker is run directly as a program. */ auxiliary vector. */
#ifndef HAVE_AUX_XID #ifndef HAVE_AUX_XID
# define SEE(UID, uid) if ((seen & M (AT_##UID)) == 0) uid = __get##uid () # define SEE(UID, var, uid) \
SEE (UID, uid); if ((seen & M (AT_##UID)) == 0) var ^= __get##uid ()
SEE (GID, gid); SEE (UID, uid, uid);
SEE (EUID, euid); SEE (EUID, uid, euid);
SEE (EGID, egid); SEE (GID, gid, gid);
SEE (EGID, gid, egid);
#endif #endif
INTUSE(__libc_enable_secure) = uid != euid || gid != egid; /* If one of the two pairs of IDs does not mattch this is a setuid
or setgid run. */
INTUSE(__libc_enable_secure) = uid | gid;
#ifndef HAVE_AUX_PAGESIZE #ifndef HAVE_AUX_PAGESIZE
if (GL(dl_pagesize) == 0) if (GL(dl_pagesize) == 0)

View File

@ -171,6 +171,12 @@
# define __ASSUME_AT_PAGESIZE 1 # define __ASSUME_AT_PAGESIZE 1
#endif #endif
/* Starting with at least 2.4.0 the kernel passes the uid/gid unconditionally
up to the child. */
#if __LINUX_KERNEL_VERSION >= 132097
# define __ASSUME_AT_XID 1
#endif
/* Starting with 2.4.5 kernels PPC passes the AUXV in the standard way /* Starting with 2.4.5 kernels PPC passes the AUXV in the standard way
and the mmap2 syscall made it into the official kernel. */ and the mmap2 syscall made it into the official kernel. */
#if __LINUX_KERNEL_VERSION >= (132096+5) && defined __powerpc__ #if __LINUX_KERNEL_VERSION >= (132096+5) && defined __powerpc__

View File

@ -36,8 +36,10 @@ extern void _dl_aux_init (ElfW(auxv_t) *av) internal_function;
extern void _dl_non_dynamic_init (void) internal_function; extern void _dl_non_dynamic_init (void) internal_function;
/* We can assume that the kernel always provides the AT_UID, AT_EUID, /* We can assume that the kernel always provides the AT_UID, AT_EUID,
AT_GID, and AT_EGID values in the auxiliary vector. */ AT_GID, and AT_EGID values in the auxiliary vector from 2.4.0 or so on. */
#define HAVE_AUX_XID #if __ASSUME_AT_XID
# define HAVE_AUX_XID
#endif
/* Starting with one of the 2.4.0 pre-releases the Linux kernel passes /* Starting with one of the 2.4.0 pre-releases the Linux kernel passes
up the page size information. */ up the page size information. */