* [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit
@ 2024-11-12 17:18 Petr Vorel
2024-11-12 17:18 ` [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit Petr Vorel
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Petr Vorel @ 2024-11-12 17:18 UTC (permalink / raw)
To: ltp
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_timedreceive/mq_timedreceive01.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
index 3870b4087a..d4f447d047 100644
--- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
+++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
@@ -183,7 +183,7 @@ static void do_test(unsigned int i)
return;
}
- 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.47.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit
2024-11-12 17:18 [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit Petr Vorel
@ 2024-11-12 17:18 ` Petr Vorel
2024-11-13 3:00 ` Wei Gao via ltp
2024-11-26 14:31 ` Cyril Hrubis
2024-11-13 1:37 ` [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit Wei Gao via ltp
2024-11-26 14:29 ` Cyril Hrubis
2 siblings, 2 replies; 9+ messages in thread
From: Petr Vorel @ 2024-11-12 17:18 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>
---
.../mq_timedreceive/mq_timedreceive01.c | 78 ++++++++++++++-----
1 file changed, 58 insertions(+), 20 deletions(-)
diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
index d4f447d047..a5a43a1771 100644
--- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
+++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
@@ -129,32 +129,16 @@ static void setup(void)
setup_common();
}
-static void do_test(unsigned int i)
+
+static void verify_mqt_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;
void *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) {
- if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
- tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
- return;
- }
- }
+ unsigned int j;
+ unsigned int prio;
if (tc->invalid_msg)
len -= 1;
@@ -208,6 +192,60 @@ static void do_test(unsigned int i)
TST_RET, prio, len);
}
+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_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];
+ 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 && tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
+ tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
+ return;
+ }
+
+ verify_mqt_receive(i, pid);
+}
+
static struct tst_test test = {
.tcnt = ARRAY_SIZE(tcase),
.test = do_test,
--
2.47.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit
2024-11-12 17:18 [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit Petr Vorel
2024-11-12 17:18 ` [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit Petr Vorel
@ 2024-11-13 1:37 ` Wei Gao via ltp
2024-11-26 14:29 ` Cyril Hrubis
2 siblings, 0 replies; 9+ messages in thread
From: Wei Gao via ltp @ 2024-11-13 1:37 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Tue, Nov 12, 2024 at 06:18:30PM +0100, Petr Vorel wrote:
> 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_timedreceive/mq_timedreceive01.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
> index 3870b4087a..d4f447d047 100644
> --- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
> +++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
> @@ -183,7 +183,7 @@ static void do_test(unsigned int i)
> return;
> }
>
> - 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;
Reviewed-by: Wei Gao <wegao@suse.com>
> --
> 2.47.0
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit
2024-11-12 17:18 ` [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit Petr Vorel
@ 2024-11-13 3:00 ` Wei Gao via ltp
2024-11-14 14:53 ` Petr Vorel
2024-11-26 14:31 ` Cyril Hrubis
1 sibling, 1 reply; 9+ messages in thread
From: Wei Gao via ltp @ 2024-11-13 3:00 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Tue, Nov 12, 2024 at 06:18:31PM +0100, Petr Vorel 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>
> ---
> .../mq_timedreceive/mq_timedreceive01.c | 78 ++++++++++++++-----
> 1 file changed, 58 insertions(+), 20 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
> index d4f447d047..a5a43a1771 100644
> --- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
> +++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
> @@ -129,32 +129,16 @@ static void setup(void)
> setup_common();
> }
>
> -static void do_test(unsigned int i)
> +
> +static void verify_mqt_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;
> void *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) {
> - if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
> - tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
> - return;
> - }
> - }
> + unsigned int j;
> + unsigned int prio;
>
> if (tc->invalid_msg)
> len -= 1;
> @@ -208,6 +192,60 @@ static void do_test(unsigned int i)
> TST_RET, prio, len);
> }
>
> +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_receive(i, pid);
> + _exit(0);
nit:
If this is a normal exit, i suggest use s/_exit(0)/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];
> + 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 && tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) {
> + tst_res(TFAIL | TTERRNO, "mq_timedsend() failed");
> + return;
> + }
> +
> + verify_mqt_receive(i, pid);
> +}
> +
> static struct tst_test test = {
> .tcnt = ARRAY_SIZE(tcase),
> .test = do_test,
> --
> 2.47.0
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit
2024-11-13 3:00 ` Wei Gao via ltp
@ 2024-11-14 14:53 ` Petr Vorel
2024-11-15 12:57 ` Jan Stancek
0 siblings, 1 reply; 9+ messages in thread
From: Petr Vorel @ 2024-11-14 14:53 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi all,
> On Tue, Nov 12, 2024 at 06:18:31PM +0100, Petr Vorel 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.
...
> > + unsigned int j;
> > + unsigned int prio;
> > if (tc->invalid_msg)
> > len -= 1;
> > @@ -208,6 +192,60 @@ static void do_test(unsigned int i)
> > TST_RET, prio, len);
> > }
> > +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_receive(i, pid);
> > + _exit(0);
> nit:
> If this is a normal exit, i suggest use s/_exit(0)/exit(0) ?
I copy pasted this from similar tests. IMHO both should work. According to man
exit() calls functions registered with atexit() and _exit(), _exit() just
immediately terminates the process. Any open file descriptors belonging to the process are closed.
@Jan, @Cyril Please correct me if I'm wrong.
Kind regards,
Petr
> > + }
> > +
> > + 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));
> > +}
...
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit
2024-11-14 14:53 ` Petr Vorel
@ 2024-11-15 12:57 ` Jan Stancek
0 siblings, 0 replies; 9+ messages in thread
From: Jan Stancek @ 2024-11-15 12:57 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Thu, Nov 14, 2024 at 3:53 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi all,
>
> > On Tue, Nov 12, 2024 at 06:18:31PM +0100, Petr Vorel 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.
>
> ...
> > > + unsigned int j;
> > > + unsigned int prio;
>
> > > if (tc->invalid_msg)
> > > len -= 1;
> > > @@ -208,6 +192,60 @@ static void do_test(unsigned int i)
> > > TST_RET, prio, len);
> > > }
>
> > > +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_receive(i, pid);
> > > + _exit(0);
> > nit:
> > If this is a normal exit, i suggest use s/_exit(0)/exit(0) ?
>
> I copy pasted this from similar tests. IMHO both should work. According to man
> exit() calls functions registered with atexit() and _exit(), _exit() just
> immediately terminates the process. Any open file descriptors belonging to the process are closed.
>
> @Jan, @Cyril Please correct me if I'm wrong.
Our main usage of _exit() is signal handlers, because exit() is not
async-signal-safe.
exit() will also flush open streams, which seems desirable here.
>
> Kind regards,
> Petr
>
> > > + }
> > > +
> > > + 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));
> > > +}
> ...
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit
2024-11-12 17:18 [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit Petr Vorel
2024-11-12 17:18 ` [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit Petr Vorel
2024-11-13 1:37 ` [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit Wei Gao via ltp
@ 2024-11-26 14:29 ` Cyril Hrubis
2 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2024-11-26 14:29 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
That looks obviously correct.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit
2024-11-12 17:18 ` [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit Petr Vorel
2024-11-13 3:00 ` Wei Gao via ltp
@ 2024-11-26 14:31 ` Cyril Hrubis
2024-11-26 18:32 ` Petr Vorel
1 sibling, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2024-11-26 14:31 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
Looks good, minus the _exit() part:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit
2024-11-26 14:31 ` Cyril Hrubis
@ 2024-11-26 18:32 ` Petr Vorel
0 siblings, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2024-11-26 18:32 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
> Hi!
> Looks good, minus the _exit() part:
_exit() changed to exit() and merged.
Thanks for your review!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-11-26 18:32 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12 17:18 [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit Petr Vorel
2024-11-12 17:18 ` [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit Petr Vorel
2024-11-13 3:00 ` Wei Gao via ltp
2024-11-14 14:53 ` Petr Vorel
2024-11-15 12:57 ` Jan Stancek
2024-11-26 14:31 ` Cyril Hrubis
2024-11-26 18:32 ` Petr Vorel
2024-11-13 1:37 ` [LTP] [PATCH 1/2] mq_timedreceive01: Fix different signedness error on 32bit Wei Gao via ltp
2024-11-26 14:29 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox