All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [COMMITTED] [PATCH] syscalls: modify_ldt02: Fix failure
@ 2021-05-06 13:04 zhaogongyi
  2021-05-06 13:35 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: zhaogongyi @ 2021-05-06 13:04 UTC (permalink / raw)
  To: ltp

Hi Cyril, Petr,

I am sorry, It's my fault. It seems that restore to origin code is more better since it might create a core file.

Best Regards,
Gongyi


> 
> The test was wrong to begin with, if we want to get SEGFAULT from the
> waitpid() we cannot setup a handler that catches it and exits with 0.
> 
> Fixes: f5e8e6b11ce8 ("syscalls/modify_ldt: Replace TINFO with TPASS or
> TFAIL")
> Reported-by: Petr Vorel <pvorel@suse.cz>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  .../kernel/syscalls/modify_ldt/modify_ldt02.c     | 15 +--------------
>  1 file changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
> b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
> index e34d3d54d..f911aa5fd 100644
> --- a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
> +++ b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
> @@ -120,6 +120,7 @@ int main(int ac, char **av)
> 
>  		tst_old_flush();
>  		if ((pid = FORK_OR_VFORK()) == 0) {
> +			signal(SIGSEGV, SIG_DFL);
>  			val = read_segment(0);
>  			exit(1);
>  		}
> @@ -168,24 +169,10 @@ int read_segment(unsigned int index)
>  	return res;
>  }
> 
> -void sigsegv_handler(int sig)
> -{
> -	tst_resm(TINFO, "received signal: %d", sig);
> -	exit(0);
> -}
> -
>  void setup(void)
>  {
> -	struct sigaction act;
> -
> -	memset(&act, 0, sizeof(act));
> -	sigemptyset(&act.sa_mask);
> -
>  	tst_sig(FORK, DEF_HANDLER, cleanup);
> 
> -	act.sa_handler = sigsegv_handler;
> -	(void)sigaction(SIGSEGV, &act, NULL);
> -
>  	TEST_PAUSE;
>  }
> 
> --
> 2.26.3
> 
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [COMMITTED] [PATCH] syscalls: modify_ldt02: Fix failure
  2021-05-06 13:04 [LTP] [COMMITTED] [PATCH] syscalls: modify_ldt02: Fix failure zhaogongyi
@ 2021-05-06 13:35 ` Cyril Hrubis
  2021-05-06 18:26   ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2021-05-06 13:35 UTC (permalink / raw)
  To: ltp

Hi!
> I am sorry, It's my fault. It seems that restore to origin code is
> more better since it might create a core file.

No this is not solution either, since the original code was broken to
begin with.

We do have tst_no_corefile() in the test library, which should be called
by tests that cause SEGFAULT on purpose in order to avoid dumping a
core, but it looks like it's available only for new library tests. We
would have to convert the test to new library first if we wanted to
that.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [COMMITTED] [PATCH] syscalls: modify_ldt02: Fix failure
  2021-05-06 13:35 ` Cyril Hrubis
@ 2021-05-06 18:26   ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-05-06 18:26 UTC (permalink / raw)
  To: ltp

> Hi!
> > I am sorry, It's my fault. It seems that restore to origin code is
> > more better since it might create a core file.

> No this is not solution either, since the original code was broken to
> begin with.

> We do have tst_no_corefile() in the test library, which should be called
> by tests that cause SEGFAULT on purpose in order to avoid dumping a
> core, but it looks like it's available only for new library tests. We
> would have to convert the test to new library first if we wanted to
> that.

Thanks for info, I was not aware of tst_no_corefile().

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [COMMITTED] [PATCH] syscalls: modify_ldt02: Fix failure
  2021-05-06 11:51 Cyril Hrubis
@ 2021-05-06 12:43 ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-05-06 12:43 UTC (permalink / raw)
  To: ltp

Hi Cyril,

> The test was wrong to begin with, if we want to get SEGFAULT from the
> waitpid() we cannot setup a handler that catches it and exits with 0.

> Fixes: f5e8e6b11ce8 ("syscalls/modify_ldt: Replace TINFO with TPASS or TFAIL")

Thanks a lot!

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [COMMITTED] [PATCH] syscalls: modify_ldt02: Fix failure
@ 2021-05-06 11:51 Cyril Hrubis
  2021-05-06 12:43 ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2021-05-06 11:51 UTC (permalink / raw)
  To: ltp

The test was wrong to begin with, if we want to get SEGFAULT from the
waitpid() we cannot setup a handler that catches it and exits with 0.

Fixes: f5e8e6b11ce8 ("syscalls/modify_ldt: Replace TINFO with TPASS or TFAIL")
Reported-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 .../kernel/syscalls/modify_ldt/modify_ldt02.c     | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
index e34d3d54d..f911aa5fd 100644
--- a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
+++ b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
@@ -120,6 +120,7 @@ int main(int ac, char **av)
 
 		tst_old_flush();
 		if ((pid = FORK_OR_VFORK()) == 0) {
+			signal(SIGSEGV, SIG_DFL);
 			val = read_segment(0);
 			exit(1);
 		}
@@ -168,24 +169,10 @@ int read_segment(unsigned int index)
 	return res;
 }
 
-void sigsegv_handler(int sig)
-{
-	tst_resm(TINFO, "received signal: %d", sig);
-	exit(0);
-}
-
 void setup(void)
 {
-	struct sigaction act;
-
-	memset(&act, 0, sizeof(act));
-	sigemptyset(&act.sa_mask);
-
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-	act.sa_handler = sigsegv_handler;
-	(void)sigaction(SIGSEGV, &act, NULL);
-
 	TEST_PAUSE;
 }
 
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-06 18:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 13:04 [LTP] [COMMITTED] [PATCH] syscalls: modify_ldt02: Fix failure zhaogongyi
2021-05-06 13:35 ` Cyril Hrubis
2021-05-06 18:26   ` Petr Vorel
  -- strict thread matches above, loose matches on Subject: below --
2021-05-06 11:51 Cyril Hrubis
2021-05-06 12:43 ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.