Bug 16431 - PowerPC: gettimeofday calling from glibc internal symbol redirects to system call version
Summary: PowerPC: gettimeofday calling from glibc internal symbol redirects to system ...
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: Adhemerval Zanella Netto
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-10 16:53 UTC by Adhemerval Zanella Netto
Modified: 2014-06-13 09:01 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adhemerval Zanella Netto 2014-01-10 16:53:29 UTC
The PowerPC gettimeofday implementation (sysdeps/unix/sysv/linux/powerpc/gettimeofday.c) relies on IFUNC selection to use the vDSO implementation (if it is provided by kernel) or a fallback symbol that uses a system call.

The IFUNC selector for gettimeofday runs before _libc_vdso_platform_setup where
__vdso_gettimeofday is set. The selector then sets __gettimeofday (the internal
version used within GLIBC) to use the system call version instead of the vDSO one.

Although this does not lead to wrong behavior, a possible performance leverage would be to change the way IFUNC resolver get the vDSO to call _dl_vdso_vsym directly instead of relying in __vdso_gettimeofday value (much like as x86_64 does).
Comment 1 Adhemerval Zanella Netto 2014-01-10 17:07:22 UTC
An fix for this issue:

diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
index 29a5e08..a90fd3e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
@@ -35,8 +35,13 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
 void *
 gettimeofday_ifunc (void)
 {
+  void *vdso_gettimeofday;
+
+  PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565);
+
   /* If the vDSO is not available we fall back syscall.  */
-  return (__vdso_gettimeofday ? VDSO_IFUNC_RET (__vdso_gettimeofday)
+  vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
+  return (vdso_gettimeofday ? VDSO_IFUNC_RET (vdso_gettimeofday)
          : __gettimeofday_syscall);
 }
 asm (".type __gettimeofday, %gnu_indirect_function");
Comment 2 Ondrej Bilka 2014-01-12 13:52:51 UTC
*** Bug 16257 has been marked as a duplicate of this bug. ***
Comment 3 Adhemerval Zanella Netto 2014-01-12 14:28:29 UTC
In fact I think Bug 16257 is a duplicate of Bug 16430 instead. And I'm currently working with Alan Modra to determine if this is a binutils bug or an expected behavior.
Comment 4 Adhemerval Zanella Netto 2014-01-20 18:52:53 UTC
Fixed by d98720e07f67fbeec00f9e1347840404240d3c48.