Messages in this thread | | | Date | Tue, 8 Sep 2020 16:42:37 -0700 | From | Kees Cook <> | Subject | Re: [PATCH v2 1/1] samples/seccomp: eliminate two compile warnings in user-trap.c |
| |
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.
-- Kees Cook
| |