diff options
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/sysv/linux/dl-execstack.c | 96 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/getdents.c | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/kernel-features.h | 17 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/waitid.c | 41 |
4 files changed, 8 insertions, 152 deletions
diff --git a/sysdeps/unix/sysv/linux/dl-execstack.c b/sysdeps/unix/sysv/linux/dl-execstack.c index 6408adcc9f..9aadb90891 100644 --- a/sysdeps/unix/sysv/linux/dl-execstack.c +++ b/sysdeps/unix/sysv/linux/dl-execstack.c @@ -1,5 +1,5 @@ /* Stack executability handling for GNU dynamic linker. Linux version. - Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2003-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -46,95 +46,11 @@ _dl_make_stack_executable (void **stack_endp) || __builtin_expect (*stack_endp != __libc_stack_end, 0)) return EPERM; - /* Newer Linux kernels support a flag to make our job easy. */ -#if defined PROT_GROWSDOWN || defined PROT_GROWSUP -# if __ASSUME_PROT_GROWSUPDOWN == 0 - static bool no_growsupdown; - if (! no_growsupdown) -# endif - { - if (__builtin_expect (__mprotect ((void *) page, GLRO(dl_pagesize), - __stack_prot) == 0, 1)) - goto return_success; -# if __ASSUME_PROT_GROWSUPDOWN == 0 - if (errno == EINVAL) - no_growsupdown = true; - else -# endif - { - result = errno; - goto out; - } - } -#endif - - /* There is always a hole in the address space below the bottom of the - stack. So when we make an mprotect call that starts below the bottom - of the stack, it will include the hole and fail with ENOMEM. - - We start with a random guess at how deep the stack might have gotten - so as to have extended the GROWSDOWN mapping to lower pages. */ - -#if __ASSUME_PROT_GROWSUPDOWN == 0 - size_t size = GLRO(dl_pagesize) * 8; - -# if _STACK_GROWS_DOWN - page = page + GLRO(dl_pagesize) - size; - while (1) - { - if (__mprotect ((void *) page, size, - __stack_prot & ~PROT_GROWSDOWN) == 0) - /* We got this chunk changed; loop to do another chunk below. */ - page -= size; - else - { - if (errno != ENOMEM) /* Unexpected failure mode. */ - { - result = errno; - goto out; - } - - if (size == GLRO(dl_pagesize)) - /* We just tried to mprotect the top hole page and failed. - We are done. */ - break; - - /* Our mprotect call failed because it started below the lowest - stack page. Try again on just the top half of that region. */ - size /= 2; - page += size; - } - } - -# elif _STACK_GROWS_UP - while (1) - { - if (__mprotect ((void *) page, size, __stack_prot & ~PROT_GROWSUP) == 0) - /* We got this chunk changed; loop to do another chunk below. */ - page += size; - else - { - if (errno != ENOMEM) /* Unexpected failure mode. */ - { - result = errno; - goto out; - } - - if (size == GLRO(dl_pagesize)) - /* We just tried to mprotect the lowest hole page and failed. - We are done. */ - break; - - /* Our mprotect call failed because it extended past the highest - stack page. Try again on just the bottom half of that region. */ - size /= 2; - } - } - -# else -# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP" -# endif -#endif + if (__builtin_expect (__mprotect ((void *) page, GLRO(dl_pagesize), + __stack_prot) == 0, 1)) + goto return_success; + result = errno; + goto out; return_success: /* Clear the address. */ diff --git a/sysdeps/unix/sysv/linux/getdents.c b/sysdeps/unix/sysv/linux/getdents.c index ac4979efb2..babfbd0a43 100644 --- a/sysdeps/unix/sysv/linux/getdents.c +++ b/sysdeps/unix/sysv/linux/getdents.c @@ -97,7 +97,6 @@ __GETDENTS (int fd, char *buf, size_t nbytes) { ssize_t retval; -#ifdef __ASSUME_GETDENTS32_D_TYPE /* The d_ino and d_off fields in kernel_dirent and dirent must have the same sizes and alignments. */ if (sizeof (DIRENT_TYPE) == sizeof (struct dirent) @@ -135,7 +134,6 @@ __GETDENTS (int fd, char *buf, size_t nbytes) return retval; } -#endif off64_t last_offset = -1; @@ -293,11 +291,7 @@ __GETDENTS (int fd, char *buf, size_t nbytes) DIRENT_SET_DP_INO(dp, kdp->d_ino); dp->d_off = kdp->d_off; dp->d_reclen = new_reclen; -#ifdef __ASSUME_GETDENTS32_D_TYPE dp->d_type = *((char *) kdp + kdp->d_reclen - 1); -#else - dp->d_type = DT_UNKNOWN; -#endif memcpy (dp->d_name, kdp->d_name, kdp->d_reclen - offsetof (struct kernel_dirent, d_name)); diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 7dfc4e30d1..9f0a8e6218 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -139,10 +139,6 @@ # define __ASSUME_FADVISE64_64_SYSCALL 1 #endif -/* The PROT_GROWSDOWN/PROT_GROWSUP flags were introduced in the 2.6.0-test - series. */ -#define __ASSUME_PROT_GROWSUPDOWN 1 - /* Starting with 2.6.0 PowerPC adds signal/swapcontext support for Vector SIMD (AKA Altivec, VMX) instructions and register state. This changes the overall size of the sigcontext and adds the swapcontext syscall. */ @@ -150,19 +146,6 @@ # define __ASSUME_SWAPCONTEXT_SYSCALL 1 #endif -/* The CLONE_DETACHED flag is not necessary in 2.6.2 kernels, it is - implied. */ -#define __ASSUME_NO_CLONE_DETACHED 1 - -/* Starting with version 2.6.4-rc1 the getdents syscall returns d_type - information as well and in between 2.6.5 and 2.6.8 most compat wrappers - were fixed too. Except s390{,x} which was fixed in 2.6.11. */ -#define __ASSUME_GETDENTS32_D_TYPE 1 - -/* Starting with version 2.6.9, the waitid system call is available. - Except for powerpc{,64} and s390{,x}, where it is available in 2.6.12. */ -#define __ASSUME_WAITID_SYSCALL 1 - /* On sparc64 stat64/lstat64/fstat64 syscalls were introduced in 2.6.12. */ #if defined __sparc__ && defined __arch64__ # define __ASSUME_STAT64_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/waitid.c b/sysdeps/unix/sysv/linux/waitid.c index 7a8b6eb8b2..0fe6330392 100644 --- a/sysdeps/unix/sysv/linux/waitid.c +++ b/sysdeps/unix/sysv/linux/waitid.c @@ -1,5 +1,5 @@ /* Linux implementation of waitid. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,14 +19,8 @@ #include <stddef.h> #include <errno.h> #include <sys/wait.h> -#include <kernel-features.h> #include <sysdep.h> - -#ifdef __NR_waitid - -# if __ASSUME_WAITID_SYSCALL > 0 - static inline int do_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) { @@ -34,37 +28,6 @@ do_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) pass if we were using waitid to simulate wait3/wait4. */ return INLINE_SYSCALL (waitid, 5, idtype, id, infop, options, NULL); } -# define NO_DO_WAITID - -# else - -static int do_compat_waitid (idtype_t idtype, id_t id, - siginfo_t *infop, int options); -# define DO_WAITID do_compat_waitid - -static int -do_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) -{ - static int waitid_works; - if (waitid_works > 0) - return INLINE_SYSCALL (waitid, 5, idtype, id, infop, options, NULL); - if (waitid_works == 0) - { - int result = INLINE_SYSCALL (waitid, 5, - idtype, id, infop, options, NULL); - if (result < 0 && errno == ENOSYS) - waitid_works = -1; - else - { - waitid_works = 1; - return result; - } - } - return do_compat_waitid (idtype, id, infop, options); -} - -# endif - -#endif +#define NO_DO_WAITID #include "sysdeps/posix/waitid.c" |