[LTP] [PATCH 3/5] mq_timedsend01: Workaround segfault on libc variant on 32 bit

Petr Vorel pvorel@suse.cz
Fri Nov 15 15:00:05 CET 2024


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


More information about the ltp mailing list