Re: [PATCH v3 3/3] selftests: pidfd: add tests for PIDFD_SELF_*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 16, 2024 at 11:06:34PM +0100, Lorenzo Stoakes wrote:
[sniip]
> >
> > The import will be fine and you can control that with -I flag in
> > the makefile. Remove these and try to get including linux/pidfd.h
> > working.
>
> I just tried this and it's not fine :) it immediately broke the build as
> pidfd.h imports linux/fcntl.h which conflicts horribly with system headers
> on my machine.
>
> For instance f_owner_ex gets redefined among others and fails the build e..g:
>
> /usr/include/asm-generic/fcntl.h:155:8: error: redefinition of ‘struct f_owner_ex’
>   155 | struct f_owner_ex {
>       |        ^~~~~~~~~~
> In file included from /usr/include/bits/fcntl.h:61,
>                  from /usr/include/fcntl.h:35,
>                  from pidfd_test.c:6:
> /usr/include/bits/fcntl-linux.h:274:8: note: originally defined here
>   274 | struct f_owner_ex
>       |        ^~~~~~~~~~
>
> It seems only one other test tries to do this as far as I can tell (I only
> did a quick grep), so it's not at all standard it seems.
>
> This issue occurred even when I used make headers_install to create
> sanitised user headers and added them to the include path.
>
> A quick google suggests linux/fcntl.h (imported by this pidfd.h uapi
> header) and system fcntl.h is a known thing. Slightly bizarre...
>
> I tried removing the <fcntl.h> include and that resulted in <sys/mount.h>
> conflicting:
>
> In file included from /usr/include/fcntl.h:35,
>                  from /usr/include/sys/mount.h:24,
>                  from pidfd.h:17,
>                  from pidfd_test.c:22:
> /usr/include/bits/fcntl.h:35:8: error: redefinition of ‘struct flock’
>    35 | struct flock
>       |        ^~~~~
> In file included from /tmp/hdr/include/asm/fcntl.h:1,
>                  from /tmp/hdr/include/linux/fcntl.h:5,
>                  from /tmp/hdr/include/linux/pidfd.h:7,
>                  from pidfd.h:6:
> /usr/include/asm-generic/fcntl.h:195:8: note: originally defined here
>   195 | struct flock {
>       |        ^~~~~
>
> So I don't think I can actually work around this, at least on my system,
> and I can't really sensibly submit a patch that I can't run on my own
> machine :)
>
> I may be missing something here.
>

[snip]

Some added data:

OK so I asked people on fedi to compile the following locally (also a
variant with _GNU_SOURCE being defined):

	#include <linux/pidfd.h>
	#include <fcntl.h>

	int main(void) {}

And they are all encountering the same issue as I am on a number of
different distros (ordering of includes doesn't seem to matter either).

So this seems like a known-broken thing.

And we can't really isolate inclusion of this file since all the tests
interact directly with defines from it.

So it seems the only solution is the workaround I suggested previously I
think with the header guard define hack.

[snip]




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux