aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Lutomirski <[email protected]>2016-03-22 14:24:43 -0700
committerLinus Torvalds <[email protected]>2016-03-22 15:36:02 -0700
commit5180e3e24fd3e8e7ea46fbe21e10f5ea3fb1edaa (patch)
treeba5283961497ff4608eecf8e620ffbd1fd4b2462
parentb4aa14a63cb3194d8eab355fcee194838ab09121 (diff)
compat: add in_compat_syscall to ask whether we're in a compat syscall
A lot of code currently abuses is_compat_task to determine this. Signed-off-by: Andy Lutomirski <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: Andreas Dilger <[email protected]> Cc: Clemens Ladisch <[email protected]> Cc: David Airlie <[email protected]> Cc: David Herrmann <[email protected]> Cc: David Miller <[email protected]> Cc: Dmitry Torokhov <[email protected]> Cc: Eric Paris <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Ingo Molnar <[email protected]> Acked-by: Jiri Kosina <[email protected]> Cc: Matt Fleming <[email protected]> Cc: Neil Horman <[email protected]> Cc: Oded Gabbay <[email protected]> Cc: Oleg Drokin <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Paul Moore <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Steffen Klassert <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vlad Yasevich <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--include/linux/compat.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h
index fe4ccd0c748a..f964ef79e0ad 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -5,6 +5,8 @@
* syscall compatibility layer.
*/
+#include <linux/types.h>
+
#ifdef CONFIG_COMPAT
#include <linux/stat.h>
@@ -719,9 +721,22 @@ asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32,
int, const char __user *);
+
+/*
+ * For most but not all architectures, "am I in a compat syscall?" and
+ * "am I a compat task?" are the same question. For architectures on which
+ * they aren't the same question, arch code can override in_compat_syscall.
+ */
+
+#ifndef in_compat_syscall
+static inline bool in_compat_syscall(void) { return is_compat_task(); }
+#endif
+
#else
#define is_compat_task() (0)
+static inline bool in_compat_syscall(void) { return false; }
#endif /* CONFIG_COMPAT */
+
#endif /* _LINUX_COMPAT_H */