All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/5] mq_timedsend01: sigtimedwait01: Workaround segfault on libc variant on 32 bit
@ 2024-11-14 14:40 Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 1/5] mq_timedsend01: Fix different signedness error on 32bit Petr Vorel
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Petr Vorel @ 2024-11-14 14:40 UTC (permalink / raw)
  To: ltp

Hi,

similar patchset to
https://patchwork.ozlabs.org/project/ltp/patch/20241112171831.156440-2-pvorel@suse.cz/

Kind regards,
Petr

Petr Vorel (5):
  mq_timedsend01: Fix different signedness error on 32bit
  mq_timedsend01: Remove unneeded designated initializers
  mq_timedsend01: Workaround segfault on libc variant on 32 bit
  libs/sigwait: Workaround segfault on libc variant on 32 bit
  libs/sigwait: Use safe/test macros

 libs/sigwait/sigwait.c                        |  47 ++++----
 .../syscalls/mq_timedsend/mq_timedsend01.c    | 104 +++++++++++-------
 2 files changed, 86 insertions(+), 65 deletions(-)

-- 
2.45.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 1/5] mq_timedsend01: Fix different signedness error on 32bit
  2024-11-14 14:40 [LTP] [PATCH 0/5] mq_timedsend01: sigtimedwait01: Workaround segfault on libc variant on 32 bit Petr Vorel
@ 2024-11-14 14:40 ` Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 2/5] mq_timedsend01: Remove unneeded designated initializers Petr Vorel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2024-11-14 14:40 UTC (permalink / raw)
  To: ltp

mq_timedsend01.c:223:21: warning: comparison of integer expressions of
different signedness: ‘unsigned int’ and ‘long int’ [-Wsign-compare]

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
index 334131402c..2636066861 100644
--- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
+++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
@@ -235,7 +235,7 @@ static void do_test(unsigned int i)
 		}
 	}
 
-	if (tc->len != TST_RET) {
+	if ((long)tc->len != TST_RET) {
 		tst_res(TFAIL, "mq_timedreceive() wrong length %ld, expected %u",
 			TST_RET, tc->len);
 		return;
-- 
2.45.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 2/5] mq_timedsend01: Remove unneeded designated initializers
  2024-11-14 14:40 [LTP] [PATCH 0/5] mq_timedsend01: sigtimedwait01: Workaround segfault on libc variant on 32 bit Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 1/5] mq_timedsend01: Fix different signedness error on 32bit Petr Vorel
@ 2024-11-14 14:40 ` Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit Petr Vorel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2024-11-14 14:40 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 .../kernel/syscalls/mq_timedsend/mq_timedsend01.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
index 2636066861..35bf4445f5 100644
--- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
+++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
@@ -22,28 +22,19 @@ static void *bad_addr;
 static struct test_case tcase[] = {
 	{
 		.fd = &fd,
-		.len = 0,
-		.ret = 0,
-		.err = 0,
 	},
 	{
 		.fd = &fd,
 		.len = 1,
-		.ret = 0,
-		.err = 0,
 	},
 	{
 		.fd = &fd,
 		.len = MAX_MSGSIZE,
-		.ret = 0,
-		.err = 0,
 	},
 	{
 		.fd = &fd,
 		.len = 1,
 		.prio = MQ_PRIO_MAX - 1,
-		.ret = 0,
-		.err = 0,
 	},
 	{
 		.fd = &fd,
@@ -53,19 +44,16 @@ static struct test_case tcase[] = {
 	},
 	{
 		.fd = &fd_invalid,
-		.len = 0,
 		.ret = -1,
 		.err = EBADF,
 	},
 	{
 		.fd = &fd_maxint,
-		.len = 0,
 		.ret = -1,
 		.err = EBADF,
 	},
 	{
 		.fd = &fd_root,
-		.len = 0,
 		.ret = -1,
 		.err = EBADF,
 	},
@@ -86,7 +74,6 @@ static struct test_case tcase[] = {
 		.fd = &fd,
 		.len = 16,
 		.tv_sec = -1,
-		.tv_nsec = 0,
 		.rq = &ts,
 		.send = 1,
 		.ret = -1,
@@ -95,7 +82,6 @@ static struct test_case tcase[] = {
 	{
 		.fd = &fd,
 		.len = 16,
-		.tv_sec = 0,
 		.tv_nsec = -1,
 		.rq = &ts,
 		.send = 1,
@@ -105,7 +91,6 @@ static struct test_case tcase[] = {
 	{
 		.fd = &fd,
 		.len = 16,
-		.tv_sec = 0,
 		.tv_nsec = 1000000000,
 		.rq = &ts,
 		.send = 1,
-- 
2.45.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit
  2024-11-14 14:40 [LTP] [PATCH 0/5] mq_timedsend01: sigtimedwait01: Workaround segfault on libc variant on 32 bit Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 1/5] mq_timedsend01: Fix different signedness error on 32bit Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 2/5] mq_timedsend01: Remove unneeded designated initializers Petr Vorel
@ 2024-11-14 14:40 ` Petr Vorel
  2024-11-15 13:13   ` Jan Stancek
  2024-11-14 14:40 ` [LTP] [PATCH 4/5] libs/sigwait: " Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 5/5] libs/sigwait: Use safe/test macros Petr Vorel
  4 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2024-11-14 14:40 UTC (permalink / raw)
  To: ltp

EFAULT test segfaults on newer kernels (e.g. 6.4) on libc variant on
32bit.  Similarly to 1d4d5a0750 use typical LTP workaround to test by
forked child + checking the terminating signal.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 .../syscalls/mq_timedsend/mq_timedsend01.c    | 87 ++++++++++++++-----
 1 file changed, 63 insertions(+), 24 deletions(-)

diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
index 35bf4445f5..2cec749f48 100644
--- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
+++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
@@ -143,34 +143,15 @@ static void setup(void)
 	setup_common();
 }
 
-static void do_test(unsigned int i)
+static void verify_mqt_send_receive(unsigned int i, pid_t pid)
 {
 	struct time64_variants *tv = &variants[tst_variant];
 	const struct test_case *tc = &tcase[i];
 	unsigned int j;
 	unsigned int prio;
-	size_t len = MAX_MSGSIZE;
-	char rmsg[len];
-	pid_t pid = -1;
+	char rmsg[MAX_MSGSIZE];
 	void *msg_ptr, *abs_timeout;
 
-	tst_ts_set_sec(&ts, tc->tv_sec);
-	tst_ts_set_nsec(&ts, tc->tv_nsec);
-
-	if (tc->signal)
-		pid = set_sig(tc->rq, tv->clock_gettime);
-
-	if (tc->timeout)
-		set_timeout(tc->rq, tv->clock_gettime);
-
-	if (tc->send) {
-		for (j = 0; j < MSG_LENGTH; j++)
-			if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
-				tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
-				return;
-			}
-	}
-
 	if (tc->bad_msg_addr)
 		msg_ptr = bad_addr;
 	else
@@ -200,7 +181,7 @@ static void do_test(unsigned int i)
 		return;
 	}
 
-	TEST(tv->mqt_receive(*tc->fd, rmsg, len, &prio, tst_ts_get(tc->rq)));
+	TEST(tv->mqt_receive(*tc->fd, rmsg, MAX_MSGSIZE, &prio, tst_ts_get(tc->rq)));
 
 	if (*tc->fd == fd)
 		cleanup_queue(fd);
@@ -241,8 +222,66 @@ static void do_test(unsigned int i)
 		}
 	}
 
-	tst_res(TPASS, "mq_timedreceive() returned %ld, priority %u, length: %zu",
-			TST_RET, prio, len);
+	tst_res(TPASS, "mq_timedreceive() returned %ld, priority %u, length: %i",
+			TST_RET, prio, MAX_MSGSIZE);
+}
+
+static void test_bad_addr(unsigned int i)
+{
+	struct time64_variants *tv = &variants[tst_variant];
+	pid_t pid;
+	int status;
+
+	pid = SAFE_FORK();
+	if (!pid) {
+		verify_mqt_send_receive(i, pid);
+		_exit(0);
+	}
+
+	SAFE_WAITPID(pid, &status, 0);
+
+	if (WIFEXITED(status) && !WEXITSTATUS(status))
+		return;
+
+	if (tv->ts_type == TST_LIBC_TIMESPEC &&
+		WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
+		tst_res(TPASS, "Child killed by expected signal");
+		return;
+	}
+
+	tst_res(TFAIL, "Child %s", tst_strstatus(status));
+}
+
+static void do_test(unsigned int i)
+{
+	struct time64_variants *tv = &variants[tst_variant];
+	const struct test_case *tc = &tcase[i];
+	unsigned int j;
+	pid_t pid = -1;
+
+	tst_ts_set_sec(&ts, tc->tv_sec);
+	tst_ts_set_nsec(&ts, tc->tv_nsec);
+
+	if (tc->bad_ts_addr) {
+		test_bad_addr(i);
+		return;
+	}
+
+	if (tc->signal)
+		pid = set_sig(tc->rq, tv->clock_gettime);
+
+	if (tc->timeout)
+		set_timeout(tc->rq, tv->clock_gettime);
+
+	if (tc->send) {
+		for (j = 0; j < MSG_LENGTH; j++)
+			if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
+				tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
+				return;
+			}
+	}
+
+	verify_mqt_send_receive(i, pid);
 }
 
 static struct tst_test test = {
-- 
2.45.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 4/5] libs/sigwait: Workaround segfault on libc variant on 32 bit
  2024-11-14 14:40 [LTP] [PATCH 0/5] mq_timedsend01: sigtimedwait01: Workaround segfault on libc variant on 32 bit Petr Vorel
                   ` (2 preceding siblings ...)
  2024-11-14 14:40 ` [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit Petr Vorel
@ 2024-11-14 14:40 ` Petr Vorel
  2024-11-14 14:40 ` [LTP] [PATCH 5/5] libs/sigwait: Use safe/test macros Petr Vorel
  4 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2024-11-14 14:40 UTC (permalink / raw)
  To: ltp

test_bad_address3() test which tests EFAULT segfaults on newer kernels
(e.g. 6.4) on libc variant on 32bit.  Similarly to 1d4d5a0750 use
typical LTP workaround to test by forked child + checking the
terminating signal.

This got broken on sigtimedwait01.c (but not on rt_sigtimedwait01.c).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 libs/sigwait/sigwait.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/libs/sigwait/sigwait.c b/libs/sigwait/sigwait.c
index 86899954d7..cf3c445b4a 100644
--- a/libs/sigwait/sigwait.c
+++ b/libs/sigwait/sigwait.c
@@ -359,17 +359,27 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 		       enum tst_ts_type type LTP_ATTRIBUTE_UNUSED)
 {
 	sigset_t sigs;
+	pid_t pid;
+	int status;
 
-	SAFE_SIGEMPTYSET(&sigs);
-	TEST(sigwaitinfo(&sigs, NULL, (void *)1));
-	if (TST_RET == -1) {
-		if (TST_ERR == EFAULT)
-			tst_res(TPASS, "Fault occurred while accessing the buffers");
-		else
-			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
-	} else {
-		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		SAFE_SIGEMPTYSET(&sigs);
+		TST_EXP_FAIL(sigwaitinfo(&sigs, NULL, (void *)1), EFAULT);
+		_exit(0);
+	}
+
+	SAFE_WAITPID(pid, &status, 0);
+
+	if (WIFEXITED(status) && !WEXITSTATUS(status))
+		return;
+
+	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
+		tst_res(TPASS, "Child killed by expected signal");
+		return;
 	}
+
+	tst_res(TFAIL, "Child %s", tst_strstatus(status));
 }
 
 static void empty_handler(int sig LTP_ATTRIBUTE_UNUSED)
-- 
2.45.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 5/5] libs/sigwait: Use safe/test macros
  2024-11-14 14:40 [LTP] [PATCH 0/5] mq_timedsend01: sigtimedwait01: Workaround segfault on libc variant on 32 bit Petr Vorel
                   ` (3 preceding siblings ...)
  2024-11-14 14:40 ` [LTP] [PATCH 4/5] libs/sigwait: " Petr Vorel
@ 2024-11-14 14:40 ` Petr Vorel
  4 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2024-11-14 14:40 UTC (permalink / raw)
  To: ltp

Simplify code with SAFE_SIGPROCMASK(), TST_EXP_FAIL().

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 libs/sigwait/sigwait.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/libs/sigwait/sigwait.c b/libs/sigwait/sigwait.c
index cf3c445b4a..a9fd62d73c 100644
--- a/libs/sigwait/sigwait.c
+++ b/libs/sigwait/sigwait.c
@@ -286,9 +286,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	/* let's not get interrupted by our dying child */
 	SAFE_SIGADDSET(&sigs, SIGCHLD);
 
-	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
-	if (TST_RET == -1)
-		tst_brk(TBROK | TTERRNO, "sigprocmask() failed");
+	SAFE_SIGPROCMASK(SIG_SETMASK, &sigs, &oldmask);
 
 	/* don't wait on a SIGCHLD */
 	SAFE_SIGDELSET(&sigs, SIGCHLD);
@@ -296,19 +294,8 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	/* Run a child that will wake us up */
 	child = create_sig_proc(signo, 1, 0);
 
-	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
-	if (TST_RET == -1) {
-		if (TST_ERR == EFAULT)
-			tst_res(TPASS, "Fault occurred while accessing the buffers");
-		else
-			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
-	} else {
-		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
-	}
-
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, NULL));
-	if (TST_RET == -1)
-		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
+	TST_EXP_FAIL(sigwaitinfo(&sigs, (void *)1, NULL), EFAULT);
+	SAFE_SIGPROCMASK(SIG_SETMASK, &oldmask, NULL);
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
-- 
2.45.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit
  2024-11-14 14:40 ` [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit Petr Vorel
@ 2024-11-15 13:13   ` Jan Stancek
  2024-11-15 14:00     ` Petr Vorel
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Stancek @ 2024-11-15 13:13 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Thu, Nov 14, 2024 at 3:40 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> EFAULT test segfaults on newer kernels (e.g. 6.4) on libc variant on
> 32bit.  Similarly to 1d4d5a0750 use typical LTP workaround to test by
> forked child + checking the terminating signal.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  .../syscalls/mq_timedsend/mq_timedsend01.c    | 87 ++++++++++++++-----
>  1 file changed, 63 insertions(+), 24 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
> index 35bf4445f5..2cec749f48 100644
> --- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
> +++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
> @@ -143,34 +143,15 @@ static void setup(void)
>         setup_common();
>  }
>
> -static void do_test(unsigned int i)
> +static void verify_mqt_send_receive(unsigned int i, pid_t pid)
>  {
>         struct time64_variants *tv = &variants[tst_variant];
>         const struct test_case *tc = &tcase[i];
>         unsigned int j;
>         unsigned int prio;
> -       size_t len = MAX_MSGSIZE;
> -       char rmsg[len];
> -       pid_t pid = -1;
> +       char rmsg[MAX_MSGSIZE];
>         void *msg_ptr, *abs_timeout;
>
> -       tst_ts_set_sec(&ts, tc->tv_sec);
> -       tst_ts_set_nsec(&ts, tc->tv_nsec);
> -
> -       if (tc->signal)
> -               pid = set_sig(tc->rq, tv->clock_gettime);
> -
> -       if (tc->timeout)
> -               set_timeout(tc->rq, tv->clock_gettime);
> -
> -       if (tc->send) {
> -               for (j = 0; j < MSG_LENGTH; j++)
> -                       if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
> -                               tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
> -                               return;
> -                       }
> -       }
> -
>         if (tc->bad_msg_addr)
>                 msg_ptr = bad_addr;
>         else
> @@ -200,7 +181,7 @@ static void do_test(unsigned int i)
>                 return;
>         }
>
> -       TEST(tv->mqt_receive(*tc->fd, rmsg, len, &prio, tst_ts_get(tc->rq)));
> +       TEST(tv->mqt_receive(*tc->fd, rmsg, MAX_MSGSIZE, &prio, tst_ts_get(tc->rq)));
>
>         if (*tc->fd == fd)
>                 cleanup_queue(fd);
> @@ -241,8 +222,66 @@ static void do_test(unsigned int i)
>                 }
>         }
>
> -       tst_res(TPASS, "mq_timedreceive() returned %ld, priority %u, length: %zu",
> -                       TST_RET, prio, len);
> +       tst_res(TPASS, "mq_timedreceive() returned %ld, priority %u, length: %i",
> +                       TST_RET, prio, MAX_MSGSIZE);
> +}
> +
> +static void test_bad_addr(unsigned int i)
> +{
> +       struct time64_variants *tv = &variants[tst_variant];
> +       pid_t pid;
> +       int status;
> +
> +       pid = SAFE_FORK();
> +       if (!pid) {
> +               verify_mqt_send_receive(i, pid);
> +               _exit(0);
> +       }
> +
> +       SAFE_WAITPID(pid, &status, 0);
> +
> +       if (WIFEXITED(status) && !WEXITSTATUS(status))
> +               return;
> +
> +       if (tv->ts_type == TST_LIBC_TIMESPEC &&
> +               WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
> +               tst_res(TPASS, "Child killed by expected signal");
> +               return;
> +       }
> +
> +       tst_res(TFAIL, "Child %s", tst_strstatus(status));
> +}
> +
> +static void do_test(unsigned int i)
> +{
> +       struct time64_variants *tv = &variants[tst_variant];
> +       const struct test_case *tc = &tcase[i];
> +       unsigned int j;
> +       pid_t pid = -1;
> +
> +       tst_ts_set_sec(&ts, tc->tv_sec);
> +       tst_ts_set_nsec(&ts, tc->tv_nsec);
> +
> +       if (tc->bad_ts_addr) {

Would it make sense to run bad_msg_addr/EFAULT test also in child?

> +               test_bad_addr(i);
> +               return;
> +       }
> +
> +       if (tc->signal)
> +               pid = set_sig(tc->rq, tv->clock_gettime);
> +
> +       if (tc->timeout)
> +               set_timeout(tc->rq, tv->clock_gettime);
> +
> +       if (tc->send) {
> +               for (j = 0; j < MSG_LENGTH; j++)
> +                       if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
> +                               tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
> +                               return;
> +                       }
> +       }
> +
> +       verify_mqt_send_receive(i, pid);
>  }
>
>  static struct tst_test test = {
> --
> 2.45.2
>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit
  2024-11-15 13:13   ` Jan Stancek
@ 2024-11-15 14:00     ` Petr Vorel
  2024-11-18  9:45       ` Jan Stancek
  0 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2024-11-15 14:00 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp

Hi Jan,

> On Thu, Nov 14, 2024 at 3:40 PM Petr Vorel <pvorel@suse.cz> wrote:

> > EFAULT test segfaults on newer kernels (e.g. 6.4) on libc variant on
> > 32bit.  Similarly to 1d4d5a0750 use typical LTP workaround to test by
> > forked child + checking the terminating signal.
...
> > +static void test_bad_addr(unsigned int i)
> > +{
> > +       struct time64_variants *tv = &variants[tst_variant];
> > +       pid_t pid;
> > +       int status;
> > +
> > +       pid = SAFE_FORK();
> > +       if (!pid) {
> > +               verify_mqt_send_receive(i, pid);
> > +               _exit(0);
> > +       }
> > +
> > +       SAFE_WAITPID(pid, &status, 0);
> > +
> > +       if (WIFEXITED(status) && !WEXITSTATUS(status))
> > +               return;
> > +
> > +       if (tv->ts_type == TST_LIBC_TIMESPEC &&
> > +               WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
> > +               tst_res(TPASS, "Child killed by expected signal");
> > +               return;
> > +       }
> > +
> > +       tst_res(TFAIL, "Child %s", tst_strstatus(status));
> > +}
> > +
> > +static void do_test(unsigned int i)
> > +{
> > +       struct time64_variants *tv = &variants[tst_variant];
> > +       const struct test_case *tc = &tcase[i];
> > +       unsigned int j;
> > +       pid_t pid = -1;
> > +
> > +       tst_ts_set_sec(&ts, tc->tv_sec);
> > +       tst_ts_set_nsec(&ts, tc->tv_nsec);
> > +
> > +       if (tc->bad_ts_addr) {

> Would it make sense to run bad_msg_addr/EFAULT test also in child?

First, thanks a lot a review.
I'm not sure myself. So far it's not needed (problem is only with struct
timespec *abs_timeout not with const char msg_ptr[]). But OTOH it does not
harm. Doing this might prevent some failure in the future.

Kind regards,
Petr

> > +               test_bad_addr(i);
> > +               return;
> > +       }
...

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit
  2024-11-15 14:00     ` Petr Vorel
@ 2024-11-18  9:45       ` Jan Stancek
  2024-11-25  9:28         ` Petr Vorel
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Stancek @ 2024-11-18  9:45 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Fri, Nov 15, 2024 at 3:00 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Jan,
>
> > On Thu, Nov 14, 2024 at 3:40 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> > > EFAULT test segfaults on newer kernels (e.g. 6.4) on libc variant on
> > > 32bit.  Similarly to 1d4d5a0750 use typical LTP workaround to test by
> > > forked child + checking the terminating signal.
> ...
> > > +static void test_bad_addr(unsigned int i)
> > > +{
> > > +       struct time64_variants *tv = &variants[tst_variant];
> > > +       pid_t pid;
> > > +       int status;
> > > +
> > > +       pid = SAFE_FORK();
> > > +       if (!pid) {
> > > +               verify_mqt_send_receive(i, pid);
> > > +               _exit(0);
> > > +       }
> > > +
> > > +       SAFE_WAITPID(pid, &status, 0);
> > > +
> > > +       if (WIFEXITED(status) && !WEXITSTATUS(status))
> > > +               return;
> > > +
> > > +       if (tv->ts_type == TST_LIBC_TIMESPEC &&
> > > +               WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
> > > +               tst_res(TPASS, "Child killed by expected signal");
> > > +               return;
> > > +       }
> > > +
> > > +       tst_res(TFAIL, "Child %s", tst_strstatus(status));
> > > +}
> > > +
> > > +static void do_test(unsigned int i)
> > > +{
> > > +       struct time64_variants *tv = &variants[tst_variant];
> > > +       const struct test_case *tc = &tcase[i];
> > > +       unsigned int j;
> > > +       pid_t pid = -1;
> > > +
> > > +       tst_ts_set_sec(&ts, tc->tv_sec);
> > > +       tst_ts_set_nsec(&ts, tc->tv_nsec);
> > > +
> > > +       if (tc->bad_ts_addr) {
>
> > Would it make sense to run bad_msg_addr/EFAULT test also in child?
>
> First, thanks a lot a review.
> I'm not sure myself. So far it's not needed (problem is only with struct
> timespec *abs_timeout not with const char msg_ptr[]). But OTOH it does not
> harm. Doing this might prevent some failure in the future.

It was only as a precaution. Either way, feel free to add to series:
Acked-by: Jan Stancek <jstancek@redhat.com>

>
> Kind regards,
> Petr
>
> > > +               test_bad_addr(i);
> > > +               return;
> > > +       }
> ...
>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit
  2024-11-18  9:45       ` Jan Stancek
@ 2024-11-25  9:28         ` Petr Vorel
  0 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2024-11-25  9:28 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp

Hi Jan,

...
> > > > +       if (tc->bad_ts_addr) {

> > > Would it make sense to run bad_msg_addr/EFAULT test also in child?

> > First, thanks a lot a review.
> > I'm not sure myself. So far it's not needed (problem is only with struct
> > timespec *abs_timeout not with const char msg_ptr[]). But OTOH it does not
> > harm. Doing this might prevent some failure in the future.

> It was only as a precaution. Either way, feel free to add to series:
> Acked-by: Jan Stancek <jstancek@redhat.com>

Thanks a lot for your review. Merged with changing bad_msg_addr/EFAULT being
tested also in child.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2024-11-25  9:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 14:40 [LTP] [PATCH 0/5] mq_timedsend01: sigtimedwait01: Workaround segfault on libc variant on 32 bit Petr Vorel
2024-11-14 14:40 ` [LTP] [PATCH 1/5] mq_timedsend01: Fix different signedness error on 32bit Petr Vorel
2024-11-14 14:40 ` [LTP] [PATCH 2/5] mq_timedsend01: Remove unneeded designated initializers Petr Vorel
2024-11-14 14:40 ` [LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit Petr Vorel
2024-11-15 13:13   ` Jan Stancek
2024-11-15 14:00     ` Petr Vorel
2024-11-18  9:45       ` Jan Stancek
2024-11-25  9:28         ` Petr Vorel
2024-11-14 14:40 ` [LTP] [PATCH 4/5] libs/sigwait: " Petr Vorel
2024-11-14 14:40 ` [LTP] [PATCH 5/5] libs/sigwait: Use safe/test macros 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.