Skip to content

Commit 4ddb45d

Browse files
Dominik BrodowskiIngo Molnar
authored andcommitted
x86/syscalls: Use COMPAT_SYSCALL_DEFINEx() macros for x86-only compat syscalls
While at it, convert declarations of type "unsigned" to "unsigned int". Signed-off-by: Dominik Brodowski <[email protected]> Acked-by: Linus Torvalds <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 7c2178c commit 4ddb45d

File tree

3 files changed

+76
-62
lines changed

3 files changed

+76
-62
lines changed

arch/x86/entry/syscalls/syscall_32.tbl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
4 i386 write sys_write
1414
5 i386 open sys_open compat_sys_open
1515
6 i386 close sys_close
16-
7 i386 waitpid sys_waitpid sys32_waitpid
16+
7 i386 waitpid sys_waitpid compat_sys_x86_waitpid
1717
8 i386 creat sys_creat
1818
9 i386 link sys_link
1919
10 i386 unlink sys_unlink
@@ -96,7 +96,7 @@
9696
87 i386 swapon sys_swapon
9797
88 i386 reboot sys_reboot
9898
89 i386 readdir sys_old_readdir compat_sys_old_readdir
99-
90 i386 mmap sys_old_mmap sys32_mmap
99+
90 i386 mmap sys_old_mmap compat_sys_x86_mmap
100100
91 i386 munmap sys_munmap
101101
92 i386 truncate sys_truncate compat_sys_truncate
102102
93 i386 ftruncate sys_ftruncate compat_sys_ftruncate
@@ -186,8 +186,8 @@
186186
177 i386 rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait
187187
178 i386 rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo
188188
179 i386 rt_sigsuspend sys_rt_sigsuspend
189-
180 i386 pread64 sys_pread64 sys32_pread
190-
181 i386 pwrite64 sys_pwrite64 sys32_pwrite
189+
180 i386 pread64 sys_pread64 compat_sys_x86_pread
190+
181 i386 pwrite64 sys_pwrite64 compat_sys_x86_pwrite
191191
182 i386 chown sys_chown16
192192
183 i386 getcwd sys_getcwd
193193
184 i386 capget sys_capget
@@ -199,11 +199,11 @@
199199
190 i386 vfork sys_vfork
200200
191 i386 ugetrlimit sys_getrlimit compat_sys_getrlimit
201201
192 i386 mmap2 sys_mmap_pgoff
202-
193 i386 truncate64 sys_truncate64 sys32_truncate64
203-
194 i386 ftruncate64 sys_ftruncate64 sys32_ftruncate64
204-
195 i386 stat64 sys_stat64 sys32_stat64
205-
196 i386 lstat64 sys_lstat64 sys32_lstat64
206-
197 i386 fstat64 sys_fstat64 sys32_fstat64
202+
193 i386 truncate64 sys_truncate64 compat_sys_x86_truncate64
203+
194 i386 ftruncate64 sys_ftruncate64 compat_sys_x86_ftruncate64
204+
195 i386 stat64 sys_stat64 compat_sys_x86_stat64
205+
196 i386 lstat64 sys_lstat64 compat_sys_x86_lstat64
206+
197 i386 fstat64 sys_fstat64 compat_sys_x86_fstat64
207207
198 i386 lchown32 sys_lchown
208208
199 i386 getuid32 sys_getuid
209209
200 i386 getgid32 sys_getgid
@@ -231,7 +231,7 @@
231231
# 222 is unused
232232
# 223 is unused
233233
224 i386 gettid sys_gettid
234-
225 i386 readahead sys_readahead sys32_readahead
234+
225 i386 readahead sys_readahead compat_sys_x86_readahead
235235
226 i386 setxattr sys_setxattr
236236
227 i386 lsetxattr sys_lsetxattr
237237
228 i386 fsetxattr sys_fsetxattr
@@ -256,7 +256,7 @@
256256
247 i386 io_getevents sys_io_getevents compat_sys_io_getevents
257257
248 i386 io_submit sys_io_submit compat_sys_io_submit
258258
249 i386 io_cancel sys_io_cancel
259-
250 i386 fadvise64 sys_fadvise64 sys32_fadvise64
259+
250 i386 fadvise64 sys_fadvise64 compat_sys_x86_fadvise64
260260
# 251 is available for reuse (was briefly sys_set_zone_reclaim)
261261
252 i386 exit_group sys_exit_group
262262
253 i386 lookup_dcookie sys_lookup_dcookie compat_sys_lookup_dcookie
@@ -278,7 +278,7 @@
278278
269 i386 fstatfs64 sys_fstatfs64 compat_sys_fstatfs64
279279
270 i386 tgkill sys_tgkill
280280
271 i386 utimes sys_utimes compat_sys_utimes
281-
272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
281+
272 i386 fadvise64_64 sys_fadvise64_64 compat_sys_x86_fadvise64_64
282282
273 i386 vserver
283283
274 i386 mbind sys_mbind
284284
275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
@@ -306,7 +306,7 @@
306306
297 i386 mknodat sys_mknodat
307307
298 i386 fchownat sys_fchownat
308308
299 i386 futimesat sys_futimesat compat_sys_futimesat
309-
300 i386 fstatat64 sys_fstatat64 sys32_fstatat
309+
300 i386 fstatat64 sys_fstatat64 compat_sys_x86_fstatat
310310
301 i386 unlinkat sys_unlinkat
311311
302 i386 renameat sys_renameat
312312
303 i386 linkat sys_linkat
@@ -320,7 +320,7 @@
320320
311 i386 set_robust_list sys_set_robust_list compat_sys_set_robust_list
321321
312 i386 get_robust_list sys_get_robust_list compat_sys_get_robust_list
322322
313 i386 splice sys_splice
323-
314 i386 sync_file_range sys_sync_file_range sys32_sync_file_range
323+
314 i386 sync_file_range sys_sync_file_range compat_sys_x86_sync_file_range
324324
315 i386 tee sys_tee
325325
316 i386 vmsplice sys_vmsplice compat_sys_vmsplice
326326
317 i386 move_pages sys_move_pages compat_sys_move_pages
@@ -330,7 +330,7 @@
330330
321 i386 signalfd sys_signalfd compat_sys_signalfd
331331
322 i386 timerfd_create sys_timerfd_create
332332
323 i386 eventfd sys_eventfd
333-
324 i386 fallocate sys_fallocate sys32_fallocate
333+
324 i386 fallocate sys_fallocate compat_sys_x86_fallocate
334334
325 i386 timerfd_settime sys_timerfd_settime compat_sys_timerfd_settime
335335
326 i386 timerfd_gettime sys_timerfd_gettime compat_sys_timerfd_gettime
336336
327 i386 signalfd4 sys_signalfd4 compat_sys_signalfd4

arch/x86/ia32/sys_ia32.c

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@
5151
#define AA(__x) ((unsigned long)(__x))
5252

5353

54-
asmlinkage long sys32_truncate64(const char __user *filename,
55-
unsigned long offset_low,
56-
unsigned long offset_high)
54+
COMPAT_SYSCALL_DEFINE3(x86_truncate64, const char __user *, filename,
55+
unsigned long, offset_low, unsigned long, offset_high)
5756
{
5857
return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
5958
}
6059

61-
asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
62-
unsigned long offset_high)
60+
COMPAT_SYSCALL_DEFINE3(x86_ftruncate64, unsigned int, fd,
61+
unsigned long, offset_low, unsigned long, offset_high)
6362
{
6463
return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
6564
}
@@ -96,8 +95,8 @@ static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
9695
return 0;
9796
}
9897

99-
asmlinkage long sys32_stat64(const char __user *filename,
100-
struct stat64 __user *statbuf)
98+
COMPAT_SYSCALL_DEFINE2(x86_stat64, const char __user *, filename,
99+
struct stat64 __user *, statbuf)
101100
{
102101
struct kstat stat;
103102
int ret = vfs_stat(filename, &stat);
@@ -107,8 +106,8 @@ asmlinkage long sys32_stat64(const char __user *filename,
107106
return ret;
108107
}
109108

110-
asmlinkage long sys32_lstat64(const char __user *filename,
111-
struct stat64 __user *statbuf)
109+
COMPAT_SYSCALL_DEFINE2(x86_lstat64, const char __user *, filename,
110+
struct stat64 __user *, statbuf)
112111
{
113112
struct kstat stat;
114113
int ret = vfs_lstat(filename, &stat);
@@ -117,7 +116,8 @@ asmlinkage long sys32_lstat64(const char __user *filename,
117116
return ret;
118117
}
119118

120-
asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
119+
COMPAT_SYSCALL_DEFINE2(x86_fstat64, unsigned int, fd,
120+
struct stat64 __user *, statbuf)
121121
{
122122
struct kstat stat;
123123
int ret = vfs_fstat(fd, &stat);
@@ -126,8 +126,9 @@ asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
126126
return ret;
127127
}
128128

129-
asmlinkage long sys32_fstatat(unsigned int dfd, const char __user *filename,
130-
struct stat64 __user *statbuf, int flag)
129+
COMPAT_SYSCALL_DEFINE4(x86_fstatat, unsigned int, dfd,
130+
const char __user *, filename,
131+
struct stat64 __user *, statbuf, int, flag)
131132
{
132133
struct kstat stat;
133134
int error;
@@ -153,7 +154,7 @@ struct mmap_arg_struct32 {
153154
unsigned int offset;
154155
};
155156

156-
asmlinkage long sys32_mmap(struct mmap_arg_struct32 __user *arg)
157+
COMPAT_SYSCALL_DEFINE1(x86_mmap, struct mmap_arg_struct32 __user *, arg)
157158
{
158159
struct mmap_arg_struct32 a;
159160

@@ -167,22 +168,22 @@ asmlinkage long sys32_mmap(struct mmap_arg_struct32 __user *arg)
167168
a.offset>>PAGE_SHIFT);
168169
}
169170

170-
asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int __user *stat_addr,
171-
int options)
171+
COMPAT_SYSCALL_DEFINE3(x86_waitpid, compat_pid_t, pid, unsigned int __user *,
172+
stat_addr, int, options)
172173
{
173174
return compat_sys_wait4(pid, stat_addr, options, NULL);
174175
}
175176

176177
/* warning: next two assume little endian */
177-
asmlinkage long sys32_pread(unsigned int fd, char __user *ubuf, u32 count,
178-
u32 poslo, u32 poshi)
178+
COMPAT_SYSCALL_DEFINE5(x86_pread, unsigned int, fd, char __user *, ubuf,
179+
u32, count, u32, poslo, u32, poshi)
179180
{
180181
return sys_pread64(fd, ubuf, count,
181182
((loff_t)AA(poshi) << 32) | AA(poslo));
182183
}
183184

184-
asmlinkage long sys32_pwrite(unsigned int fd, const char __user *ubuf,
185-
u32 count, u32 poslo, u32 poshi)
185+
COMPAT_SYSCALL_DEFINE5(x86_pwrite, unsigned int, fd, const char __user *, ubuf,
186+
u32, count, u32, poslo, u32, poshi)
186187
{
187188
return sys_pwrite64(fd, ubuf, count,
188189
((loff_t)AA(poshi) << 32) | AA(poslo));
@@ -193,39 +194,41 @@ asmlinkage long sys32_pwrite(unsigned int fd, const char __user *ubuf,
193194
* Some system calls that need sign extended arguments. This could be
194195
* done by a generic wrapper.
195196
*/
196-
long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
197-
__u32 len_low, __u32 len_high, int advice)
197+
COMPAT_SYSCALL_DEFINE6(x86_fadvise64_64, int, fd, __u32, offset_low,
198+
__u32, offset_high, __u32, len_low, __u32, len_high,
199+
int, advice)
198200
{
199201
return sys_fadvise64_64(fd,
200202
(((u64)offset_high)<<32) | offset_low,
201203
(((u64)len_high)<<32) | len_low,
202204
advice);
203205
}
204206

205-
asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,
206-
size_t count)
207+
COMPAT_SYSCALL_DEFINE4(x86_readahead, int, fd, unsigned int, off_lo,
208+
unsigned int, off_hi, size_t, count)
207209
{
208210
return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
209211
}
210212

211-
asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
212-
unsigned n_low, unsigned n_hi, int flags)
213+
COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low,
214+
unsigned int, off_hi, unsigned int, n_low,
215+
unsigned int, n_hi, int, flags)
213216
{
214217
return sys_sync_file_range(fd,
215218
((u64)off_hi << 32) | off_low,
216219
((u64)n_hi << 32) | n_low, flags);
217220
}
218221

219-
asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
220-
size_t len, int advice)
222+
COMPAT_SYSCALL_DEFINE5(x86_fadvise64, int, fd, unsigned int, offset_lo,
223+
unsigned int, offset_hi, size_t, len, int, advice)
221224
{
222225
return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
223226
len, advice);
224227
}
225228

226-
asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
227-
unsigned offset_hi, unsigned len_lo,
228-
unsigned len_hi)
229+
COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode,
230+
unsigned int, offset_lo, unsigned int, offset_hi,
231+
unsigned int, len_lo, unsigned int, len_hi)
229232
{
230233
return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
231234
((u64)len_hi << 32) | len_lo);

arch/x86/include/asm/sys_ia32.h

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,41 @@
2020
#include <asm/ia32.h>
2121

2222
/* ia32/sys_ia32.c */
23-
asmlinkage long sys32_truncate64(const char __user *, unsigned long, unsigned long);
24-
asmlinkage long sys32_ftruncate64(unsigned int, unsigned long, unsigned long);
23+
asmlinkage long compat_sys_x86_truncate64(const char __user *, unsigned long,
24+
unsigned long);
25+
asmlinkage long compat_sys_x86_ftruncate64(unsigned int, unsigned long,
26+
unsigned long);
2527

26-
asmlinkage long sys32_stat64(const char __user *, struct stat64 __user *);
27-
asmlinkage long sys32_lstat64(const char __user *, struct stat64 __user *);
28-
asmlinkage long sys32_fstat64(unsigned int, struct stat64 __user *);
29-
asmlinkage long sys32_fstatat(unsigned int, const char __user *,
28+
asmlinkage long compat_sys_x86_stat64(const char __user *,
29+
struct stat64 __user *);
30+
asmlinkage long compat_sys_x86_lstat64(const char __user *,
31+
struct stat64 __user *);
32+
asmlinkage long compat_sys_x86_fstat64(unsigned int, struct stat64 __user *);
33+
asmlinkage long compat_sys_x86_fstatat(unsigned int, const char __user *,
3034
struct stat64 __user *, int);
3135
struct mmap_arg_struct32;
32-
asmlinkage long sys32_mmap(struct mmap_arg_struct32 __user *);
36+
asmlinkage long compat_sys_x86_mmap(struct mmap_arg_struct32 __user *);
3337

34-
asmlinkage long sys32_waitpid(compat_pid_t, unsigned int __user *, int);
38+
asmlinkage long compat_sys_x86_waitpid(compat_pid_t, unsigned int __user *,
39+
int);
3540

36-
asmlinkage long sys32_pread(unsigned int, char __user *, u32, u32, u32);
37-
asmlinkage long sys32_pwrite(unsigned int, const char __user *, u32, u32, u32);
41+
asmlinkage long compat_sys_x86_pread(unsigned int, char __user *, u32, u32,
42+
u32);
43+
asmlinkage long compat_sys_x86_pwrite(unsigned int, const char __user *, u32,
44+
u32, u32);
3845

39-
long sys32_fadvise64_64(int, __u32, __u32, __u32, __u32, int);
46+
asmlinkage long compat_sys_x86_fadvise64_64(int, __u32, __u32, __u32, __u32,
47+
int);
4048

41-
asmlinkage ssize_t sys32_readahead(int, unsigned, unsigned, size_t);
42-
asmlinkage long sys32_sync_file_range(int, unsigned, unsigned,
43-
unsigned, unsigned, int);
44-
asmlinkage long sys32_fadvise64(int, unsigned, unsigned, size_t, int);
45-
asmlinkage long sys32_fallocate(int, int, unsigned,
46-
unsigned, unsigned, unsigned);
49+
asmlinkage ssize_t compat_sys_x86_readahead(int, unsigned int, unsigned int,
50+
size_t);
51+
asmlinkage long compat_sys_x86_sync_file_range(int, unsigned int, unsigned int,
52+
unsigned int, unsigned int,
53+
int);
54+
asmlinkage long compat_sys_x86_fadvise64(int, unsigned int, unsigned int,
55+
size_t, int);
56+
asmlinkage long compat_sys_x86_fallocate(int, int, unsigned int, unsigned int,
57+
unsigned int, unsigned int);
4758

4859
/* ia32/ia32_signal.c */
4960
asmlinkage long sys32_sigreturn(void);

0 commit comments

Comments
 (0)