On 4/21/2010 8:06 AM, Josh Boyer wrote:
> I have a case where uClibc will segfault in the fstatfs call.  The testcase
> is pretty simple, and just tests the error cases that should be returned for
> EBADF and EFAULT.  The EFAULT case is where the crash occurs.
>   

In hopes that it helps, attached is a change I made last month to our
uClibc to fix this problem (as a Perforce diff).  Unfortunately our
uClibc forked off the NPTL branch in the SVN days (at change 22990) so a
fair amount of divergence has developed, so I haven't been trying to
push back changes recently.  Translation: I hope this helps Josh, but
please don't tell me this isn't the right way to push changes upstream
-- I know :-)

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

Change 98707 by cmetc...@cmetcalf-m2 on 2010/03/30 15:46:59

        Fix statfs64() and fstatfs64() in uclibc to use the 64-bit kernel
        API instead of some wacky uClibc compatibility wrapper.
        
        It's not clear why uClibc was set up this way, but it means that
        programs using the 64-bit APIs in 32-bit mode weren't getting
        full 32-bit data.  Now we just provide separate statfs() and
        statfs64() implementations (invoked in the usual ways via
        -D_FILE_OFFSET_BITS=64, etc.) for 32-bit platforms, and on
        64-bit platforms we provide statfs64() as an alias for statfs(),
        which is the normal way uclibc does things elsewhere.
        
        This was discovered by an LTP test failure (a bogus pointer
        caused a SIGSEGV in the wrapper, rather than EFAULT in the kernel).
        
          CR: none, fiddly but basically straightforward

Affected files ...

... //tilera/user/cmetcalf/main/tools/uclibc/libc/misc/statfs/fstatfs64.c#2 edit
... //tilera/user/cmetcalf/main/tools/uclibc/libc/misc/statfs/statfs64.c#2 edit
... 
//tilera/user/cmetcalf/main/tools/uclibc/libc/sysdeps/linux/common/fstatfs.c#2 
edit
... 
//tilera/user/cmetcalf/main/tools/uclibc/libc/sysdeps/linux/common/fstatfs64.c#1
 add
... 
//tilera/user/cmetcalf/main/tools/uclibc/libc/sysdeps/linux/common/statfs.c#2 
edit
... 
//tilera/user/cmetcalf/main/tools/uclibc/libc/sysdeps/linux/common/statfs64.c#1 
add

Differences ...

==== //tilera/user/cmetcalf/main/tools/uclibc/libc/misc/statfs/fstatfs64.c#2 
(text) ====

@@ -24,6 +24,10 @@
 #include <sys/statfs.h>
 #include <sys/statvfs.h>
 #include <stddef.h>
+#include <sys/syscall.h>
+#include <bits/wordsize.h>
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32 && !defined __NR_fstatfs64
 
 /* Experimentally off - libc_hidden_proto(memcpy) */
 libc_hidden_proto(fstatfs)
@@ -51,3 +55,5 @@
     return 0;
 }
 libc_hidden_def(fstatfs64)
+
+#endif

==== //tilera/user/cmetcalf/main/tools/uclibc/libc/misc/statfs/statfs64.c#2 
(text) ====

@@ -22,7 +22,10 @@
 #include <string.h>
 #include <stddef.h>
 #include <sys/statfs.h>
+#include <sys/syscall.h>
+#include <bits/wordsize.h>
 
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32 && !defined __NR_fstatfs64
 
 /* Experimentally off - libc_hidden_proto(memcpy) */
 libc_hidden_proto(statfs)
@@ -50,3 +53,5 @@
     return 0;
 }
 libc_hidden_def(statfs64)
+
+#endif

==== 
//tilera/user/cmetcalf/main/tools/uclibc/libc/sysdeps/linux/common/fstatfs.c#2 
(text) ====

@@ -8,6 +8,12 @@
  */
 
 #include <sys/syscall.h>
+#include <bits/wordsize.h>
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 && !defined __NR_fstatfs64
+#define fstatfs64 fstatfs64_hide
+#endif
+
 #include <sys/vfs.h>
 
 #if !defined __UCLIBC_LINUX_SPECIFIC__
@@ -23,6 +29,9 @@
 # endif
 #endif
 #endif
+
+#undef fstatfs64
+
 extern __typeof(fstatfs) __libc_fstatfs;
 libc_hidden_proto(__libc_fstatfs)
 #define __NR___libc_fstatfs __NR_fstatfs
@@ -33,4 +42,10 @@
 libc_hidden_proto(fstatfs)
 weak_alias(__libc_fstatfs,fstatfs)
 libc_hidden_weak(fstatfs)
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 && !defined __NR_fstatfs64
+extern __typeof(fstatfs) fstatfs64;
+strong_alias(__libc_fstatfs,__GI_fstatfs64)
+weak_alias(__libc_fstatfs,fstatfs64)
+#endif
 #endif

==== 
//tilera/user/cmetcalf/main/tools/uclibc/libc/sysdeps/linux/common/statfs.c#2 
(text) ====

@@ -8,10 +8,16 @@
  */
 
 #include <sys/syscall.h>
-#include <string.h>
-#include <sys/param.h>
+#include <bits/wordsize.h>
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 && !defined __NR_statfs64
+#define statfs64 statfs64_ignore
+#endif
+
 #include <sys/vfs.h>
 
+#undef statfs64
+
 extern __typeof(statfs) __libc_statfs;
 libc_hidden_proto(__libc_statfs)
 #define __NR___libc_statfs __NR_statfs
@@ -23,3 +29,9 @@
 weak_alias(__libc_statfs,statfs)
 libc_hidden_weak(statfs)
 #endif
+
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 && !defined __NR_statfs64
+extern __typeof(statfs) statfs64;
+strong_alias(__libc_statfs,__GI_statfs64)
+weak_alias(__libc_statfs,statfs64)
+#endif
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to