]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix pthreads getrlimit, gettimeofday namespace (bug 17682).
authorJoseph Myers <joseph@codesourcery.com>
Sat, 6 Dec 2014 23:40:48 +0000 (23:40 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Sat, 6 Dec 2014 23:40:48 +0000 (23:40 +0000)
Some pthreads functions use getrlimit and gettimeofday, but these
functions are XSI, not base POSIX; this is a namespace issue for
dynamic linking as well as static linking.  This patch makes them use
__getrlimit and __gettimeofday instead - the former needed to be newly
exported from libc.so at GLIBC_PRIVATE (and so now needs
libc_hidden_proto / libc_hidden_def), the latter was already exported.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).

[BZ #17682]
* resource/Versions (libc): Add __getrlimit at GLIBC_PRIVATE.
* resource/getrlimit.c (__getrlimit): Use libc_hidden_def.
* sysdeps/mach/hurd/getrlimit.c (__getrlimit): Likewise.
* include/sys/resource.h (__getrlimit): Use libc_hidden_proto.
* nptl/nptl-init.c (__pthread_initialize_minimal_internal): Use
__getrlimit instead of getrlimit.
* nptl/pthread_cond_timedwait.c (__pthread_cond_timedwait): Use
__gettimeofday instead of gettimeofday.
* nptl/pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock):
Likewise.
* nptl/pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock):
Likewise.
* sysdeps/pthread/aio_misc.c (handle_fildes_io): Likewise.
* conform/Makefile (test-xfail-POSIX2008/aio.h/linknamespace):
Remove variable.
(test-xfail-POSIX2008/pthread.h/linknamespace): Likewise.
(test-xfail-POSIX2008/time.h/linknamespace): Likewise.

12 files changed:
ChangeLog
NEWS
conform/Makefile
include/sys/resource.h
nptl/nptl-init.c
nptl/pthread_cond_timedwait.c
nptl/pthread_rwlock_timedrdlock.c
nptl/pthread_rwlock_timedwrlock.c
resource/Versions
resource/getrlimit.c
sysdeps/mach/hurd/getrlimit.c
sysdeps/pthread/aio_misc.c

index fede1bbcec7fbb7db31169f42f61fcb528d95e79..676fd0ee60f1db799d6107422e0411266cc405ca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2014-12-06  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #17682]
+       * resource/Versions (libc): Add __getrlimit at GLIBC_PRIVATE.
+       * resource/getrlimit.c (__getrlimit): Use libc_hidden_def.
+       * sysdeps/mach/hurd/getrlimit.c (__getrlimit): Likewise.
+       * include/sys/resource.h (__getrlimit): Use libc_hidden_proto.
+       * nptl/nptl-init.c (__pthread_initialize_minimal_internal): Use
+       __getrlimit instead of getrlimit.
+       * nptl/pthread_cond_timedwait.c (__pthread_cond_timedwait): Use
+       __gettimeofday instead of gettimeofday.
+       * nptl/pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock):
+       Likewise.
+       * nptl/pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock):
+       Likewise.
+       * sysdeps/pthread/aio_misc.c (handle_fildes_io): Likewise.
+       * conform/Makefile (test-xfail-POSIX2008/aio.h/linknamespace):
+       Remove variable.
+       (test-xfail-POSIX2008/pthread.h/linknamespace): Likewise.
+       (test-xfail-POSIX2008/time.h/linknamespace): Likewise.
+
 2014-12-05  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        * libio/tst-ftell-active-handler.c (do_ftell_test): Fix buffer overrun
diff --git a/NEWS b/NEWS
index 84c135314898109ea20a5610688ead4292240b04..1b08d40a6802c387ebba72c47fea3e0135d7eedb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,8 @@ Version 2.21
   16619, 16740, 16857, 17192, 17266, 17344, 17363, 17370, 17371, 17411,
   17460, 17475, 17485, 17501, 17506, 17508, 17522, 17555, 17570, 17571,
   17572, 17573, 17574, 17581, 17582, 17583, 17584, 17585, 17589, 17594,
-  17601, 17608, 17616, 17625, 17633, 17647, 17653, 17664, 17665, 17668.
+  17601, 17608, 17616, 17625, 17633, 17647, 17653, 17664, 17665, 17668,
+  17682.
 
 * CVE-2104-7817 The wordexp function could ignore the WRDE_NOCMD flag
   under certain input conditions resulting in the execution of a shell for
index a73b217005c176b15bddfa06d044fff85db5d625..f99c30c7d5bb7bee660e8ebdec382f484669e7a7 100644 (file)
@@ -424,18 +424,15 @@ test-xfail-XOPEN2K/syslog.h/linknamespace = yes
 test-xfail-XOPEN2K/ucontext.h/linknamespace = yes
 test-xfail-XOPEN2K/unistd.h/linknamespace = yes
 test-xfail-XOPEN2K/wordexp.h/linknamespace = yes
-test-xfail-POSIX2008/aio.h/linknamespace = yes
 test-xfail-POSIX2008/ctype.h/linknamespace = yes
 test-xfail-POSIX2008/dirent.h/linknamespace = yes
 test-xfail-POSIX2008/fcntl.h/linknamespace = yes
 test-xfail-POSIX2008/grp.h/linknamespace = yes
 test-xfail-POSIX2008/mqueue.h/linknamespace = yes
 test-xfail-POSIX2008/netdb.h/linknamespace = yes
-test-xfail-POSIX2008/pthread.h/linknamespace = yes
 test-xfail-POSIX2008/regex.h/linknamespace = yes
 test-xfail-POSIX2008/semaphore.h/linknamespace = yes
 test-xfail-POSIX2008/spawn.h/linknamespace = yes
-test-xfail-POSIX2008/time.h/linknamespace = yes
 test-xfail-POSIX2008/unistd.h/linknamespace = yes
 test-xfail-XOPEN2K8/dirent.h/linknamespace = yes
 test-xfail-XOPEN2K8/fcntl.h/linknamespace = yes
index c35df435a5f94c54ebd8811a80c000a3f5df585a..1ce190f5f0cdb7e926cd9fcb70fab6692e099892 100644 (file)
@@ -9,6 +9,7 @@ libc_hidden_proto (getrlimit64)
 /* Now define the internal interfaces.  */
 extern int __getrlimit (enum __rlimit_resource __resource,
                        struct rlimit *__rlimits);
+libc_hidden_proto (__getrlimit)
 extern int __getrusage (enum __rusage_who __who, struct rusage *__usage)
        attribute_hidden;
 
index dcb77c5cf61714c90f8bbf5e10ccf7a1877549c8..8e90f05bb3aa6c996fd56595317d5011352b76de 100644 (file)
@@ -433,7 +433,7 @@ __pthread_initialize_minimal_internal (void)
   /* Determine the default allowed stack size.  This is the size used
      in case the user does not specify one.  */
   struct rlimit limit;
-  if (getrlimit (RLIMIT_STACK, &limit) != 0
+  if (__getrlimit (RLIMIT_STACK, &limit) != 0
       || limit.rlim_cur == RLIM_INFINITY)
     /* The system limit is not usable.  Use an architecture-specific
        default.  */
index 1c53bdddc3b010d3c6f71b013f27405243c019bd..989f0a68522985065e53c15d8992ed43d84e5d84 100644 (file)
@@ -131,7 +131,7 @@ __pthread_cond_timedwait (cond, mutex, abstime)
 # else
        /* Get the current time.  So far we support only one clock.  */
        struct timeval tv;
-       (void) gettimeofday (&tv, NULL);
+       (void) __gettimeofday (&tv, NULL);
 
        /* Convert the absolute timeout value to a relative timeout.  */
        rt.tv_sec = abstime->tv_sec - tv.tv_sec;
index d3044fb047e7f22ca7768ab79f259c2af59f2580..822ac8bea56925833b8bb8a4c1538a2133db30d0 100644 (file)
@@ -90,7 +90,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime)
      || !defined lll_futex_timed_wait_bitset)
       /* Get the current time.  So far we support only one clock.  */
       struct timeval tv;
-      (void) gettimeofday (&tv, NULL);
+      (void) __gettimeofday (&tv, NULL);
 
       /* Convert the absolute timeout value to a relative timeout.  */
       struct timespec rt;
index 560403f50ab3e6feec2300f12e9982d351c26753..22f9ad5d902aa82e5ec4604e036d56fdd883e401 100644 (file)
@@ -81,7 +81,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime)
      || !defined lll_futex_timed_wait_bitset)
       /* Get the current time.  So far we support only one clock.  */
       struct timeval tv;
-      (void) gettimeofday (&tv, NULL);
+      (void) __gettimeofday (&tv, NULL);
 
       /* Convert the absolute timeout value to a relative timeout.  */
       struct timespec rt;
index caff6a2f50897a39838655db17985d7349b48d7d..d6c2ccee1bc4faaee2c04b3f27e1442ac72fd375 100644 (file)
@@ -22,4 +22,7 @@ libc {
     # s*
     setrlimit64;
   }
+  GLIBC_PRIVATE {
+    __getrlimit;
+  }
 }
index 69206229223e4427d1f5ebbc29299aa0bcba687c..799ee6eb49ab30e679f77807bd7cd37b064167ef 100644 (file)
@@ -27,6 +27,7 @@ __getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
   __set_errno (ENOSYS);
   return -1;
 }
+libc_hidden_def (__getrlimit)
 weak_alias (__getrlimit, getrlimit)
 
 stub_warning (getrlimit)
index 0dc75185d9e1680f23fff1fc221302ec563ef5a8..141135ba5ea2ddf38a3f8f613f3586554e021b84 100644 (file)
@@ -43,4 +43,5 @@ __getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
 
   return 0;
 }
+libc_hidden_def (__getrlimit)
 weak_alias (__getrlimit, getrlimit)
index 5ebceeee402f872634229d32c08625bde28713d3..4aed16ac6de7456793cbdc98eba8365b1db7a985 100644 (file)
@@ -631,7 +631,7 @@ handle_fildes_io (void *arg)
          struct timespec wakeup_time;
 
          ++idle_thread_count;
-         gettimeofday (&now, NULL);
+         __gettimeofday (&now, NULL);
          wakeup_time.tv_sec = now.tv_sec + optim.aio_idle_time;
          wakeup_time.tv_nsec = now.tv_usec * 1000;
          if (wakeup_time.tv_nsec >= 1000000000)