Messages in this thread | | | Subject | Re: [PATCH v2 1/1] samples/seccomp: eliminate two compile warnings in user-trap.c | From | "Leizhen (ThunderTown)" <> | Date | Wed, 9 Sep 2020 10:20:01 +0800 |
| |
On 2020/9/9 7:42, Kees Cook wrote: > On Wed, Sep 02, 2020 at 09:33:06AM +0800, Leizhen (ThunderTown) wrote: >> On 2020/9/1 16:39, Zhen Lei wrote: >>> samples/seccomp/user-trap.c is compiled with $(userccflags), and the >>> latter does not contain -fno-strict-aliasing, so the warnings reported as >>> below. Due to add "userccflags += -fno-strict-aliasing" will impact other >>> files, so use __attribute__((__may_alias__)) to suppress it exactly. >>> >>> My gcc version is 5.5.0 20171010. >>> >>> ---------- >>> samples/seccomp/user-trap.c: In function ‘send_fd’: >>> samples/seccomp/user-trap.c:50:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] >>> *((int *)CMSG_DATA(cmsg)) = fd; >>> ^ >>> samples/seccomp/user-trap.c: In function ‘recv_fd’: >>> samples/seccomp/user-trap.c:83:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] >>> return *((int *)CMSG_DATA(cmsg)); >>> ^ >> >> Doesn't anyone care about this? Or is it that everyone hasn't encountered this problem? >> Why do these two warnings occur every time I compiled? > > Hi! > > I think the samples have been a bit ignored lately because they have a > lot of weird build issues with regard to native vs compat and needing > the kernel headers to be built first, etc. > > That said, yes, I'd like to fix warnings. However, I can't reproduce > this. How are you building? I tried x86_64 and cross-compiled to i386.
I can reproduce it both on X86 and ARM64.
On X86: make distclean allmodconfig make -j64 2>err.txt vi err.txt
$ arch x86_64 $ ls -l samples/seccomp/user-trap user-trap user-trap.c $ gcc -v gcc version 5.5.0 20171010 (Ubuntu 5.5.0-12ubuntu5~16.04)
On ARM64: make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- distclean allmodconfig make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j64 2>err.tx vi err.txt
$ ls -l samples/seccomp/user-trap user-trap user-trap.c $ aarch64-linux-gnu-gcc -v gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) >
| |