Skip to content

Commit

Permalink
Add generic sys_old_select()
Browse files Browse the repository at this point in the history
Add a generic implementation of the old select() syscall, which expects
its argument in a memory block and switch all architectures over to use
it.

Signed-off-by: Christoph Hellwig <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Reviewed-by: H. Peter Anvin <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: "Luck, Tony" <[email protected]>
Cc: James Morris <[email protected]>
Acked-by: Andreas Schwab <[email protected]>
Acked-by: Russell King <[email protected]>
Acked-by: Greg Ungerer <[email protected]>
Acked-by: David Howells <[email protected]>
Cc: Andreas Schwab <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Hellwig authored and torvalds committed Mar 12, 2010
1 parent 724ee62 commit 5d0e528
Show file tree
Hide file tree
Showing 27 changed files with 52 additions and 152 deletions.
1 change: 1 addition & 0 deletions arch/arm/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
#define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_RT_SIGACTION
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
#define __ARCH_WANT_SYS_OLD_SELECT

#if !defined(CONFIG_AEABI) || defined(CONFIG_OABI_COMPAT)
#define __ARCH_WANT_SYS_TIME
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/calls.S
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
CALL(sys_settimeofday)
/* 80 */ CALL(sys_getgroups16)
CALL(sys_setgroups16)
CALL(OBSOLETE(old_select)) /* used by libc4 */
CALL(OBSOLETE(sys_old_select)) /* used by libc4 */
CALL(sys_symlink)
CALL(sys_ni_syscall) /* was sys_lstat */
/* 85 */ CALL(sys_readlink)
Expand Down
21 changes: 0 additions & 21 deletions arch/arm/kernel/sys_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,6 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
return error;
}

/*
* Perform the select(nd, in, out, ex, tv) and mmap() system
* calls.
*/

struct sel_arg_struct {
unsigned long n;
fd_set __user *inp, *outp, *exp;
struct timeval __user *tvp;
};

asmlinkage int old_select(struct sel_arg_struct __user *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
/* sys_select() does the appropriate kernel locking */
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}

#if !defined(CONFIG_AEABI) || defined(CONFIG_OABI_COMPAT)
/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
Expand Down
1 change: 1 addition & 0 deletions arch/h8300/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
16 changes: 0 additions & 16 deletions arch/h8300/kernel/sys_h8300.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,6 @@ asmlinkage int old_mmap(struct mmap_arg_struct *arg)
return error;
}

struct sel_arg_struct {
unsigned long n;
fd_set *inp, *outp, *exp;
struct timeval *tvp;
};

asmlinkage int old_select(struct sel_arg_struct *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
/* sys_select() does the appropriate kernel locking */
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
2 changes: 1 addition & 1 deletion arch/h8300/kernel/syscalls.S
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ SYMBOL_NAME_LABEL(sys_call_table)
.long SYMBOL_NAME(sys_settimeofday)
.long SYMBOL_NAME(sys_getgroups16) /* 80 */
.long SYMBOL_NAME(sys_setgroups16)
.long SYMBOL_NAME(old_select)
.long SYMBOL_NAME(sys_old_select)
.long SYMBOL_NAME(sys_symlink)
.long SYMBOL_NAME(sys_lstat)
.long SYMBOL_NAME(sys_readlink) /* 85 */
Expand Down
1 change: 1 addition & 0 deletions arch/m68k/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ sys_call_table:
.long sys_settimeofday
.long sys_getgroups16 /* 80 */
.long sys_setgroups16
.long old_select
.long sys_old_select
.long sys_symlink
.long sys_lstat
.long sys_readlink /* 85 */
Expand Down
16 changes: 0 additions & 16 deletions arch/m68k/kernel/sys_m68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,6 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
return error;
}

struct sel_arg_struct {
unsigned long n;
fd_set __user *inp, *outp, *exp;
struct timeval __user *tvp;
};

asmlinkage int old_select(struct sel_arg_struct __user *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
/* sys_select() does the appropriate kernel locking */
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
16 changes: 0 additions & 16 deletions arch/m68knommu/kernel/sys_m68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,6 @@ asmlinkage int old_mmap(struct mmap_arg_struct *arg)
return error;
}

struct sel_arg_struct {
unsigned long n;
fd_set *inp, *outp, *exp;
struct timeval *tvp;
};

asmlinkage int old_select(struct sel_arg_struct *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
/* sys_select() does the appropriate kernel locking */
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
2 changes: 1 addition & 1 deletion arch/m68knommu/kernel/syscalltable.S
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ENTRY(sys_call_table)
.long sys_settimeofday
.long sys_getgroups16 /* 80 */
.long sys_setgroups16
.long old_select
.long sys_old_select
.long sys_symlink
.long sys_lstat
.long sys_readlink /* 85 */
Expand Down
1 change: 1 addition & 0 deletions arch/mn10300/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
2 changes: 1 addition & 1 deletion arch/mn10300/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ ENTRY(sys_call_table)
.long sys_settimeofday
.long sys_getgroups16 /* 80 */
.long sys_setgroups16
.long old_select
.long sys_old_select
.long sys_symlink
.long sys_lstat
.long sys_readlink /* 85 */
Expand Down
18 changes: 0 additions & 18 deletions arch/mn10300/kernel/sys_mn10300.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ asmlinkage long old_mmap(unsigned long addr, unsigned long len,
return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
}

struct sel_arg_struct {
unsigned long n;
fd_set *inp;
fd_set *outp;
fd_set *exp;
struct timeval *tvp;
};

asmlinkage int old_select(struct sel_arg_struct __user *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
/* sys_select() does the appropriate kernel locking */
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
1 change: 0 additions & 1 deletion arch/s390/kernel/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct new_utsname;
struct mmap_arg_struct;
struct fadvise64_64_args;
struct old_sigaction;
struct sel_arg_struct;

long sys_mmap2(struct mmap_arg_struct __user *arg);
long sys_s390_old_mmap(struct mmap_arg_struct __user *arg);
Expand Down
18 changes: 0 additions & 18 deletions arch/um/sys-i386/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ long old_mmap_i386(struct mmap_arg_struct __user *arg)
return err;
}

struct sel_arg_struct {
unsigned long n;
fd_set __user *inp;
fd_set __user *outp;
fd_set __user *exp;
struct timeval __user *tvp;
};

long old_select(struct sel_arg_struct __user *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
/* sys_select() does the appropriate kernel locking */
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}

/*
* The prototype on i386 is:
*
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/ia32/ia32entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ ia32_sys_call_table:
.quad compat_sys_settimeofday
.quad sys_getgroups16 /* 80 */
.quad sys_setgroups16
.quad sys32_old_select
.quad compat_sys_old_select
.quad sys_symlink
.quad sys_lstat
.quad sys_readlink /* 85 */
Expand Down
18 changes: 0 additions & 18 deletions arch/x86/ia32/sys_ia32.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,24 +332,6 @@ asmlinkage long sys32_alarm(unsigned int seconds)
return alarm_setitimer(seconds);
}

struct sel_arg_struct {
unsigned int n;
unsigned int inp;
unsigned int outp;
unsigned int exp;
unsigned int tvp;
};

asmlinkage long sys32_old_select(struct sel_arg_struct __user *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
compat_ptr(a.exp), compat_ptr(a.tvp));
}

asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr,
int options)
{
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/include/asm/sys_ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ asmlinkage long sys32_rt_sigprocmask(int, compat_sigset_t __user *,
compat_sigset_t __user *, unsigned int);
asmlinkage long sys32_alarm(unsigned int);

struct sel_arg_struct;
asmlinkage long sys32_old_select(struct sel_arg_struct __user *);
asmlinkage long sys32_waitpid(compat_pid_t, unsigned int *, int);
asmlinkage long sys32_sysfs(int, u32, u32);

Expand Down
2 changes: 0 additions & 2 deletions arch/x86/include/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ unsigned long sys_sigreturn(struct pt_regs *);

/* kernel/sys_i386_32.c */
struct mmap_arg_struct;
struct sel_arg_struct;
struct oldold_utsname;
struct old_utsname;

asmlinkage int old_mmap(struct mmap_arg_struct __user *);
asmlinkage int old_select(struct sel_arg_struct __user *);
asmlinkage int sys_ipc(uint, int, int, int, void __user *, long);
asmlinkage int sys_uname(struct old_utsname __user *);
asmlinkage int sys_olduname(struct oldold_utsname __user *);
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/unistd_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
#define __ARCH_WANT_SYS_LLSEEK
#define __ARCH_WANT_SYS_NICE
#define __ARCH_WANT_SYS_OLD_GETRLIMIT
#define __ARCH_WANT_SYS_OLD_SELECT
#define __ARCH_WANT_SYS_OLDUMOUNT
#define __ARCH_WANT_SYS_SIGPENDING
#define __ARCH_WANT_SYS_SIGPROCMASK
Expand Down
17 changes: 0 additions & 17 deletions arch/x86/kernel/sys_i386_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,6 @@ asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
return err;
}


struct sel_arg_struct {
unsigned long n;
fd_set __user *inp, *outp, *exp;
struct timeval __user *tvp;
};

asmlinkage int old_select(struct sel_arg_struct __user *arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
/* sys_select() does the appropriate kernel locking */
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}

/*
* sys_ipc() is the de-multiplexer for the SysV IPC calls..
*
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/syscall_table_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ENTRY(sys_call_table)
.long sys_settimeofday
.long sys_getgroups16 /* 80 */
.long sys_setgroups16
.long old_select
.long sys_old_select
.long sys_symlink
.long sys_lstat
.long sys_readlink /* 85 */
Expand Down
18 changes: 18 additions & 0 deletions fs/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,24 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
return ret;
}

struct compat_sel_arg_struct {
compat_ulong_t n;
compat_uptr_t inp;
compat_uptr_t outp;
compat_uptr_t exp;
compat_uptr_t tvp;
};

asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg)
{
struct compat_sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
compat_ptr(a.exp), compat_ptr(a.tvp));
}

#ifdef HAVE_SET_RESTORE_SIGMASK
static long do_compat_pselect(int n, compat_ulong_t __user *inp,
compat_ulong_t __user *outp, compat_ulong_t __user *exp,
Expand Down
17 changes: 17 additions & 0 deletions fs/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,23 @@ SYSCALL_DEFINE6(pselect6, int, n, fd_set __user *, inp, fd_set __user *, outp,
}
#endif /* HAVE_SET_RESTORE_SIGMASK */

#ifdef __ARCH_WANT_SYS_OLD_SELECT
struct sel_arg_struct {
unsigned long n;
fd_set __user *inp, *outp, *exp;
struct timeval __user *tvp;
};

SYSCALL_DEFINE1(old_select, struct sel_arg_struct __user *, arg)
{
struct sel_arg_struct a;

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}
#endif

struct poll_list {
struct poll_list *next;
int len;
Expand Down
3 changes: 3 additions & 0 deletions include/linux/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
typedef __compat_uid32_t compat_uid_t;
typedef __compat_gid32_t compat_gid_t;

struct compat_sel_arg_struct;
struct rusage;

struct compat_itimerspec {
Expand Down Expand Up @@ -249,6 +250,8 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
compat_ulong_t __user *outp, compat_ulong_t __user *exp,
struct compat_timeval __user *tvp);

asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);

asmlinkage long compat_sys_wait4(compat_pid_t pid,
compat_uint_t __user *stat_addr, int options,
struct compat_rusage __user *ru);
Expand Down
Loading

0 comments on commit 5d0e528

Please sign in to comment.