Bug 11155

Summary: fstat broken on sparc64
Product: glibc Reporter: hideaki <hideaki>
Component: libcAssignee: David S. Miller <davem>
Status: RESOLVED FIXED    
Severity: normal CC: davem, glibc-bugs, jengelh
Priority: P2 Flags: fweimer: security-
Version: 2.10   
Target Milestone: ---   
Host: sparc64-unknown-linux-gnu Target: sparc64-unknown-linux-gnu
Build: sparc64-unknown-linux-gnu Last reconfirmed:
Attachments: test case

Description hideaki 2010-01-09 16:08:55 UTC
Calling fstat() in a C program compiled for sparc32 will eventually lead to the
'fstat64' syscall being made - as observed with 'strace'.
However, when compiled with -m64, strace shows that the inferior 'fstat' syscall
is executed, thereby giving a zero nanosecond part.
Comment 1 hideaki 2010-01-09 16:11:19 UTC
Created attachment 4505 [details]
test case

Compile this with -m64. You should observe:

1260745109.876573675
1260745109.000000000

When compiled with -static, objdump prints (for -m32):

0001d720 <fstat64>:
   1d720:	94 10 00 09	mov  %o1, %o2
   1d724:	92 10 00 08	mov  %o0, %o1
   1d728:	90 10 20 03	mov  3, %o0
   1d72c:	82 13 c0 00	mov  %o7, %g1
   1d730:	10 80 00 0c	b  1d760 <___fxstat64>

While with -m64:

000000000010d9c0 <fstat64>:
  10d9c0:	94 10 00 09	mov  %o1, %o2
  10d9c4:	92 10 00 08	mov  %o0, %o1
  10d9c8:	90 10 20 03	mov  3, %o0
  10d9cc:	82 13 c0 00	mov  %o7, %g1
  10d9d0:	10 68 00 0c	b  %xcc, 10da00 <__fxstat>

So __fxstat64 is not called in 64-bit mode. This looks like a glibc bug to me.
Comment 2 hideaki 2010-01-10 23:17:45 UTC
This trivial patch fixes it.

Index: glibc-2.10.1/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
===================================================================
--- glibc-2.10.1.orig/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
+++ glibc-2.10.1/sysdeps/unix/sysv/linux/sparc/sparc64/fxstat.c
@@ -1 +1 @@
-#include "../../fxstat.c"
+#include "../../i386/fxstat.c"
Comment 3 Jan Engelhardt 2010-06-27 15:41:00 UTC
So is this ever going to be fixed?
Comment 4 David S. Miller 2010-12-22 19:54:54 UTC
I plan to check this fix in, just as soon as I can get a successful
sparc64 build of the current tree.  It currently crashes when running
the rpc programs.
Comment 5 David S. Miller 2011-01-04 20:27:02 UTC
Fix committed to mainline.