diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2009-01-14 08:13:59 -0500 |
---|---|---|
committer | Heiko Carstens <heiko.carstens@de.ibm.com> | 2009-01-14 08:15:16 -0500 |
commit | 1a94bc34768e463a93cb3751819709ab0ea80a01 (patch) | |
tree | a27753a61c2aa02d31b2d1f8efe9f00e68770856 /include | |
parent | f627a741d24f12955fa2d9f8831c3b12860635bd (diff) |
[CVE-2009-0029] System call wrapper infrastructure
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
By selecting HAVE_SYSCALL_WRAPPERS architectures can activate
system call wrappers in order to sign extend system call arguments.
All architectures where the ABI defines that the caller of a function
has to perform sign extension probably need this.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/syscalls.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index ca079c3d09e3..0bb537d7ba2e 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -66,6 +66,68 @@ struct old_linux_dirent; | |||
66 | #include <linux/quota.h> | 66 | #include <linux/quota.h> |
67 | #include <linux/key.h> | 67 | #include <linux/key.h> |
68 | 68 | ||
69 | #define __SC_DECL1(t1, a1) t1 a1 | ||
70 | #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__) | ||
71 | #define __SC_DECL3(t3, a3, ...) t3 a3, __SC_DECL2(__VA_ARGS__) | ||
72 | #define __SC_DECL4(t4, a4, ...) t4 a4, __SC_DECL3(__VA_ARGS__) | ||
73 | #define __SC_DECL5(t5, a5, ...) t5 a5, __SC_DECL4(__VA_ARGS__) | ||
74 | #define __SC_DECL6(t6, a6, ...) t6 a6, __SC_DECL5(__VA_ARGS__) | ||
75 | |||
76 | #define __SC_LONG1(t1, a1) long a1 | ||
77 | #define __SC_LONG2(t2, a2, ...) long a2, __SC_LONG1(__VA_ARGS__) | ||
78 | #define __SC_LONG3(t3, a3, ...) long a3, __SC_LONG2(__VA_ARGS__) | ||
79 | #define __SC_LONG4(t4, a4, ...) long a4, __SC_LONG3(__VA_ARGS__) | ||
80 | #define __SC_LONG5(t5, a5, ...) long a5, __SC_LONG4(__VA_ARGS__) | ||
81 | #define __SC_LONG6(t6, a6, ...) long a6, __SC_LONG5(__VA_ARGS__) | ||
82 | |||
83 | #define __SC_CAST1(t1, a1) (t1) a1 | ||
84 | #define __SC_CAST2(t2, a2, ...) (t2) a2, __SC_CAST1(__VA_ARGS__) | ||
85 | #define __SC_CAST3(t3, a3, ...) (t3) a3, __SC_CAST2(__VA_ARGS__) | ||
86 | #define __SC_CAST4(t4, a4, ...) (t4) a4, __SC_CAST3(__VA_ARGS__) | ||
87 | #define __SC_CAST5(t5, a5, ...) (t5) a5, __SC_CAST4(__VA_ARGS__) | ||
88 | #define __SC_CAST6(t6, a6, ...) (t6) a6, __SC_CAST5(__VA_ARGS__) | ||
89 | |||
90 | #define __SC_TEST(type) BUILD_BUG_ON(sizeof(type) > sizeof(long)) | ||
91 | #define __SC_TEST1(t1, a1) __SC_TEST(t1) | ||
92 | #define __SC_TEST2(t2, a2, ...) __SC_TEST(t2); __SC_TEST1(__VA_ARGS__) | ||
93 | #define __SC_TEST3(t3, a3, ...) __SC_TEST(t3); __SC_TEST2(__VA_ARGS__) | ||
94 | #define __SC_TEST4(t4, a4, ...) __SC_TEST(t4); __SC_TEST3(__VA_ARGS__) | ||
95 | #define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__) | ||
96 | #define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__) | ||
97 | |||
98 | #define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) | ||
99 | #define SYSCALL_DEFINE1(...) SYSCALL_DEFINEx(1, __VA_ARGS__) | ||
100 | #define SYSCALL_DEFINE2(...) SYSCALL_DEFINEx(2, __VA_ARGS__) | ||
101 | #define SYSCALL_DEFINE3(...) SYSCALL_DEFINEx(3, __VA_ARGS__) | ||
102 | #define SYSCALL_DEFINE4(...) SYSCALL_DEFINEx(4, __VA_ARGS__) | ||
103 | #define SYSCALL_DEFINE5(...) SYSCALL_DEFINEx(5, __VA_ARGS__) | ||
104 | #define SYSCALL_DEFINE6(...) SYSCALL_DEFINEx(6, __VA_ARGS__) | ||
105 | |||
106 | #define SYSCALL_ALIAS(alias, name) \ | ||
107 | asm ("\t.globl " #alias "\n\t.set " #alias ", " #name) | ||
108 | |||
109 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
110 | |||
111 | #define SYSCALL_DEFINE(name) static inline long SYSC_##name | ||
112 | #define SYSCALL_DEFINEx(x, name, ...) \ | ||
113 | asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__)); \ | ||
114 | static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__)); \ | ||
115 | asmlinkage long SyS_##name(__SC_LONG##x(__VA_ARGS__)) \ | ||
116 | { \ | ||
117 | __SC_TEST##x(__VA_ARGS__); \ | ||
118 | return (long) SYSC_##name(__SC_CAST##x(__VA_ARGS__)); \ | ||
119 | } \ | ||
120 | SYSCALL_ALIAS(sys_##name, SyS_##name); \ | ||
121 | static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__)) | ||
122 | |||
123 | #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ | ||
124 | |||
125 | #define SYSCALL_DEFINE(name) asmlinkage long sys_##name | ||
126 | #define SYSCALL_DEFINEx(x, name, ...) \ | ||
127 | asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__)) | ||
128 | |||
129 | #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ | ||
130 | |||
69 | asmlinkage long sys_time(time_t __user *tloc); | 131 | asmlinkage long sys_time(time_t __user *tloc); |
70 | asmlinkage long sys_stime(time_t __user *tptr); | 132 | asmlinkage long sys_stime(time_t __user *tptr); |
71 | asmlinkage long sys_gettimeofday(struct timeval __user *tv, | 133 | asmlinkage long sys_gettimeofday(struct timeval __user *tv, |