public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	Ingo Molnar <mingo@kernel.org>,
	"kernelci.org bot" <bot@kernelci.org>,
	linux-next@vger.kernel.org
Subject: Re: Fw: next/pending-fixes build: 162 builds: 2 failed, 160 passed, 2 errors, 109 warnings (v5.7-8671-g086779e58c68)
Date: Fri, 5 Jun 2020 07:36:02 -0700	[thread overview]
Message-ID: <202006050734.97C4AB35CF@keescook> (raw)
In-Reply-To: <20200605083855.GH3976@hirez.programming.kicks-ass.net>

On Fri, Jun 05, 2020 at 10:38:55AM +0200, Peter Zijlstra wrote:
> On Fri, Jun 05, 2020 at 11:52:13AM +1000, Stephen Rothwell wrote:
> > Commit
> > 
> >   a148866489fb ("sched: Replace rq::wake_list")
> > 
> > added
> > 
> > BUILD_BUG_ON(offsetof(struct task_struct, wake_entry_type) - offsetof(struct task_struct, wake_entry) !=
> > 		     offsetof(struct __call_single_data, flags) - offsetof(struct __call_single_data, llist));
> > 
> > in kernel/smp.c.  This seems to be failing - at least for gcc-8 (I
> > haven't seen any failures in my linux-next testing).
> 
> CONFIG_GCC_PLUGIN_RANDSTRUCT=y

(FWIW, the plugins will only be enabled if the gcc plugins-dev package is
installed)

> working on it.

Either of these solutions should fix it. I'm not sure which is
preferred.


Collect them into a separate anonymous struct to keep them together
under randomization:

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 613bf7a21ae2..0f90239501c8 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -654,8 +654,11 @@ struct task_struct {
 	unsigned int			ptrace;
 
 #ifdef CONFIG_SMP
-	struct llist_node		wake_entry;
-	unsigned int			wake_entry_type;
+	/* Keep these members together under __randomize_struct. */
+	struct {
+		struct llist_node		wake_entry;
+		unsigned int			wake_entry_type;
+	};
 	int				on_cpu;
 #ifdef CONFIG_THREAD_INFO_IN_TASK
 	/* Current CPU: */


or just explicitly move them out of the randomized section:

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 613bf7a21ae2..f97b41ce1b13 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -641,6 +641,10 @@ struct task_struct {
 	/* -1 unrunnable, 0 runnable, >0 stopped: */
 	volatile long			state;
 
+#ifdef CONFIG_SMP
+	struct llist_node		wake_entry;
+	unsigned int			wake_entry_type;
+#endif
 	/*
 	 * This begins the randomizable portion of task_struct. Only
 	 * scheduling-critical items should be added above here.
@@ -654,8 +658,6 @@ struct task_struct {
 	unsigned int			ptrace;
 
 #ifdef CONFIG_SMP
-	struct llist_node		wake_entry;
-	unsigned int			wake_entry_type;
 	int				on_cpu;
 #ifdef CONFIG_THREAD_INFO_IN_TASK
 	/* Current CPU: */

-- 
Kees Cook

  reply	other threads:[~2020-06-05 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05  1:52 Fw: next/pending-fixes build: 162 builds: 2 failed, 160 passed, 2 errors, 109 warnings (v5.7-8671-g086779e58c68) Stephen Rothwell
2020-06-05  8:38 ` Peter Zijlstra
2020-06-05 14:36   ` Kees Cook [this message]
2020-06-05 14:47     ` Peter Zijlstra

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=202006050734.97C4AB35CF@keescook \
    --to=keescook@chromium.org \
    --cc=bot@kernelci.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sfr@canb.auug.org.au \
    /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