public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tycho Andersen <tycho@tycho.pizza>
To: Kees Cook <keescook@chromium.org>
Cc: Arnd Bergmann <arnd@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] samples: user-trap: fix strict-aliasing warning
Date: Mon, 12 Feb 2024 16:14:45 -0700	[thread overview]
Message-ID: <ZcqmZdZ6x5w54nTI@tycho.pizza> (raw)
In-Reply-To: <170776334482.2557794.95461406898503535.b4-ty@chromium.org>

On Mon, Feb 12, 2024 at 10:42:27AM -0800, Kees Cook wrote:
> On Mon, 12 Feb 2024 12:17:31 +0100, Arnd Bergmann wrote:
> > I started getting warnings for this one file, though I can't see what changed
> > since it was originally introduced in commit fec7b6690541 ("samples: add an
> > example of seccomp user trap").
> > 
> > samples/seccomp/user-trap.c: In function 'send_fd':
> > samples/seccomp/user-trap.c:50:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> >    50 |         *((int *)CMSG_DATA(cmsg)) = fd;
> >       |          ~^~~~~~~~~~~~~~~~~~~~~~~
> > samples/seccomp/user-trap.c: In function 'recv_fd':
> > samples/seccomp/user-trap.c:83:18: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> >    83 |         return *((int *)CMSG_DATA(cmsg));
> >       |                 ~^~~~~~~~~~~~~~~~~~~~~~~
> > 
> > [...]
> 
> Applied to for-next/seccomp, thanks!
> 
> [1/1] samples: user-trap: fix strict-aliasing warning
>       https://git.kernel.org/kees/c/9ad28ca5238d
> 
> Take care,

If you happen to update the trailers, looks good to me too:

Acked-by: Tycho Andersen <tandersen@netflix.com>

I also don't understand what changed, or why this really fixes it.
We're still "violating" strict aliasing as far as I can tell, since we
just introduce `int *fd_ptr` insted of memcpy()-ing out the fd into
an int?

But whatever shuts the compiler up works for me.

Tycho

      reply	other threads:[~2024-02-12 23:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 11:17 [PATCH] samples: user-trap: fix strict-aliasing warning Arnd Bergmann
2024-02-12 18:42 ` Kees Cook
2024-02-12 23:14   ` Tycho Andersen [this message]

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=ZcqmZdZ6x5w54nTI@tycho.pizza \
    --to=tycho@tycho.pizza \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    /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