blob: 44d931f084145bd1c4274002ed9a7f24230f1f7c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on
Thomas Gleixnerc202f292008-01-30 13:30:08 +01003 * sys_sparc32
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * Copyright (C) 2000 VA Linux Co
6 * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
Thomas Gleixnerc202f292008-01-30 13:30:08 +01007 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
8 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
9 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * Copyright (C) 2000 Hewlett-Packard Co.
11 * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
Thomas Gleixnerc202f292008-01-30 13:30:08 +010012 * Copyright (C) 2000,2001,2002 Andi Kleen, SuSE Labs (x86-64 port)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
14 * These routines maintain argument size conversion between 32bit and 64bit
Thomas Gleixnerc202f292008-01-30 13:30:08 +010015 * environment. In 2.5 most of this should be moved to a generic directory.
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 *
17 * This file assumes that there is a hole at the end of user address space.
Thomas Gleixnerc202f292008-01-30 13:30:08 +010018 *
19 * Some of the functions are LE specific currently. These are
20 * hopefully all marked. This should be fixed.
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 */
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/kernel.h>
24#include <linux/sched.h>
Thomas Gleixnerc202f292008-01-30 13:30:08 +010025#include <linux/fs.h>
26#include <linux/file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/signal.h>
28#include <linux/syscalls.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/times.h>
30#include <linux/utsname.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/smp_lock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/mm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <linux/uio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <linux/poll.h>
35#include <linux/personality.h>
36#include <linux/stat.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/rwsem.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <linux/compat.h>
39#include <linux/vfs.h>
40#include <linux/ptrace.h>
41#include <linux/highuid.h>
Andi Kleenddb15ec2006-09-26 10:52:33 +020042#include <linux/sysctl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <asm/mman.h>
44#include <asm/types.h>
45#include <asm/uaccess.h>
46#include <asm/semaphore.h>
47#include <asm/atomic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <asm/ia32.h>
Arnaldo Carvalho de Melo28d23122008-02-07 21:03:04 -020049#include <asm/vgtod.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51#define AA(__x) ((unsigned long)(__x))
52
53int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
54{
David Howellsafefdbb2006-10-03 01:13:46 -070055 compat_ino_t ino;
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 typeof(ubuf->st_uid) uid = 0;
58 typeof(ubuf->st_gid) gid = 0;
59 SET_UID(uid, kbuf->uid);
60 SET_GID(gid, kbuf->gid);
61 if (!old_valid_dev(kbuf->dev) || !old_valid_dev(kbuf->rdev))
62 return -EOVERFLOW;
63 if (kbuf->size >= 0x7fffffff)
64 return -EOVERFLOW;
David Howellsafefdbb2006-10-03 01:13:46 -070065 ino = kbuf->ino;
66 if (sizeof(ino) < sizeof(kbuf->ino) && ino != kbuf->ino)
67 return -EOVERFLOW;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
Thomas Gleixnerc202f292008-01-30 13:30:08 +010069 __put_user(old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
70 __put_user(ino, &ubuf->st_ino) ||
71 __put_user(kbuf->mode, &ubuf->st_mode) ||
72 __put_user(kbuf->nlink, &ubuf->st_nlink) ||
73 __put_user(uid, &ubuf->st_uid) ||
74 __put_user(gid, &ubuf->st_gid) ||
75 __put_user(old_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
76 __put_user(kbuf->size, &ubuf->st_size) ||
77 __put_user(kbuf->atime.tv_sec, &ubuf->st_atime) ||
78 __put_user(kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) ||
79 __put_user(kbuf->mtime.tv_sec, &ubuf->st_mtime) ||
80 __put_user(kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
81 __put_user(kbuf->ctime.tv_sec, &ubuf->st_ctime) ||
82 __put_user(kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
83 __put_user(kbuf->blksize, &ubuf->st_blksize) ||
84 __put_user(kbuf->blocks, &ubuf->st_blocks))
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 return -EFAULT;
86 return 0;
87}
88
Thomas Gleixnerc202f292008-01-30 13:30:08 +010089asmlinkage long sys32_truncate64(char __user *filename,
90 unsigned long offset_low,
91 unsigned long offset_high)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
93 return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
94}
95
Thomas Gleixnerc202f292008-01-30 13:30:08 +010096asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
97 unsigned long offset_high)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
99 return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
100}
101
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100102/*
103 * Another set for IA32/LFS -- x86_64 struct stat is different due to
104 * support for 64bit inode numbers.
105 */
106static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107{
108 typeof(ubuf->st_uid) uid = 0;
109 typeof(ubuf->st_gid) gid = 0;
110 SET_UID(uid, stat->uid);
111 SET_GID(gid, stat->gid);
112 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
113 __put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) ||
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100114 __put_user(stat->ino, &ubuf->__st_ino) ||
115 __put_user(stat->ino, &ubuf->st_ino) ||
116 __put_user(stat->mode, &ubuf->st_mode) ||
117 __put_user(stat->nlink, &ubuf->st_nlink) ||
118 __put_user(uid, &ubuf->st_uid) ||
119 __put_user(gid, &ubuf->st_gid) ||
120 __put_user(huge_encode_dev(stat->rdev), &ubuf->st_rdev) ||
121 __put_user(stat->size, &ubuf->st_size) ||
122 __put_user(stat->atime.tv_sec, &ubuf->st_atime) ||
123 __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec) ||
124 __put_user(stat->mtime.tv_sec, &ubuf->st_mtime) ||
125 __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
126 __put_user(stat->ctime.tv_sec, &ubuf->st_ctime) ||
127 __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
128 __put_user(stat->blksize, &ubuf->st_blksize) ||
129 __put_user(stat->blocks, &ubuf->st_blocks))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 return -EFAULT;
131 return 0;
132}
133
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100134asmlinkage long sys32_stat64(char __user *filename,
135 struct stat64 __user *statbuf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136{
137 struct kstat stat;
138 int ret = vfs_stat(filename, &stat);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 if (!ret)
141 ret = cp_stat64(statbuf, &stat);
142 return ret;
143}
144
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100145asmlinkage long sys32_lstat64(char __user *filename,
146 struct stat64 __user *statbuf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
148 struct kstat stat;
149 int ret = vfs_lstat(filename, &stat);
150 if (!ret)
151 ret = cp_stat64(statbuf, &stat);
152 return ret;
153}
154
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100155asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156{
157 struct kstat stat;
158 int ret = vfs_fstat(fd, &stat);
159 if (!ret)
160 ret = cp_stat64(statbuf, &stat);
161 return ret;
162}
163
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100164asmlinkage long sys32_fstatat(unsigned int dfd, char __user *filename,
165 struct stat64 __user *statbuf, int flag)
Ulrich Dreppercff2b762006-02-11 17:55:47 -0800166{
167 struct kstat stat;
168 int error = -EINVAL;
169
170 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
171 goto out;
172
173 if (flag & AT_SYMLINK_NOFOLLOW)
174 error = vfs_lstat_fd(dfd, filename, &stat);
175 else
176 error = vfs_stat_fd(dfd, filename, &stat);
177
178 if (!error)
179 error = cp_stat64(statbuf, &stat);
180
181out:
182 return error;
183}
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185/*
186 * Linux/i386 didn't use to be able to handle more than
187 * 4 system call parameters, so these system calls used a memory
188 * block for parameter passing..
189 */
190
191struct mmap_arg_struct {
192 unsigned int addr;
193 unsigned int len;
194 unsigned int prot;
195 unsigned int flags;
196 unsigned int fd;
197 unsigned int offset;
198};
199
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100200asmlinkage long sys32_mmap(struct mmap_arg_struct __user *arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201{
202 struct mmap_arg_struct a;
203 struct file *file = NULL;
204 unsigned long retval;
205 struct mm_struct *mm ;
206
207 if (copy_from_user(&a, arg, sizeof(a)))
208 return -EFAULT;
209
210 if (a.offset & ~PAGE_MASK)
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100211 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
213 if (!(a.flags & MAP_ANONYMOUS)) {
214 file = fget(a.fd);
215 if (!file)
216 return -EBADF;
217 }
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100218
219 mm = current->mm;
220 down_write(&mm->mmap_sem);
221 retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags,
222 a.offset>>PAGE_SHIFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 if (file)
224 fput(file);
225
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100226 up_write(&mm->mmap_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
228 return retval;
229}
230
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100231asmlinkage long sys32_mprotect(unsigned long start, size_t len,
232 unsigned long prot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100234 return sys_mprotect(start, len, prot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235}
236
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100237asmlinkage long sys32_pipe(int __user *fd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
239 int retval;
240 int fds[2];
241
242 retval = do_pipe(fds);
243 if (retval)
244 goto out;
245 if (copy_to_user(fd, fds, sizeof(fds)))
246 retval = -EFAULT;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100247out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 return retval;
249}
250
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100251asmlinkage long sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
252 struct sigaction32 __user *oact,
253 unsigned int sigsetsize)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254{
255 struct k_sigaction new_ka, old_ka;
256 int ret;
257 compat_sigset_t set32;
258
259 /* XXX: Don't preclude handling different sized sigset_t's. */
260 if (sigsetsize != sizeof(compat_sigset_t))
261 return -EINVAL;
262
263 if (act) {
264 compat_uptr_t handler, restorer;
265
266 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
267 __get_user(handler, &act->sa_handler) ||
268 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100269 __get_user(restorer, &act->sa_restorer) ||
270 __copy_from_user(&set32, &act->sa_mask,
271 sizeof(compat_sigset_t)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 return -EFAULT;
273 new_ka.sa.sa_handler = compat_ptr(handler);
274 new_ka.sa.sa_restorer = compat_ptr(restorer);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100275
276 /*
277 * FIXME: here we rely on _COMPAT_NSIG_WORS to be >=
278 * than _NSIG_WORDS << 1
279 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 switch (_NSIG_WORDS) {
281 case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6]
282 | (((long)set32.sig[7]) << 32);
283 case 3: new_ka.sa.sa_mask.sig[2] = set32.sig[4]
284 | (((long)set32.sig[5]) << 32);
285 case 2: new_ka.sa.sa_mask.sig[1] = set32.sig[2]
286 | (((long)set32.sig[3]) << 32);
287 case 1: new_ka.sa.sa_mask.sig[0] = set32.sig[0]
288 | (((long)set32.sig[1]) << 32);
289 }
290 }
291
292 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
293
294 if (!ret && oact) {
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100295 /*
296 * FIXME: here we rely on _COMPAT_NSIG_WORS to be >=
297 * than _NSIG_WORDS << 1
298 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 switch (_NSIG_WORDS) {
300 case 4:
301 set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32);
302 set32.sig[6] = old_ka.sa.sa_mask.sig[3];
303 case 3:
304 set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32);
305 set32.sig[4] = old_ka.sa.sa_mask.sig[2];
306 case 2:
307 set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32);
308 set32.sig[2] = old_ka.sa.sa_mask.sig[1];
309 case 1:
310 set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
311 set32.sig[0] = old_ka.sa.sa_mask.sig[0];
312 }
313 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100314 __put_user(ptr_to_compat(old_ka.sa.sa_handler),
315 &oact->sa_handler) ||
316 __put_user(ptr_to_compat(old_ka.sa.sa_restorer),
317 &oact->sa_restorer) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100319 __copy_to_user(&oact->sa_mask, &set32,
320 sizeof(compat_sigset_t)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 return -EFAULT;
322 }
323
324 return ret;
325}
326
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100327asmlinkage long sys32_sigaction(int sig, struct old_sigaction32 __user *act,
328 struct old_sigaction32 __user *oact)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329{
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100330 struct k_sigaction new_ka, old_ka;
331 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100333 if (act) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 compat_old_sigset_t mask;
335 compat_uptr_t handler, restorer;
336
337 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
338 __get_user(handler, &act->sa_handler) ||
339 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
340 __get_user(restorer, &act->sa_restorer) ||
341 __get_user(mask, &act->sa_mask))
342 return -EFAULT;
343
344 new_ka.sa.sa_handler = compat_ptr(handler);
345 new_ka.sa.sa_restorer = compat_ptr(restorer);
346
347 siginitset(&new_ka.sa.sa_mask, mask);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100348 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100350 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
352 if (!ret && oact) {
353 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100354 __put_user(ptr_to_compat(old_ka.sa.sa_handler),
355 &oact->sa_handler) ||
356 __put_user(ptr_to_compat(old_ka.sa.sa_restorer),
357 &oact->sa_restorer) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
359 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
360 return -EFAULT;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100361 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362
363 return ret;
364}
365
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100366asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
367 compat_sigset_t __user *oset,
368 unsigned int sigsetsize)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369{
370 sigset_t s;
371 compat_sigset_t s32;
372 int ret;
373 mm_segment_t old_fs = get_fs();
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100374
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 if (set) {
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100376 if (copy_from_user(&s32, set, sizeof(compat_sigset_t)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 return -EFAULT;
378 switch (_NSIG_WORDS) {
379 case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
380 case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
381 case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
382 case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
383 }
384 }
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100385 set_fs(KERNEL_DS);
Andi Kleenddb15ec2006-09-26 10:52:33 +0200386 ret = sys_rt_sigprocmask(how,
387 set ? (sigset_t __user *)&s : NULL,
388 oset ? (sigset_t __user *)&s : NULL,
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100389 sigsetsize);
390 set_fs(old_fs);
391 if (ret)
392 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 if (oset) {
394 switch (_NSIG_WORDS) {
395 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
396 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
397 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
398 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
399 }
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100400 if (copy_to_user(oset, &s32, sizeof(compat_sigset_t)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 return -EFAULT;
402 }
403 return 0;
404}
405
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100406static inline long get_tv32(struct timeval *o, struct compat_timeval __user *i)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100408 int err = -EFAULT;
409
410 if (access_ok(VERIFY_READ, i, sizeof(*i))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 err = __get_user(o->tv_sec, &i->tv_sec);
412 err |= __get_user(o->tv_usec, &i->tv_usec);
413 }
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100414 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415}
416
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100417static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418{
419 int err = -EFAULT;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100420
421 if (access_ok(VERIFY_WRITE, o, sizeof(*o))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 err = __put_user(i->tv_sec, &o->tv_sec);
423 err |= __put_user(i->tv_usec, &o->tv_usec);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100424 }
425 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426}
427
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100428asmlinkage long sys32_alarm(unsigned int seconds)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429{
Thomas Gleixnerc08b8a42006-03-25 03:06:33 -0800430 return alarm_setitimer(seconds);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431}
432
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100433/*
434 * Translations due to time_t size differences. Which affects all
435 * sorts of things, like timeval and itimerval.
436 */
437asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv,
438 struct timezone __user *tz)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439{
440 if (tv) {
441 struct timeval ktv;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100442
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 do_gettimeofday(&ktv);
444 if (put_tv32(tv, &ktv))
445 return -EFAULT;
446 }
447 if (tz) {
448 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
449 return -EFAULT;
450 }
451 return 0;
452}
453
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100454asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv,
455 struct timezone __user *tz)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456{
457 struct timeval ktv;
458 struct timespec kts;
459 struct timezone ktz;
460
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100461 if (tv) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 if (get_tv32(&ktv, tv))
463 return -EFAULT;
464 kts.tv_sec = ktv.tv_sec;
465 kts.tv_nsec = ktv.tv_usec * NSEC_PER_USEC;
466 }
467 if (tz) {
468 if (copy_from_user(&ktz, tz, sizeof(ktz)))
469 return -EFAULT;
470 }
471
472 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
473}
474
475struct sel_arg_struct {
476 unsigned int n;
477 unsigned int inp;
478 unsigned int outp;
479 unsigned int exp;
480 unsigned int tvp;
481};
482
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100483asmlinkage long sys32_old_select(struct sel_arg_struct __user *arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484{
485 struct sel_arg_struct a;
486
487 if (copy_from_user(&a, arg, sizeof(a)))
488 return -EFAULT;
489 return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
490 compat_ptr(a.exp), compat_ptr(a.tvp));
491}
492
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100493asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr,
494 int options)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495{
496 return compat_sys_wait4(pid, stat_addr, options, NULL);
497}
498
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499/* 32-bit timeval and related flotsam. */
500
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100501asmlinkage long sys32_sysfs(int option, u32 arg1, u32 arg2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502{
503 return sys_sysfs(option, arg1, arg2);
504}
505
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100506asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
507 struct compat_timespec __user *interval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508{
509 struct timespec t;
510 int ret;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100511 mm_segment_t old_fs = get_fs();
512
513 set_fs(KERNEL_DS);
Andi Kleenddb15ec2006-09-26 10:52:33 +0200514 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100515 set_fs(old_fs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 if (put_compat_timespec(&t, interval))
517 return -EFAULT;
518 return ret;
519}
520
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100521asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
522 compat_size_t sigsetsize)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523{
524 sigset_t s;
525 compat_sigset_t s32;
526 int ret;
527 mm_segment_t old_fs = get_fs();
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100528
529 set_fs(KERNEL_DS);
Andi Kleenddb15ec2006-09-26 10:52:33 +0200530 ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100531 set_fs(old_fs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 if (!ret) {
533 switch (_NSIG_WORDS) {
534 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
535 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
536 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
537 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
538 }
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100539 if (copy_to_user(set, &s32, sizeof(compat_sigset_t)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 return -EFAULT;
541 }
542 return ret;
543}
544
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100545asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
546 compat_siginfo_t __user *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547{
548 siginfo_t info;
549 int ret;
550 mm_segment_t old_fs = get_fs();
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100551
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 if (copy_siginfo_from_user32(&info, uinfo))
553 return -EFAULT;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100554 set_fs(KERNEL_DS);
Andi Kleenddb15ec2006-09-26 10:52:33 +0200555 ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100556 set_fs(old_fs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 return ret;
558}
559
560/* These are here just in case some old ia32 binary calls it. */
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100561asmlinkage long sys32_pause(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562{
563 current->state = TASK_INTERRUPTIBLE;
564 schedule();
565 return -ERESTARTNOHAND;
566}
567
568
Eric W. Biedermanb89a8172006-09-27 01:51:04 -0700569#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570struct sysctl_ia32 {
571 unsigned int name;
572 int nlen;
573 unsigned int oldval;
574 unsigned int oldlenp;
575 unsigned int newval;
576 unsigned int newlen;
577 unsigned int __unused[4];
578};
579
580
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100581asmlinkage long sys32_sysctl(struct sysctl_ia32 __user *args32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582{
583 struct sysctl_ia32 a32;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100584 mm_segment_t old_fs = get_fs();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 void __user *oldvalp, *newvalp;
586 size_t oldlen;
587 int __user *namep;
588 long ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100590 if (copy_from_user(&a32, args32, sizeof(a32)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 return -EFAULT;
592
593 /*
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100594 * We need to pre-validate these because we have to disable
595 * address checking before calling do_sysctl() because of
596 * OLDLEN but we can't run the risk of the user specifying bad
597 * addresses here. Well, since we're dealing with 32 bit
598 * addresses, we KNOW that access_ok() will always succeed, so
599 * this is an expensive NOP, but so what...
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 */
601 namep = compat_ptr(a32.name);
602 oldvalp = compat_ptr(a32.oldval);
603 newvalp = compat_ptr(a32.newval);
604
605 if ((oldvalp && get_user(oldlen, (int __user *)compat_ptr(a32.oldlenp)))
606 || !access_ok(VERIFY_WRITE, namep, 0)
607 || !access_ok(VERIFY_WRITE, oldvalp, 0)
608 || !access_ok(VERIFY_WRITE, newvalp, 0))
609 return -EFAULT;
610
611 set_fs(KERNEL_DS);
612 lock_kernel();
Andi Kleenddb15ec2006-09-26 10:52:33 +0200613 ret = do_sysctl(namep, a32.nlen, oldvalp, (size_t __user *)&oldlen,
614 newvalp, (size_t) a32.newlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 unlock_kernel();
616 set_fs(old_fs);
617
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100618 if (oldvalp && put_user(oldlen, (int __user *)compat_ptr(a32.oldlenp)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 return -EFAULT;
620
621 return ret;
622}
623#endif
624
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100625/* warning: next two assume little endian */
626asmlinkage long sys32_pread(unsigned int fd, char __user *ubuf, u32 count,
627 u32 poslo, u32 poshi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628{
629 return sys_pread64(fd, ubuf, count,
630 ((loff_t)AA(poshi) << 32) | AA(poslo));
631}
632
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100633asmlinkage long sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count,
634 u32 poslo, u32 poshi)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635{
636 return sys_pwrite64(fd, ubuf, count,
637 ((loff_t)AA(poshi) << 32) | AA(poslo));
638}
639
640
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100641asmlinkage long sys32_personality(unsigned long personality)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642{
643 int ret;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100644
645 if (personality(current->personality) == PER_LINUX32 &&
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 personality == PER_LINUX)
647 personality = PER_LINUX32;
648 ret = sys_personality(personality);
649 if (ret == PER_LINUX32)
650 ret = PER_LINUX;
651 return ret;
652}
653
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100654asmlinkage long sys32_sendfile(int out_fd, int in_fd,
655 compat_off_t __user *offset, s32 count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656{
657 mm_segment_t old_fs = get_fs();
658 int ret;
659 off_t of;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100660
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 if (offset && get_user(of, offset))
662 return -EFAULT;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100663
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 set_fs(KERNEL_DS);
Andi Kleenddb15ec2006-09-26 10:52:33 +0200665 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
666 count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 set_fs(old_fs);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100668
Tsuneo.Yoshioka@f-secure.com83b942b2005-09-12 18:49:24 +0200669 if (offset && put_user(of, offset))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 return ret;
672}
673
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100675 unsigned long prot, unsigned long flags,
676 unsigned long fd, unsigned long pgoff)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677{
678 struct mm_struct *mm = current->mm;
679 unsigned long error;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100680 struct file *file = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681
682 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
683 if (!(flags & MAP_ANONYMOUS)) {
684 file = fget(fd);
685 if (!file)
686 return -EBADF;
687 }
688
689 down_write(&mm->mmap_sem);
690 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
691 up_write(&mm->mmap_sem);
692
693 if (file)
694 fput(file);
695 return error;
696}
697
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100698asmlinkage long sys32_olduname(struct oldold_utsname __user *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699{
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100700 char *arch = "x86_64";
Andi Kleen26c13f22006-09-26 10:52:40 +0200701 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702
703 if (!name)
704 return -EFAULT;
Serge E. Hallyne9ff3992006-10-02 02:18:11 -0700705 if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 return -EFAULT;
Serge E. Hallyne9ff3992006-10-02 02:18:11 -0700707
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100708 down_read(&uts_sem);
709
710 err = __copy_to_user(&name->sysname, &utsname()->sysname,
711 __OLD_UTS_LEN);
712 err |= __put_user(0, name->sysname+__OLD_UTS_LEN);
713 err |= __copy_to_user(&name->nodename, &utsname()->nodename,
714 __OLD_UTS_LEN);
715 err |= __put_user(0, name->nodename+__OLD_UTS_LEN);
716 err |= __copy_to_user(&name->release, &utsname()->release,
717 __OLD_UTS_LEN);
718 err |= __put_user(0, name->release+__OLD_UTS_LEN);
719 err |= __copy_to_user(&name->version, &utsname()->version,
720 __OLD_UTS_LEN);
721 err |= __put_user(0, name->version+__OLD_UTS_LEN);
722
723 if (personality(current->personality) == PER_LINUX32)
724 arch = "i686";
725
726 err |= __copy_to_user(&name->machine, arch, strlen(arch) + 1);
Serge E. Hallyne9ff3992006-10-02 02:18:11 -0700727
728 up_read(&uts_sem);
729
730 err = err ? -EFAULT : 0;
731
732 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733}
734
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100735long sys32_uname(struct old_utsname __user *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736{
737 int err;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100738
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 if (!name)
740 return -EFAULT;
741 down_read(&uts_sem);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100742 err = copy_to_user(name, utsname(), sizeof(*name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 up_read(&uts_sem);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100744 if (personality(current->personality) == PER_LINUX32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 err |= copy_to_user(&name->machine, "i686", 5);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100746
747 return err ? -EFAULT : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748}
749
750long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
751{
752 struct ustat u;
753 mm_segment_t seg;
754 int ret;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100755
756 seg = get_fs();
757 set_fs(KERNEL_DS);
Andi Kleenddb15ec2006-09-26 10:52:33 +0200758 ret = sys_ustat(dev, (struct ustat __user *)&u);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 set_fs(seg);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100760 if (ret < 0)
761 return ret;
762
763 if (!access_ok(VERIFY_WRITE, u32p, sizeof(struct ustat32)) ||
764 __put_user((__u32) u.f_tfree, &u32p->f_tfree) ||
765 __put_user((__u32) u.f_tinode, &u32p->f_tfree) ||
766 __copy_to_user(&u32p->f_fname, u.f_fname, sizeof(u.f_fname)) ||
767 __copy_to_user(&u32p->f_fpack, u.f_fpack, sizeof(u.f_fpack)))
768 ret = -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 return ret;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100770}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771
772asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
773 compat_uptr_t __user *envp, struct pt_regs *regs)
774{
775 long error;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100776 char *filename;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777
778 filename = getname(name);
779 error = PTR_ERR(filename);
780 if (IS_ERR(filename))
781 return error;
782 error = compat_do_execve(filename, argv, envp, regs);
783 if (error == 0) {
784 task_lock(current);
785 current->ptrace &= ~PT_DTRACE;
786 task_unlock(current);
787 }
788 putname(filename);
789 return error;
790}
791
792asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
793 struct pt_regs *regs)
794{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100795 void __user *parent_tid = (void __user *)regs->dx;
796 void __user *child_tid = (void __user *)regs->di;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100797
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 if (!newsp)
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100799 newsp = regs->sp;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100800 return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801}
802
803/*
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100804 * Some system calls that need sign extended arguments. This could be
805 * done by a generic wrapper.
806 */
807long sys32_lseek(unsigned int fd, int offset, unsigned int whence)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808{
809 return sys_lseek(fd, offset, whence);
810}
811
812long sys32_kill(int pid, int sig)
813{
814 return sys_kill(pid, sig);
815}
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100816
817long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 __u32 len_low, __u32 len_high, int advice)
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100819{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 return sys_fadvise64_64(fd,
821 (((u64)offset_high)<<32) | offset_low,
822 (((u64)len_high)<<32) | len_low,
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100823 advice);
824}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825
826long sys32_vm86_warning(void)
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100827{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 struct task_struct *me = current;
829 static char lastcomm[sizeof(me->comm)];
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100830
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100832 compat_printk(KERN_INFO
833 "%s: vm86 mode not supported on 64 bit kernel\n",
834 me->comm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 strncpy(lastcomm, me->comm, sizeof(lastcomm));
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100836 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 return -ENOSYS;
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100838}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839
840long sys32_lookup_dcookie(u32 addr_low, u32 addr_high,
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100841 char __user *buf, size_t len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842{
843 return sys_lookup_dcookie(((u64)addr_high << 32) | addr_low, buf, len);
844}
845
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100846asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,
847 size_t count)
Andi Kleene412ac42007-06-20 12:23:30 +0200848{
849 return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
850}
851
852asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100853 unsigned n_low, unsigned n_hi, int flags)
Andi Kleene412ac42007-06-20 12:23:30 +0200854{
855 return sys_sync_file_range(fd,
856 ((u64)off_hi << 32) | off_low,
857 ((u64)n_hi << 32) | n_low, flags);
858}
859
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100860asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
861 size_t len, int advice)
Andi Kleene412ac42007-06-20 12:23:30 +0200862{
863 return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
864 len, advice);
865}
Amit Arora97ac7352007-07-17 21:42:44 -0400866
867asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
868 unsigned offset_hi, unsigned len_lo,
869 unsigned len_hi)
870{
871 return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
872 ((u64)len_hi << 32) | len_lo);
873}