Re: [LTP] [PATCH 2/2] mq_timedreceive01: Workaround segfault on libc variant on 32 bit

Petr Vorel
2024-11-14T14:53:27Z

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));
> > +}
...