[uclibc-ng-devel] statfs call corrupts memory struct statfs too small

Waldemar Brodkorb wbx at uclibc-ng.org
Fri Jun 29 19:32:15 CEST 2018


Hi Geoff,
Geoff Levand wrote,

> Hi,
> 
> I experienced seg faults due to stack corruption when
> calling statfs() with an automatic struct statfs variable.
>  
> It seems there is a mismatch between the struct statfs used
> by libc and that used by the arm64 kernel.  The call to
> statfs() writes 120 bytes, but struct statfs is only 88
> bytes.  The attached test program shows this.
> 
> Building for arm64.
> libuClibc-1.0.30
> kernel: Linux-4.17.3
> 
> Comparing these files:
> 
>  https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/include/uapi/asm-generic/statfs.h?h=v4.17.3#n23
>  https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/common-generic/bits/statfs.h?h=v1.0.30#n16
> 
> I see for the kernel all fields of struct statfs except f_fsid are the
> same length at 64 bits for arm64, and that gives 120 bytes.  That differs
> from the libc version which has some 32 bit fields.

Do you have a patch in mind fixing this difference?

best regards
 Waldemar


More information about the devel mailing list