lsds / sgx-lkl

SGX-LKL Library OS for running Linux applications inside of Intel SGX enclaves
MIT License
257 stars 89 forks source link

[TEST]: Signal mask is unset for the signal during its handler execution #700

Open shaikshavali1 opened 4 years ago

shaikshavali1 commented 4 years ago

Original Test case: Use sigaction(2) to set a signal handler for SIGUSR1. There are 4 test cases: 1) Set SA_RESETHAND and SA_SIGINFO. When the handler runs, SA_SIGINFO should be set. 2) Set SA_RESETHAND. When the handler runs, SIGUSR1 should be masked (SA_RESETHAND makes sigaction behave as if SA_NODEFER was not set). 3) Same as case 2, but when the handler is established, sa_mask is set to include SIGUSR1. Ensure that SIGUSR1 is indeed masked even if SA_RESETHAND is set. 4) A signal generated from an interface or condition that does not provide siginfo (such as pthread_kill(3)) should invoke the handler with a non-NULL siginfo pointer.

Test case Link: https://github.com/lsds/ltp/blob/sgx-lkl/testcases/kernel/syscalls/sigaction/sigaction01.c

Problem/Issue: The test case 2 is failed with below error message. sigaction01 2 TFAIL : sigaction01.c:146: SA_RESETHAND should cause sig tobe masked when the handler executes.

Link: https://github.com/lsds/ltp/blob/ac1696c2b7ba626a7ccb9cb71e661fa288044d9e/testcases/kernel/syscalls/sigaction/sigaction01.c#L144

SGX_LKL is not blocked/masked the SIGUSR1 signal when the signal mask was read inside the registered application's signal handler.

GDB Logs:

[[ SGX-LKL ]] libc_start_main_stage2(): Calling app main: /ltp/testcases/kernel/syscalls/sigaction/sigaction01 [Switching to Thread 0x7fff919b0700 (LWP 5036)]

Thread 6 "ENCLAVE" hit Breakpoint 1, handle_signal (ksig=0x7fe040b46c10, uctx=0x7fe040b46c60) at arch/lkl/kernel/signal.c:37 37 { (gdb) b handler Breakpoint 2 at 0x7fe03daa7950: file sigaction01.c, line 90. (gdb) s 38 pr_notice("ksig.sig = %d", ksig->sig); (gdb) p ksig $1 = (struct ksignal ) 0x7fe040b46c10 (gdb) p ksig $2 = {ka = {sa = {sa_handler = 0x7fe03daa7950 , sa_flags = 18446744071629176836, sa_mask = {sig = {140600054904965}}}}, info = {{ si_signo = 10, si_errno = 0, si_code = 0, _sifields = {_kill = {_pid = 36, _uid = 0}, _timer = {_tid = 36, _overrun = 0, _sigval = { sival_int = 0, sival_ptr = 0x0}, _sys_private = 0}, _rt = {_pid = 36, _uid = 0, _sigval = {sival_int = 0, sival_ptr = 0x0}}, _sigchld = {_pid = 36, _uid = 0, _status = 0, _utime = 0, _stime = 0}, _sigfault = {_addr = 0x24, {_addr_lsb = 0, _addr_bnd = { _dummy_bnd = "\000\000\000\000\000\000\000", _lower = 0x0, _upper = 0x0}, _addr_pkey = {_dummy_pkey = "\000\000\000\000\000\000\000", _pkey = 0}}}, _sigpoll = {_band = 36, _fd = 0}, _sigsys = {_call_addr = 0x24, _syscall = 0, _arch = 0}}}}, sig = 10} (gdb) c Continuing.

Thread 6 "ENCLAVE" hit Breakpoint 2, handler (sig=10, sip=0x7fe040b46c28, ucp=0x7fe040b46c60) at sigaction01.c:90 90 sigaction01.c: No such file or directory. (gdb) s 98 in sigaction01.c (gdb) s 90 in sigaction01.c (gdb) c Continuing. sigaction01 1 TPASS : SA_RESETHAND did not cause SA_SIGINFO to be cleared

Thread 6 "ENCLAVE" hit Breakpoint 1, handle_signal (ksig=0x7fe040b46c10, uctx=0x7fe040b46c60) at arch/lkl/kernel/signal.c:37 37 { (gdb) p ksig $3 = (struct ksignal ) 0x7fe040b46c10 (gdb) p ksig $4 = {ka = {sa = {sa_handler = 0x7fe03daa7950 , sa_flags = 18446744071629176832, sa_mask = {sig = {140600054904965}}}}, info = {{ si_signo = 10, si_errno = 0, si_code = 0, _sifields = {_kill = {_pid = 36, _uid = 0}, _timer = {_tid = 36, _overrun = 0, _sigval = { sival_int = 0, sival_ptr = 0x0}, _sys_private = 0}, _rt = {_pid = 36, _uid = 0, _sigval = {sival_int = 0, sival_ptr = 0x0}}, _sigchld = {_pid = 36, _uid = 0, _status = 0, _utime = 0, _stime = 0}, _sigfault = {_addr = 0x24, {_addr_lsb = 0, _addr_bnd = { _dummy_bnd = "\000\000\000\000\000\000\000", _lower = 0x0, _upper = 0x0}, _addr_pkey = {_dummy_pkey = "\000\000\000\000\000\000\000", _pkey = 0}}}, _sigpoll = {_band = 36, _fd = 0}, _sigsys = {_call_addr = 0x24, _syscall = 0, _arch = 0}}}}, sig = 10} (gdb) c Continuing. [ 195.298110] ksig.sig = 10

Thread 6 "ENCLAVE" hit Breakpoint 2, handler (sig=10, sip=0x7fe040b46c28, ucp=0x7fe040b46c60) at sigaction01.c:90 90 sigaction01.c: No such file or directory. (gdb) s 98 in sigaction01.c (gdb) s 90 in sigaction01.c (gdb) s 98 in sigaction01.c (gdb)

davidchisnall commented 4 years ago

I believe this is a duplicate of #644.