[LTP] [PATCH v2] getcpu: Add testcase for EFAULT
Petr Vorel
pvorel@suse.cz
Thu Aug 1 11:41:08 CEST 2024
> Hi!
> > > +static void run(void)
> > > +{
> > > + unsigned int cpu_id, node_id = 0;
> > > +
> > > + TST_EXP_FAIL(getcpu(tst_get_bad_addr(NULL), &node_id), EFAULT);
> > I'm not sure why, but I get SIGSEGV due tst_get_bad_addr(NULL) on various
> > kernels (SLES 5.14.21, Tumbleweed 6.5.1, 6.10, Debian 6.9, ...).
> > But the test works on SLES 4.4.180.
> If you are getting SIGSEGV that means that the address is used in
> userspace. Looking at man getcpu() it suggests that on some
> architectures it may be implemented as VDSO, which would explain it.
> So I suppose that the easies solution here would be to run the test in a
> child process and accepting SIGSEGV as a correct outcome as well.
Thanks, Cyril.
Ma Xinjian, could you please send another version?
You can get inspiration in:
testcases/kernel/syscalls/setrlimit/setrlimit05.c
Or in others:
$ git grep -l .forks_child $(git grep -l SIGSEGV)
Kind regards,
Petr
More information about the ltp
mailing list