public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/16257] New: Internal calls to gnu_indirect_functions skip implementation, leaving gibberish behind
@ 2013-11-26 17:23 CoreyMutter at eaton dot com
  2013-11-26 17:25 ` [Bug libc/16257] " CoreyMutter at eaton dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: CoreyMutter at eaton dot com @ 2013-11-26 17:23 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16257

            Bug ID: 16257
           Summary: Internal calls to gnu_indirect_functions skip
                    implementation, leaving gibberish behind
           Product: glibc
           Version: 2.18
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: CoreyMutter at eaton dot com
                CC: drepper.fsp at gmail dot com
            Target: powerpc-e300c3-linux-gnu
             Build: x86_64-redhat-linux

Created attachment 7305
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7305&action=edit
Test program

I'm seeing calls to gnu_indirect_functions from inside of libc (not crossing a
dynamic-link boundary), so they don't work. The failing case I have is on
powerpc 32-bit, and I have a workaround, but I believe the problem is more
general. 

My example case (details and test program attached): the time stamps of
syslog() messages are coming out as gibberish, with a constant
unrelated-to-reality time from each program. E.g.:
/tmp # ./testprog 
Local time: Nov 26 09:23:43 
/tmp # ./testprog 
Local time: Nov 26 09:23:52 
/tmp # tail /flash/log/messages
Oct 11 01:45:52 testprog[1500]: Test syslog message
Oct 11 01:45:52 testprog[1502]: Test syslog message
(The same timestamp happens no matter how many hours or days apart the messages
are. This particular one has a year in the 1930s). 

Analysis: 
__vsyslog_chk() calls time(). Disassembly (in case details attachment)
single-stepping shows that what it's calling is the ifunc, not the real target.
So the "now" struct is left untouched (and the return value is actually a
function address), leading to gibberish timestamps.
When the program itself calls time(), the dynamic linker calls the ifunc, gets
the address, calls the implementation that has INLINE_VSYSCALL() and it works
fine.

This *may* be a problem with ld instead of glibc; perhaps the linker should see
what we're doing and call an implementation instead. Or perhaps glibc should be
using the version of sysdeps/unix/sysv/linux/powerpc/time.c compiled without
-DSHARED for its internal calls. I see that that version does get built, don't
know why it's not being used by syslog(). 

I don't feel comfortable enough with glibc or binutils development to do a
"real" fix. Currently I'm using a workaround of patching that time.c and
gettimeofday.c to remove the indirect functions, instead always using
INLINE_VSYSCALL. As far as I can tell, those are the only indirect functions
being used internally on PPC (there appear to be many others on x86_64).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-13 11:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-26 17:23 [Bug libc/16257] New: Internal calls to gnu_indirect_functions skip implementation, leaving gibberish behind CoreyMutter at eaton dot com
2013-11-26 17:25 ` [Bug libc/16257] " CoreyMutter at eaton dot com
2014-01-12 13:52 ` neleai at seznam dot cz
2014-01-13 12:02 ` azanella at linux dot vnet.ibm.com
2014-01-13 12:03 ` azanella at linux dot vnet.ibm.com
2014-06-13 11:52 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).