Re: [PATCH 33/33] kselftest/riscv: kselftest for user mode cfi

From: Edgecombe, Rick P
Date: Thu Oct 03 2024 - 19:12:34 EST


On Thu, 2024-10-03 at 17:04 -0600, Shuah Khan wrote:
> On 10/3/24 05:03, Mark Brown wrote:
> > On Wed, Oct 02, 2024 at 05:18:36PM -0600, Shuah Khan wrote:
> > > On 10/1/24 10:06, Deepak Gupta wrote:
> >
> > > > +#ifndef __NR_prctl
> > > > +#define __NR_prctl 167
> > > > +#endif
> >
> > > > +#ifndef __NR_map_shadow_stack
> > > > +#define __NR_map_shadow_stack 453
> >
> > > Why do we need to define these? Shouldn't including
> > > asm-generic/unistd.h sufficient?
> >
> > We have this issue on arm64 as well, there's some issue with directly
> > pulling in the asm header interfering with libc in some situation (I
> > can't immediately figure out which situation or which libc to remind
> > myself what it is though...) so we've got local defines like we do for
> > the NT_ defines for ptrace.  I see x86 is doing the same.
>
> It would be nice to figure. There have been some issues reported due
> to local defines - the test fails if the define happens to not match.
>
> Does including <asm/unistd.h> fix the problem?

On x86, if you do "make headers", you can adjust the Makefile with
$(KHDR_INCLUDES) to find the syscall defines in the generated headers. But then
you have to remember to run "make headers" before building the selftests. There
was some direction on it from x86 maintainers:
https://lore.kernel.org/lkml/Y%2FduhySUieqUWoGX@xxxxxxx/#t

I don't think it's great, but the other options weren't great either.