2007-07-18 21:28:59 +00:00
|
|
|
/* sys_sparc32.c: Conversion between 32bit and 64bit native syscalls.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
2007-07-18 21:28:59 +00:00
|
|
|
* Copyright (C) 1997, 2007 David S. Miller (davem@davemloft.net)
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* These routines maintain argument size conversion between 32bit and 64bit
|
|
|
|
* environment.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
2006-01-11 20:17:48 +00:00
|
|
|
#include <linux/capability.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/resource.h>
|
|
|
|
#include <linux/times.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/sem.h>
|
|
|
|
#include <linux/msg.h>
|
|
|
|
#include <linux/shm.h>
|
|
|
|
#include <linux/uio.h>
|
|
|
|
#include <linux/nfs_fs.h>
|
|
|
|
#include <linux/quota.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/personality.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/filter.h>
|
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/highuid.h>
|
|
|
|
#include <linux/mman.h>
|
|
|
|
#include <linux/ipv6.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/icmpv6.h>
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/sysctl.h>
|
|
|
|
#include <linux/binfmts.h>
|
|
|
|
#include <linux/dnotify.h>
|
|
|
|
#include <linux/security.h>
|
|
|
|
#include <linux/compat.h>
|
|
|
|
#include <linux/vfs.h>
|
|
|
|
#include <linux/ptrace.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/types.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/fpumacro.h>
|
|
|
|
#include <asm/mmu_context.h>
|
2006-10-02 21:17:57 +00:00
|
|
|
#include <asm/compat_signal.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, unsigned long low)
|
|
|
|
{
|
|
|
|
if ((int)high < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
return sys_truncate(path, (high << 32) | low);
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low)
|
|
|
|
{
|
|
|
|
if ((int)high < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
return sys_ftruncate(fd, (high << 32) | low);
|
|
|
|
}
|
|
|
|
|
2008-06-05 18:42:40 +00:00
|
|
|
static int cp_compat_stat64(struct kstat *stat,
|
|
|
|
struct compat_stat64 __user *statbuf)
|
2005-04-18 22:13:15 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = put_user(huge_encode_dev(stat->dev), &statbuf->st_dev);
|
|
|
|
err |= put_user(stat->ino, &statbuf->st_ino);
|
|
|
|
err |= put_user(stat->mode, &statbuf->st_mode);
|
|
|
|
err |= put_user(stat->nlink, &statbuf->st_nlink);
|
2012-02-09 17:10:30 +00:00
|
|
|
err |= put_user(from_kuid_munged(current_user_ns(), stat->uid), &statbuf->st_uid);
|
|
|
|
err |= put_user(from_kgid_munged(current_user_ns(), stat->gid), &statbuf->st_gid);
|
2005-04-18 22:13:15 +00:00
|
|
|
err |= put_user(huge_encode_dev(stat->rdev), &statbuf->st_rdev);
|
|
|
|
err |= put_user(0, (unsigned long __user *) &statbuf->__pad3[0]);
|
|
|
|
err |= put_user(stat->size, &statbuf->st_size);
|
|
|
|
err |= put_user(stat->blksize, &statbuf->st_blksize);
|
|
|
|
err |= put_user(0, (unsigned int __user *) &statbuf->__pad4[0]);
|
|
|
|
err |= put_user(0, (unsigned int __user *) &statbuf->__pad4[4]);
|
|
|
|
err |= put_user(stat->blocks, &statbuf->st_blocks);
|
|
|
|
err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
|
|
|
|
err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
|
|
|
|
err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
|
|
|
|
err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
|
|
|
|
err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
|
|
|
|
err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
|
|
|
|
err |= put_user(0, &statbuf->__unused4);
|
|
|
|
err |= put_user(0, &statbuf->__unused5);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-08-11 10:26:22 +00:00
|
|
|
asmlinkage long compat_sys_stat64(const char __user * filename,
|
2005-04-18 22:13:15 +00:00
|
|
|
struct compat_stat64 __user *statbuf)
|
|
|
|
{
|
|
|
|
struct kstat stat;
|
|
|
|
int error = vfs_stat(filename, &stat);
|
|
|
|
|
|
|
|
if (!error)
|
|
|
|
error = cp_compat_stat64(&stat, statbuf);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-08-11 10:26:22 +00:00
|
|
|
asmlinkage long compat_sys_lstat64(const char __user * filename,
|
2005-04-18 22:13:15 +00:00
|
|
|
struct compat_stat64 __user *statbuf)
|
|
|
|
{
|
|
|
|
struct kstat stat;
|
|
|
|
int error = vfs_lstat(filename, &stat);
|
|
|
|
|
|
|
|
if (!error)
|
|
|
|
error = cp_compat_stat64(&stat, statbuf);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage long compat_sys_fstat64(unsigned int fd,
|
|
|
|
struct compat_stat64 __user * statbuf)
|
|
|
|
{
|
|
|
|
struct kstat stat;
|
|
|
|
int error = vfs_fstat(fd, &stat);
|
|
|
|
|
|
|
|
if (!error)
|
|
|
|
error = cp_compat_stat64(&stat, statbuf);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-08-11 10:26:22 +00:00
|
|
|
asmlinkage long compat_sys_fstatat64(unsigned int dfd,
|
|
|
|
const char __user *filename,
|
2006-02-13 07:30:11 +00:00
|
|
|
struct compat_stat64 __user * statbuf, int flag)
|
|
|
|
{
|
|
|
|
struct kstat stat;
|
2009-04-08 16:05:42 +00:00
|
|
|
int error;
|
2006-02-13 07:30:11 +00:00
|
|
|
|
2009-04-08 16:05:42 +00:00
|
|
|
error = vfs_fstatat(dfd, filename, &stat, flag);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
return cp_compat_stat64(&stat, statbuf);
|
2006-02-13 07:30:11 +00:00
|
|
|
}
|
|
|
|
|
2012-12-26 00:18:40 +00:00
|
|
|
COMPAT_SYSCALL_DEFINE3(sparc_sigaction, int, sig,
|
|
|
|
struct compat_old_sigaction __user *,act,
|
|
|
|
struct compat_old_sigaction __user *,oact)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-04-27 09:26:36 +00:00
|
|
|
WARN_ON_ONCE(sig >= 0);
|
2012-12-26 00:18:40 +00:00
|
|
|
return compat_sys_sigaction(-sig, act, oact);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-25 23:45:43 +00:00
|
|
|
COMPAT_SYSCALL_DEFINE5(rt_sigaction, int, sig,
|
|
|
|
struct compat_sigaction __user *,act,
|
|
|
|
struct compat_sigaction __user *,oact,
|
|
|
|
void __user *,restorer,
|
|
|
|
compat_size_t,sigsetsize)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct k_sigaction new_ka, old_ka;
|
|
|
|
int ret;
|
|
|
|
compat_sigset_t set32;
|
|
|
|
|
|
|
|
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
|
|
if (sigsetsize != sizeof(compat_sigset_t))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (act) {
|
|
|
|
u32 u_handler, u_restorer;
|
|
|
|
|
|
|
|
new_ka.ka_restorer = restorer;
|
|
|
|
ret = get_user(u_handler, &act->sa_handler);
|
|
|
|
new_ka.sa.sa_handler = compat_ptr(u_handler);
|
|
|
|
ret |= __copy_from_user(&set32, &act->sa_mask, sizeof(compat_sigset_t));
|
2012-12-25 23:45:43 +00:00
|
|
|
sigset_from_compat(&new_ka.sa.sa_mask, &set32);
|
2005-04-16 22:20:36 +00:00
|
|
|
ret |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
|
|
|
|
ret |= __get_user(u_restorer, &act->sa_restorer);
|
|
|
|
new_ka.sa.sa_restorer = compat_ptr(u_restorer);
|
|
|
|
if (ret)
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
|
|
|
|
|
|
|
|
if (!ret && oact) {
|
2012-12-25 23:45:43 +00:00
|
|
|
sigset_to_compat(&set32, &old_ka.sa.sa_mask);
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler);
|
|
|
|
ret |= __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t));
|
|
|
|
ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
|
|
|
|
ret |= __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer);
|
|
|
|
if (ret)
|
|
|
|
ret = -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage compat_ssize_t sys32_pread64(unsigned int fd,
|
|
|
|
char __user *ubuf,
|
|
|
|
compat_size_t count,
|
|
|
|
unsigned long poshi,
|
|
|
|
unsigned long poslo)
|
|
|
|
{
|
|
|
|
return sys_pread64(fd, ubuf, count, (poshi << 32) | poslo);
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage compat_ssize_t sys32_pwrite64(unsigned int fd,
|
|
|
|
char __user *ubuf,
|
|
|
|
compat_size_t count,
|
|
|
|
unsigned long poshi,
|
|
|
|
unsigned long poslo)
|
|
|
|
{
|
|
|
|
return sys_pwrite64(fd, ubuf, count, (poshi << 32) | poslo);
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage long compat_sys_readahead(int fd,
|
|
|
|
unsigned long offhi,
|
|
|
|
unsigned long offlo,
|
|
|
|
compat_size_t count)
|
|
|
|
{
|
|
|
|
return sys_readahead(fd, (offhi << 32) | offlo, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
long compat_sys_fadvise64(int fd,
|
|
|
|
unsigned long offhi,
|
|
|
|
unsigned long offlo,
|
|
|
|
compat_size_t len, int advice)
|
|
|
|
{
|
|
|
|
return sys_fadvise64_64(fd, (offhi << 32) | offlo, len, advice);
|
|
|
|
}
|
|
|
|
|
|
|
|
long compat_sys_fadvise64_64(int fd,
|
|
|
|
unsigned long offhi, unsigned long offlo,
|
|
|
|
unsigned long lenhi, unsigned long lenlo,
|
|
|
|
int advice)
|
|
|
|
{
|
|
|
|
return sys_fadvise64_64(fd,
|
|
|
|
(offhi << 32) | offlo,
|
|
|
|
(lenhi << 32) | lenlo,
|
|
|
|
advice);
|
|
|
|
}
|
|
|
|
|
2013-03-02 15:38:22 +00:00
|
|
|
long sys32_sync_file_range(unsigned int fd, unsigned long off_high, unsigned long off_low, unsigned long nb_high, unsigned long nb_low, unsigned int flags)
|
2006-04-01 07:49:34 +00:00
|
|
|
{
|
|
|
|
return sys_sync_file_range(fd,
|
|
|
|
(off_high << 32) | off_low,
|
|
|
|
(nb_high << 32) | nb_low,
|
|
|
|
flags);
|
|
|
|
}
|
2007-07-18 21:28:59 +00:00
|
|
|
|
|
|
|
asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
|
|
|
|
u32 lenhi, u32 lenlo)
|
|
|
|
{
|
|
|
|
return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
|
|
|
|
((loff_t)lenhi << 32) | lenlo);
|
|
|
|
}
|