[PATCH] sched/wait: Add <linux/sched/signal.h> dependency for now

From: Ingo Molnar
Date: Wed Mar 08 2017 - 03:42:52 EST


The wait_event_interruptible*() APIs are using signal_pending(), so
include its header to not build-break users of those APIs.

Note that this is overkill as most wait_event*() users don't care
about signals - but solving that problem turned out to be more
complex.

Note two dependency quirks:

- the <linux/sched/signal.h> include line needs to be last in
wait.h, because that header itself depends on wait-queue types.

- we shouldn't include cred.h from sched/signal.h, because cred.h is
a complex header that will create a circular dependency if we do so.
Instead we include wait.h to gain the waitqueue types, plus we
predeclare 'struct cred' for a function prototype.

Note that the cred.h change has some knock-on effects.

Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Not-Yet-Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
include/linux/audit.h | 2 ++
include/linux/fs.h | 1 +
include/linux/sched/signal.h | 8 +++++---
include/linux/wait.h | 3 +++
kernel/tsacct.c | 1 +
5 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 504e784b7ffa..57b3d6c07875 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -25,6 +25,8 @@

#include <linux/sched.h>
#include <linux/ptrace.h>
+#include <linux/cred.h>
+
#include <uapi/linux/audit.h>

#define AUDIT_INO_UNSET ((unsigned long)-1)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index aad3fd0ff5f8..bf51dc2dc14a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3,6 +3,7 @@

#include <linux/linkage.h>
#include <linux/wait.h>
+#include <linux/cred.h>
#include <linux/kdev_t.h>
#include <linux/dcache.h>
#include <linux/path.h>
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 2cf446704cd4..0a5abc3dc937 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -6,7 +6,7 @@
#include <linux/sched.h>
#include <linux/sched/jobctl.h>
#include <linux/sched/task.h>
-#include <linux/cred.h>
+#include <linux/wait.h>

/*
* Types defining task->signal and task->sighand and APIs using them:
@@ -289,8 +289,10 @@ extern int force_sigsegv(int, struct task_struct *);
extern int force_sig_info(int, struct siginfo *, struct task_struct *);
extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
-extern int kill_pid_info_as_cred(int, struct siginfo *, struct pid *,
- const struct cred *, u32);
+
+struct cred;
+extern int kill_pid_info_as_cred(int, struct siginfo *, struct pid *, const struct cred *, u32);
+
extern int kill_pgrp(struct pid *pid, int sig, int priv);
extern int kill_pid(struct pid *pid, int sig, int priv);
extern int kill_proc_info(int, struct siginfo *, pid_t);
diff --git a/include/linux/wait.h b/include/linux/wait.h
index aacb1282d19a..e8e5a2ea3bbd 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -1224,4 +1224,7 @@ int wait_on_atomic_t(atomic_t *val, int (*action)(atomic_t *), unsigned mode)
return out_of_line_wait_on_atomic_t(val, action, mode);
}

+/* NOTE: this is temporary, and it needs to come last, due to type dependencies: */
+#include <linux/sched/signal.h>
+
#endif /* _LINUX_WAIT_H */
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 370724b45391..63834bd86639 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -23,6 +23,7 @@
#include <linux/tsacct_kern.h>
#include <linux/acct.h>
#include <linux/jiffies.h>
+#include <linux/cred.h>
#include <linux/mm.h>

/*