[PATCH 0/4] selftests/nolibc: add user-space 'efault' handler

Zhangjin Wu falcon at tinylab.org
Tue May 30 03:47:38 PDT 2023


Hi, Willy, Thomas

This is not really for merge, but only let it work as a demo code to
test whether it is possible to restore the next test when there is a bad
pointer access in user-space [1].

Besides, a new 'run' command is added to 'NOLIBC_TEST' environment
variable or arguments to control the running iterations, this may be
used to test the reentrancy issues, but no failures found currently ;-)

With glibc, it works as following:

    $ ./nolibc-test run:2,syscall:28-30,stdlib:1
    Running iteration(s): 2

    Current iteration: 1

    Running test 'syscall', from 28 to 30
    28 dup3_m1 = -1 EBADF                                            [OK]
    29 efault_handler ! 11 SIGSEGV                                   [OK]
    30 execve_root = -1 EACCES                                       [OK]
    Errors during this test: 0

    Running test 'stdlib'
    1 getenv_blah = <(null)>                                         [OK]
    Errors during this test: 0

    Total number of errors in the 1 iteration(s): 0

    Current iteration: 2

    Running test 'syscall'
    28 dup3_m1 = -1 EBADF                                            [OK]
    29 efault_handler ! 11 SIGSEGV                                   [OK]
    30 execve_root = -1 EACCES                                       [OK]
    Errors during this test: 0

    Running test 'stdlib'
    1 getenv_blah = <(null)>                                         [OK]
    Errors during this test: 0

    Total number of errors in the 2 iteration(s): 0

With nolibc, it will be skipped (run:2,syscall:28-30,stdlib:10):

    Running iteration(s): 2

    Current iteration: 1

    Running test 'syscall', from 28 to 30
    28 dup3_m1 = -1 EBADF                                            [OK]
    29 efault_handler                                               [SKIPPED]
    30 execve_root = -1 EACCES                                       [OK]
    Errors during this test: 0

    Running test 'stdlib', from 10 to 10
    10 strrchr_foobar_o = <obar>                                     [OK]
    Errors during this test: 0

    Total number of errors in the 1 iteration(s): 0

    Current iteration: 2

    Running test 'syscall', from 28 to 30
    28 dup3_m1 = -1 EBADF                                            [OK]
    29 efault_handler                                               [SKIPPED]
    30 execve_root = -1 EACCES                                       [OK]
    Errors during this test: 0

    Running test 'stdlib', from 10 to 10
    10 strrchr_foobar_o = <obar>                                     [OK]
    Errors during this test: 0

    Total number of errors in the 2 iteration(s): 0

Best regards,
Zhangjin
---

[1]: https://lore.kernel.org/linux-riscv/20230529113143.GB2762@1wt.eu/ 

Zhangjin Wu (4):
  selftests/nolibc: allow rerun with the same settings
  selftests/nolibc: add rerun support
  selftests/nolibc: add user space efault handler
  selftests/nolibc: add user-space efault restore test case

 tools/testing/selftests/nolibc/nolibc-test.c | 247 +++++++++++++++++--
 1 file changed, 221 insertions(+), 26 deletions(-)

-- 
2.25.1




More information about the linux-riscv mailing list