public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/1] samples/seccomp: eliminate two compile warnings in user-trap.c
Date: Tue, 8 Sep 2020 16:42:37 -0700	[thread overview]
Message-ID: <202009081633.CC35635@keescook> (raw)
In-Reply-To: <973a1752-7609-bac9-758a-1a977e6fb1f0@huawei.com>

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

  reply	other threads:[~2020-09-08 23:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01  8:39 [PATCH v2 0/1] samples/seccomp: eliminate two compile warnings in user-trap.c Zhen Lei
2020-09-01  8:39 ` [PATCH v2 1/1] " Zhen Lei
2020-09-02  1:33   ` Leizhen (ThunderTown)
2020-09-08 23:42     ` Kees Cook [this message]
2020-09-09  2:20       ` Leizhen (ThunderTown)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202009081633.CC35635@keescook \
    --to=keescook@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mingo@kernel.org \
    --cc=thunder.leizhen@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox