Re: [LTP] [PATCH 1/1] recvmmsg01: Workaround segfault on libc variant on 32 bit

Cyril Hrubis
2024-11-11T10:38:09Z

Hi!
> -static void do_test(unsigned int i)
> +static void verify_recvmmsg(unsigned int i, void *timeout)
> {
> struct time64_variants *tv = &variants[tst_variant];
> struct test_case *tc = &tcase[i];
> - void *timeout;
>
> ts.type = tv->ts_type;
> tst_ts_set_sec(&ts, tc->tv_sec);
> tst_ts_set_nsec(&ts, tc->tv_nsec);
>
> + TST_EXP_FAIL2(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
> + tc->exp_errno, "recvmmsg() %s", tc->desc);
> +}
> +
> +static void test_bad_addr(unsigned int i)
> +{
> + struct time64_variants *tv = &variants[tst_variant];
> + void *timeout = bad_addr;
> + pid_t pid;
> + int status;
> +
> + pid = SAFE_FORK();
> + if (!pid) {
> + verify_recvmmsg(i, timeout);
> + _exit(!TST_PASS);

This should be just exit(0). The child should either crash or exit with
0 any other result should be considered a bug.

> + }
> +
> + 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 signal");
> + return;
> + }
> +
> + tst_res(TFAIL, "Child %s", tst_strstatus(status));
> +}

The rest looks good to me, with the minor fixed applied:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

--
Cyril Hrubis
chrubis@suse.cz