diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-02 14:23:14 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-02 14:23:14 -0400 |
| commit | b66e1f11ebc429569a3784aaf64123633d9e3ed1 (patch) | |
| tree | d49f96acc682aaf29416921428110da5fd78fea4 /arch | |
| parent | 1be1d6b7f3f6e3a87f872dd5e7a867d03d8a6851 (diff) | |
| parent | 5c598b3428c372a1209597cee99a70da20625876 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
[PATCH] fix sysctl_nr_open bugs
[PATCH] sanitize anon_inode_getfd()
[PATCH] split linux/file.h
[PATCH] make osf_select() use core_sys_select()
[PATCH] remove horrors with irix tty ioctls handling
[PATCH] fix file and descriptor handling in perfmon
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/alpha/kernel/osf_sys.c | 69 | ||||
| -rw-r--r-- | arch/mips/kernel/irixioctl.c | 55 | ||||
| -rw-r--r-- | arch/mips/kernel/kspd.c | 1 | ||||
| -rw-r--r-- | arch/powerpc/platforms/cell/spufs/coredump.c | 1 |
4 files changed, 15 insertions, 111 deletions
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 9fee37e2596f..32ca1b927307 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c | |||
| @@ -981,27 +981,18 @@ asmlinkage int | |||
| 981 | osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, | 981 | osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, |
| 982 | struct timeval32 __user *tvp) | 982 | struct timeval32 __user *tvp) |
| 983 | { | 983 | { |
| 984 | fd_set_bits fds; | 984 | s64 timeout = MAX_SCHEDULE_TIMEOUT; |
| 985 | char *bits; | ||
| 986 | size_t size; | ||
| 987 | long timeout; | ||
| 988 | int ret = -EINVAL; | ||
| 989 | struct fdtable *fdt; | ||
| 990 | int max_fds; | ||
| 991 | |||
| 992 | timeout = MAX_SCHEDULE_TIMEOUT; | ||
| 993 | if (tvp) { | 985 | if (tvp) { |
| 994 | time_t sec, usec; | 986 | time_t sec, usec; |
| 995 | 987 | ||
| 996 | if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp)) | 988 | if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp)) |
| 997 | || __get_user(sec, &tvp->tv_sec) | 989 | || __get_user(sec, &tvp->tv_sec) |
| 998 | || __get_user(usec, &tvp->tv_usec)) { | 990 | || __get_user(usec, &tvp->tv_usec)) { |
| 999 | ret = -EFAULT; | 991 | return -EFAULT; |
| 1000 | goto out_nofds; | ||
| 1001 | } | 992 | } |
| 1002 | 993 | ||
| 1003 | if (sec < 0 || usec < 0) | 994 | if (sec < 0 || usec < 0) |
| 1004 | goto out_nofds; | 995 | return -EINVAL; |
| 1005 | 996 | ||
| 1006 | if ((unsigned long) sec < MAX_SELECT_SECONDS) { | 997 | if ((unsigned long) sec < MAX_SELECT_SECONDS) { |
| 1007 | timeout = (usec + 1000000/HZ - 1) / (1000000/HZ); | 998 | timeout = (usec + 1000000/HZ - 1) / (1000000/HZ); |
| @@ -1009,60 +1000,8 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, | |||
| 1009 | } | 1000 | } |
| 1010 | } | 1001 | } |
| 1011 | 1002 | ||
| 1012 | rcu_read_lock(); | ||
| 1013 | fdt = files_fdtable(current->files); | ||
| 1014 | max_fds = fdt->max_fds; | ||
| 1015 | rcu_read_unlock(); | ||
| 1016 | if (n < 0 || n > max_fds) | ||
| 1017 | goto out_nofds; | ||
| 1018 | |||
| 1019 | /* | ||
| 1020 | * We need 6 bitmaps (in/out/ex for both incoming and outgoing), | ||
| 1021 | * since we used fdset we need to allocate memory in units of | ||
| 1022 | * long-words. | ||
| 1023 | */ | ||
| 1024 | ret = -ENOMEM; | ||
| 1025 | size = FDS_BYTES(n); | ||
| 1026 | bits = kmalloc(6 * size, GFP_KERNEL); | ||
| 1027 | if (!bits) | ||
| 1028 | goto out_nofds; | ||
| 1029 | fds.in = (unsigned long *) bits; | ||
| 1030 | fds.out = (unsigned long *) (bits + size); | ||
| 1031 | fds.ex = (unsigned long *) (bits + 2*size); | ||
| 1032 | fds.res_in = (unsigned long *) (bits + 3*size); | ||
| 1033 | fds.res_out = (unsigned long *) (bits + 4*size); | ||
| 1034 | fds.res_ex = (unsigned long *) (bits + 5*size); | ||
| 1035 | |||
| 1036 | if ((ret = get_fd_set(n, inp->fds_bits, fds.in)) || | ||
| 1037 | (ret = get_fd_set(n, outp->fds_bits, fds.out)) || | ||
| 1038 | (ret = get_fd_set(n, exp->fds_bits, fds.ex))) | ||
| 1039 | goto out; | ||
| 1040 | zero_fd_set(n, fds.res_in); | ||
| 1041 | zero_fd_set(n, fds.res_out); | ||
| 1042 | zero_fd_set(n, fds.res_ex); | ||
| 1043 | |||
| 1044 | ret = do_select(n, &fds, &timeout); | ||
| 1045 | |||
| 1046 | /* OSF does not copy back the remaining time. */ | 1003 | /* OSF does not copy back the remaining time. */ |
| 1047 | 1004 | return core_sys_select(n, inp, outp, exp, &timeout); | |
| 1048 | if (ret < 0) | ||
| 1049 | goto out; | ||
| 1050 | if (!ret) { | ||
| 1051 | ret = -ERESTARTNOHAND; | ||
| 1052 | if (signal_pending(current)) | ||
| 1053 | goto out; | ||
| 1054 | ret = 0; | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | if (set_fd_set(n, inp->fds_bits, fds.res_in) || | ||
| 1058 | set_fd_set(n, outp->fds_bits, fds.res_out) || | ||
| 1059 | set_fd_set(n, exp->fds_bits, fds.res_ex)) | ||
| 1060 | ret = -EFAULT; | ||
| 1061 | |||
| 1062 | out: | ||
| 1063 | kfree(bits); | ||
| 1064 | out_nofds: | ||
| 1065 | return ret; | ||
| 1066 | } | 1005 | } |
| 1067 | 1006 | ||
| 1068 | struct rusage32 { | 1007 | struct rusage32 { |
diff --git a/arch/mips/kernel/irixioctl.c b/arch/mips/kernel/irixioctl.c index 2bde200d5ad0..b39bdba82e02 100644 --- a/arch/mips/kernel/irixioctl.c +++ b/arch/mips/kernel/irixioctl.c | |||
| @@ -27,33 +27,6 @@ struct irix_termios { | |||
| 27 | cc_t c_cc[NCCS]; | 27 | cc_t c_cc[NCCS]; |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | extern void start_tty(struct tty_struct *tty); | ||
| 31 | static struct tty_struct *get_tty(int fd) | ||
| 32 | { | ||
| 33 | struct file *filp; | ||
| 34 | struct tty_struct *ttyp = NULL; | ||
| 35 | |||
| 36 | rcu_read_lock(); | ||
| 37 | filp = fcheck(fd); | ||
| 38 | if(filp && filp->private_data) { | ||
| 39 | ttyp = (struct tty_struct *) filp->private_data; | ||
| 40 | |||
| 41 | if(ttyp->magic != TTY_MAGIC) | ||
| 42 | ttyp =NULL; | ||
| 43 | } | ||
| 44 | rcu_read_unlock(); | ||
| 45 | return ttyp; | ||
| 46 | } | ||
| 47 | |||
| 48 | static struct tty_struct *get_real_tty(struct tty_struct *tp) | ||
| 49 | { | ||
| 50 | if (tp->driver->type == TTY_DRIVER_TYPE_PTY && | ||
| 51 | tp->driver->subtype == PTY_TYPE_MASTER) | ||
| 52 | return tp->link; | ||
| 53 | else | ||
| 54 | return tp; | ||
| 55 | } | ||
| 56 | |||
| 57 | asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) | 30 | asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) |
| 58 | { | 31 | { |
| 59 | struct tty_struct *tp, *rtp; | 32 | struct tty_struct *tp, *rtp; |
| @@ -146,34 +119,24 @@ asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) | |||
| 146 | error = sys_ioctl(fd, TIOCNOTTY, arg); | 119 | error = sys_ioctl(fd, TIOCNOTTY, arg); |
| 147 | break; | 120 | break; |
| 148 | 121 | ||
| 149 | case 0x00007416: | 122 | case 0x00007416: { |
| 123 | pid_t pid; | ||
| 150 | #ifdef DEBUG_IOCTLS | 124 | #ifdef DEBUG_IOCTLS |
| 151 | printk("TIOCGSID, %08lx) ", arg); | 125 | printk("TIOCGSID, %08lx) ", arg); |
| 152 | #endif | 126 | #endif |
| 153 | tp = get_tty(fd); | 127 | old_fs = get_fs(); set_fs(get_ds()); |
| 154 | if(!tp) { | 128 | error = sys_ioctl(fd, TIOCGSID, (unsigned long)&pid); |
| 155 | error = -EINVAL; | 129 | set_fs(old_fs); |
| 156 | break; | 130 | if (!error) |
| 157 | } | 131 | error = put_user(pid, (unsigned long __user *) arg); |
| 158 | rtp = get_real_tty(tp); | ||
| 159 | #ifdef DEBUG_IOCTLS | ||
| 160 | printk("rtp->session=%d ", rtp->session); | ||
| 161 | #endif | ||
| 162 | error = put_user(rtp->session, (unsigned long __user *) arg); | ||
| 163 | break; | 132 | break; |
| 164 | 133 | } | |
| 165 | case 0x746e: | 134 | case 0x746e: |
| 166 | /* TIOCSTART, same effect as hitting ^Q */ | 135 | /* TIOCSTART, same effect as hitting ^Q */ |
| 167 | #ifdef DEBUG_IOCTLS | 136 | #ifdef DEBUG_IOCTLS |
| 168 | printk("TIOCSTART, %08lx) ", arg); | 137 | printk("TIOCSTART, %08lx) ", arg); |
| 169 | #endif | 138 | #endif |
| 170 | tp = get_tty(fd); | 139 | error = sys_ioctl(fd, TCXONC, TCOON); |
| 171 | if(!tp) { | ||
| 172 | error = -EINVAL; | ||
| 173 | break; | ||
| 174 | } | ||
| 175 | rtp = get_real_tty(tp); | ||
| 176 | start_tty(rtp); | ||
| 177 | break; | 140 | break; |
| 178 | 141 | ||
| 179 | case 0x20006968: | 142 | case 0x20006968: |
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c index 998c4efcce88..ceb62dce1c9c 100644 --- a/arch/mips/kernel/kspd.c +++ b/arch/mips/kernel/kspd.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
| 21 | #include <linux/unistd.h> | 21 | #include <linux/unistd.h> |
| 22 | #include <linux/file.h> | 22 | #include <linux/file.h> |
| 23 | #include <linux/fdtable.h> | ||
| 23 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
| 24 | #include <linux/syscalls.h> | 25 | #include <linux/syscalls.h> |
| 25 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c index b962c3ab470c..af116aadba10 100644 --- a/arch/powerpc/platforms/cell/spufs/coredump.c +++ b/arch/powerpc/platforms/cell/spufs/coredump.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | #include <linux/elf.h> | 23 | #include <linux/elf.h> |
| 24 | #include <linux/file.h> | 24 | #include <linux/file.h> |
| 25 | #include <linux/fdtable.h> | ||
| 25 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
| 26 | #include <linux/list.h> | 27 | #include <linux/list.h> |
| 27 | #include <linux/module.h> | 28 | #include <linux/module.h> |
