linux-user: Let sigaction query SIGKILL/SIGSTOP
cover linux-user: Let sigaction query SIGKILL/SIGSTOP
valgrind fails to start under linux-user, one of the reasons being that it tries to query all the sigactions, which qemu (unlike the real kernel) doesn't allow for SIGKILL/SIGSTOP.
Patch 1 lifts this restriction, patch 2 adds a test.
Ilya Leoshkevich (2):
linux-user: Let sigaction query SIGKILL/SIGSTOP tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP
linux-user/signal.c | 6 +++++- tests/tcg/multiarch/linux-test.c | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
PATCH 1/2 linux-user: Let sigaction query SIGKILL/SIGSTOP
The kernel allows doing this, so let's allow this in qemu as well. Valgrind relies on this.
--- linux-user/signal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/signal.c +5 -1
@@ -851,7 +851,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,trace_signal_do_sigaction_guest (sig,TARGET_NSIG ); -if (sig <1 || sig >TARGET_NSIG || sig ==TARGET_SIGKILL || sig ==TARGET_SIGSTOP ) { +if (sig <1 || sig >TARGET_NSIG ) { +return -TARGET_EINVAL ; + } + +if (act && (sig ==TARGET_SIGKILL || sig ==TARGET_SIGSTOP )) {return -TARGET_EINVAL ; }
Signature · 1 line
2.31.1
Le 01/06/2021 à 16:55, Ilya Leoshkevich a écrit :
Quoted 16 lines
The kernel allows doing this, so let's allow this in qemu as well. Valgrind relies on this.
Signed-off-by Ilya Leoshkevich <[email protected]>--- linux-user/signal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)linux-user/signal.c +0
-0@@ -851,7 +851,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,trace_signal_do_sigaction_guest (sig,TARGET_NSIG );
linux-user/signal.c int do_sigaction(int sig, const struct target_sigaction *act, · line 861
Quoted 10 lines
linux-user/signal.c +5
-1-if (sig <1 || sig >TARGET_NSIG || sig ==TARGET_SIGKILL || sig ==TARGET_SIGSTOP ) { +if (sig <1 || sig >TARGET_NSIG ) { +return -TARGET_EINVAL ; + } + +if (act && (sig ==TARGET_SIGKILL || sig ==TARGET_SIGSTOP )) {return -TARGET_EINVAL ; }
Laurent Vivier
AppliedLe 01/06/2021 à 16:55, Ilya Leoshkevich a écrit :
Quoted 16 lines
The kernel allows doing this, so let's allow this in qemu as well. Valgrind relies on this.
Signed-off-by Ilya Leoshkevich <[email protected]>--- linux-user/signal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)linux-user/signal.c +0
-0@@ -851,7 +851,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,trace_signal_do_sigaction_guest (sig,TARGET_NSIG );
linux-user/signal.c int do_sigaction(int sig, const struct target_sigaction *act, · line 861
Quoted 10 lines
linux-user/signal.c +5
-1-if (sig <1 || sig >TARGET_NSIG || sig ==TARGET_SIGKILL || sig ==TARGET_SIGSTOP ) { +if (sig <1 || sig >TARGET_NSIG ) { +return -TARGET_EINVAL ; + } + +if (act && (sig ==TARGET_SIGKILL || sig ==TARGET_SIGSTOP )) {return -TARGET_EINVAL ; }
Applied to my linux-user-for-6.1 branch.
Thanks,
Laurent
PATCH 2/2 tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP
In reply to Ilya LeoshkevichVerify that querying is allowed, but making changes isn't.
--- tests/tcg/multiarch/linux-test.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tests/tcg/multiarch/linux-test.c +9 -0
@@ -496,6 +496,15 @@ static void test_signal(void)sigemptyset (&act.sa_mask); act.sa_flags =0 ;chk_error (sigaction (SIGSEGV , &act,NULL )); + +if (sigaction (SIGKILL , &act,NULL ) ==0 ) { +error ("sigaction(SIGKILL, &act, NULL) must not succeed" ); + } +if (sigaction (SIGSTOP , &act,NULL ) ==0 ) { +error ("sigaction(SIGSTOP, &act, NULL) must not succeed" ); + } +chk_error (sigaction (SIGKILL ,NULL , &act)); +chk_error (sigaction (SIGSTOP ,NULL , &act)); }#define SHM_SIZE 32768
Signature · 1 line
2.31.1
Re: [PATCH 2/2] tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP
Le 01/06/2021 à 16:56, Ilya Leoshkevich a écrit :
Quoted 18 lines
Verify that querying is allowed, but making changes isn't.
Signed-off-by Ilya Leoshkevich <[email protected]>--- tests/tcg/multiarch/linux-test.c | 9 +++++++++ 1 file changed, 9 insertions(+)tests/tcg/multiarch/linux-test.c +2
-0@@ -496,6 +496,15 @@ static void test_signal(void)sigemptyset (&act.sa_mask); act.sa_flags =0 ;chk_error (sigaction (SIGSEGV , &act,NULL )); + +if (sigaction (SIGKILL , &act,NULL ) ==0 ) {
tests/tcg/multiarch/linux-test.c static void test_signal(void) · line 510
Quoted 10 lines
tests/tcg/multiarch/linux-test.c +7
-0+error ("sigaction(SIGKILL, &act, NULL) must not succeed" ); + } +if (sigaction (SIGSTOP , &act,NULL ) ==0 ) { +error ("sigaction(SIGSTOP, &act, NULL) must not succeed" ); + } +chk_error (sigaction (SIGKILL ,NULL , &act)); +chk_error (sigaction (SIGSTOP ,NULL , &act)); }#define SHM_SIZE 32768
Alex, I will merge this via linux-user, is it ok for you?
Thanks,
Laurent
Laurent Vivier
AppliedRe: [PATCH 2/2] tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP
In reply to Ilya LeoshkevichLe 01/06/2021 à 16:56, Ilya Leoshkevich a écrit :
Quoted 18 lines
Verify that querying is allowed, but making changes isn't.
Signed-off-by Ilya Leoshkevich <[email protected]>--- tests/tcg/multiarch/linux-test.c | 9 +++++++++ 1 file changed, 9 insertions(+)tests/tcg/multiarch/linux-test.c +2
-0@@ -496,6 +496,15 @@ static void test_signal(void)sigemptyset (&act.sa_mask); act.sa_flags =0 ;chk_error (sigaction (SIGSEGV , &act,NULL )); + +if (sigaction (SIGKILL , &act,NULL ) ==0 ) {
tests/tcg/multiarch/linux-test.c static void test_signal(void) · line 510
Quoted 10 lines
tests/tcg/multiarch/linux-test.c +7
-0+error ("sigaction(SIGKILL, &act, NULL) must not succeed" ); + } +if (sigaction (SIGSTOP , &act,NULL ) ==0 ) { +error ("sigaction(SIGSTOP, &act, NULL) must not succeed" ); + } +chk_error (sigaction (SIGKILL ,NULL , &act)); +chk_error (sigaction (SIGSTOP ,NULL , &act)); }#define SHM_SIZE 32768
Applied to my linux-user-for-6.1 branch.
Thanks,
Laurent