From: Kees Cook <kees@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Mickaël Salaün" <mic@digikod.net>, linux <linux@treblig.org>,
"Mark Brown" <broonie@kernel.org>,
WangYuli <wangyuli@uniontech.com>,
"Günther Noack" <gnoack@google.com>,
"Paul Moore" <paul@paul-moore.com>,
"James Morris" <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] landlock: Work around randstruct unnamed static initializer support
Date: Tue, 22 Apr 2025 07:59:07 -0700 [thread overview]
Message-ID: <202504220756.4DD4BAD@keescook> (raw)
In-Reply-To: <ccdfe9c0-7c28-4ecf-a7da-95c9a20eead7@app.fastmail.com>
On Tue, Apr 22, 2025 at 02:53:05PM +0200, Arnd Bergmann wrote:
> On Tue, Apr 22, 2025, at 14:25, Mickaël Salaün wrote:
> > On Sun, Apr 20, 2025 at 05:08:59PM -0700, Kees Cook wrote:
> >> Unnamed static initializers aren't supported by the randstruct GCC
> >> plugin. Quoting the plugin, "set up a bogus anonymous struct field
> >> designed to error out on unnamed struct initializers as gcc provides
> >> no other way to detect such code". That is exactly what happens
> >> with the landlock code, so adjust the static initializers for structs
> >> lsm_ioctlop_audit and landlock_request that contain a randomized structure
> >> (struct path) to use named variables, which avoids the intentional
> >> GCC crashes:
> >
> > This is not a sustainable solution. Could we fix the plugin instead?
> > This new Landlock change may be the first to trigger this plugin bug but
> > it will probably not be the last to use unnamed static initializers.
> > Forbidding specific C constructs should be documented.
>
> I think the version from Kees' patch looks more readable than
> the version with the compound literal, so it certainly seems appropriate
> as an immediate regression fix, even if it's possible to fix the
> plugin later.
>
> >> We went 8 years before tripping over this!
>
> Right, it's probably enough to revisit the plugin code after
> it happens again.
Yeah, that's my thinking as well.
> >> Closes: https://lore.kernel.org/lkml/337D5D4887277B27+3c677db3-a8b9-47f0-93a4-7809355f1381@uniontech.com/
> >> Signed-off-by: Kees Cook <kees@kernel.org>
>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
Thanks! Mickaël, are you good with this for now, and if so, do you want
to carry it or shall I?
-Kees
--
Kees Cook
next prev parent reply other threads:[~2025-04-22 14:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 0:08 [PATCH] landlock: Work around randstruct unnamed static initializer support Kees Cook
2025-04-22 12:25 ` Mickaël Salaün
2025-04-22 12:53 ` Arnd Bergmann
2025-04-22 14:59 ` Kees Cook [this message]
2025-04-23 18:38 ` Mickaël Salaün
2025-04-25 10:03 ` Günther Noack
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=202504220756.4DD4BAD@keescook \
--to=kees@kernel.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=gnoack@google.com \
--cc=jmorris@namei.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux@treblig.org \
--cc=mic@digikod.net \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=torvalds@linux-foundation.org \
--cc=wangyuli@uniontech.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