Re: Fw: next/pending-fixes build: 162 builds: 2 failed, 160 passed, 2 errors, 109 warnings (v5.7-8671-g086779e58c68)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux