All of
 help / color / mirror / Atom feed
From: Peter Zijlstra <>
To: Linus Torvalds <>
Cc: Andrew Morton <>,
	Kees Cook <>, Ingo Molnar <>,
	Linux Kernel Mailing List <>,
	Kernel Hardening <>
Subject: Re: [PATCH] task_struct: Only use anon struct under randstruct plugin
Date: Wed, 28 Mar 2018 11:51:40 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, Mar 27, 2018 at 02:22:31PM -1000, Linus Torvalds wrote:
> On Tue, Mar 27, 2018 at 1:03 PM, Andrew Morton
> <> wrote:
> >
> > Why?  What caused this padding?  It happens in all configs?
> I assume what happens is that the anonymous struct ends up containing
> fields that are cacheline-aligned, and then the whole anonymous struct
> is cacheline-aligned.

Yes, structures inherit the alignment requirements of their constituent

> Which is all kinds of stupid, since the anonymous struct itself does
> not exist outside of the outer struct. So it would be entirely
> sufficient to just make the outer struct cacheline aligned (like it
> used to be), but not align the inner anonymous one - just the fields
> in it.
> But there may be "reasons" why the inner anonymous  one needs to be
> aligned. Maybe it's some standards requirement, or maybe it's just an
> internal gcc implementation detail.

Last time I read the standard there wasn't a distinction between
anonymous and regular structures for this. So in that regards a strict
reading of the standard would mandate this behaviour.

> Regardless, it's a bit sad. It also means that when randomization is
> on, that unnecessary padding will be there.

The other complaint is that the anonymous structure makes the pahole
output (which is what I showed) unnecessarily ugly.

  reply	other threads:[~2018-03-28  9:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 21:36 Kees Cook
2018-03-27 23:03 ` Andrew Morton
2018-03-28  0:22   ` Linus Torvalds
2018-03-28  9:51     ` Peter Zijlstra [this message]
2018-03-28  0:30   ` Kees Cook
2018-03-28  1:34     ` Andrew Morton

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:

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

  git send-email \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] task_struct: Only use anon struct under randstruct plugin' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.