sgx-lkl icon indicating copy to clipboard operation
sgx-lkl copied to clipboard

[Tests] statfs() syscall return zero for total blocks, available blocks & free blocks fields

Open shaikshavali1 opened this issue 4 years ago • 3 comments

In sgx-lkl, the file system information returned from statfs() syscall contains zero for the parameters total number of blocks(f_blocks), free blocks (f_bfree) and free blocks available to unprivileged user(f_bavail).

shaikshavali1 avatar May 21 '20 08:05 shaikshavali1

background of the issue: Original LTP test case “kernel-syscalls-sendfile-sendfile09” check 5GB available free space in current directory path by invoking test framework function “tst_fs_has_free”. This test framework function reads the statefs details of file system and checks available memory (f_bavail * f_bsize) with 5GB.

Based on GDB logs it looks the statfs data returned from kernel has 0 value for total number of blocks(f_blocks), free blocks (f_bfree) and free blocks available to unprivileged user(f_bavail).

shaikshavali1 avatar May 21 '20 08:05 shaikshavali1

What is the bug here? Are these incorrect values? With a minimal disk image, these are the values that I would expect. Does the LTP test runner need an image with 5GB free for this to pass?

davidchisnall avatar May 24 '20 15:05 davidchisnall

Original Test Case Description: This test case is to test "sendfile09" system call on large files. Below specified sub test case. 1. call sendfile(2) with offset at 0. 2. call sendfile(2) with offset at 3GB. In both the cases 1GB data is send. Link: https://github.com/linux-test-project/ltp/blob/c5311d26fb80988de010301c0855a5f65442c6c0/testcases/kernel/syscalls/sendfile/sendfile09.c#L139

Modifications: This test case is modified to use maximum of 4MB.

Problem/Issue: This test case checks for available free space in the file system. It performs below algorithm.

  1. Read the file system statistics by invoking "statfs" system call and calculate (f_bavail * f_bsize) the available free size.
  2. Problem here is statfs always returning below values as 0 and test case failed. (this failure is observed even after reducing the size to 4MB) a. total number of blocks(f_blocks) b. free blocks (f_bfree) c. free blocks available to unprivileged user(f_bavail). Link: https://github.com/linux-test-project/ltp/blob/c5311d26fb80988de010301c0855a5f65442c6c0/lib/tst_fs_has_free.c#L34

GDB Logs: (gdb) bt 0 tst_fs_has_free_ (cleanup=cleanup@entry=0x0, path=path@entry=0x7fff3dad06c6 ".", size=size@entry=5, mult=mult@entry=1073741824) at tst_fs_has_free.c:31 1 0x00007fff3dabf69e in tst_fs_has_free (mult=1073741824, size=5, path=0x7fff3dad06c6 ".", cleanup=0x0) at ../../../../include/tst_fs.h:223 2 setup () at sendfile09.c:139 3 main (ac=1, av=0x7fff40b5ee98) at sendfile09.c:186 4 0x00007fff00538402 in libc_start_main_stage2 (main=0x7fff3dabf610

, argc=1, argv=0x7fff40b5ee98) at src/env/__libc_start_main.c:168 5 0x00007fff00538361 in __libc_start_main (main=0x7fff3dabf610
, argc=1, argv=0x7fff40b5ee98) at src/env/__libc_start_main.c:153 6 0x00007fff3dabf84c in _start_c (p=) at crt/crt1.c:17 7 0x00007fff3dabf824 in _start () 8 0x0000000000000001 in ?? () 9 0x00007fff00b65930 in ?? () 10 0x0000000000000000 in ?? () (gdb) s 34 in tst_fs_has_free.c (gdb) s 31 in tst_fs_has_free.c (gdb) s 34 in tst_fs_has_free.c (gdb) s 31 in tst_fs_has_free.c (gdb) s 34 in tst_fs_has_free.c (gdb) s __statfs (path=0x7fff3dad06c6 ".", buf=0x7fff40b5ed30) at src/stat/statvfs.c:7 7 *buf = (struct statfs){0}; (gdb) bt 0 _statfs (path=0x7fff3dad06c6 ".", buf=0x7fff40b5ed30) at src/stat/statvfs.c:7 1 0x00007fff3dac4ab2 in tst_fs_has_free (cleanup=cleanup@entry=0x0, path=path@entry=0x7fff3dad06c6 ".", size=size@entry=5, mult=mult@entry=1073741824) at tst_fs_has_free.c:34 2 0x00007fff3dabf69e in tst_fs_has_free (mult=1073741824, size=5, path=0x7fff3dad06c6 ".", cleanup=0x0) at ../../../../include/tst_fs.h:223 3 setup () at sendfile09.c:139 4 main (ac=1, av=0x7fff40b5ee98) at sendfile09.c:186 5 0x00007fff00538402 in libc_start_main_stage2 (main=0x7fff3dabf610
, argc=1, argv=0x7fff40b5ee98) at src/env/__libc_start_main.c:168 6 0x00007fff00538361 in __libc_start_main (main=0x7fff3dabf610
, argc=1, argv=0x7fff40b5ee98) at src/env/__libc_start_main.c:153 7 0x00007fff3dabf84c in _start_c (p=) at crt/crt1.c:17 8 0x00007fff3dabf824 in start () 9 0x0000000000000001 in ?? () 10 0x00007fff00b65930 in ?? () 11 0x0000000000000000 in ?? () (gdb) s 11 return syscall(SYS_statfs, path, buf); (gdb) n (gdb) s tst_fs_has_free (cleanup=cleanup@entry=0x0, path=path@entry=0x7fff3dad06c6 ".", size=size@entry=5, mult=mult@entry=1073741824) at tst_fs_has_free.c:40 40 tst_fs_has_free.c: No such file or directory. (gdb)

shaikshavali1 avatar Jul 01 '20 12:07 shaikshavali1