[LTP] [PATCH] lib: tst_fd: Avoid tst_brk(TCONF, ...) on older distros

Petr Vorel pvorel@suse.cz
Wed Jan 24 15:56:32 CET 2024


Hi Martin, Cyril,

> On 24. 01. 24 15:21, Cyril Hrubis wrote:
> > Hi!
> > > Actually at least here tst_syscall() needs to be called or it fails on older
> > > distros due missing ENOSYS check in raw syscall():

> > Ah, no we have to handle the ENOSYS ourselves as we do in the other
> > cases. Sorry for not realizing that.

> > We likely need just:

> > diff --git a/lib/tst_fd.c b/lib/tst_fd.c
> > index ab7de81aa..8b26ff8e5 100644
> > --- a/lib/tst_fd.c
> > +++ b/lib/tst_fd.c
> > @@ -141,7 +141,7 @@ static void open_pidfd(struct tst_fd *fd)
> >   {
> >          fd->fd = syscall(__NR_pidfd_open, getpid(), 0);
> >          if (fd->fd < 0)
> > -               tst_brk(TBROK | TERRNO, "pidfd_open()");
> > +               tst_res(TCONF | TERRNO, "pidfd_open()");
> >   }

Actually, the solution I posted [1] works on both old (affected) kernel and new
one:

-	fd->fd = syscall(__NR_pidfd_open, getpid(), 0);
+	fd->fd = tst_syscall(__NR_pidfd_open, getpid(), 0);
 	if (fd->fd < 0)
 		tst_brk(TBROK | TERRNO, "pidfd_open()");

I guess we should merge your solution (otherwise we would need to change other
cases to be consistent), but I'm a bit confused. Is it the reason why we use
syscall() + tst_res(TCONF) instead of tst_syscall() + tst_brk(TBROK) that for
some cases it's expected to fail, thus TBROK is not accepted? Again, I was blind
when doing review.

If yes, please just go ahead and merge it.

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/20240124142108.303782-1-pvorel@suse.cz/

> Yes, this will work. I missed the TBROK because I didn't look too closely at
> the unchanged lines in the patch...


More information about the ltp mailing list