Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b66e1f11 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* '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
parents 1be1d6b7 5c598b34
Loading
Loading
Loading
Loading
+4 −65
Original line number Diff line number Diff line
@@ -981,27 +981,18 @@ asmlinkage int
osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp,
	   struct timeval32 __user *tvp)
{
	fd_set_bits fds;
	char *bits;
	size_t size;
	long timeout;
	int ret = -EINVAL;
	struct fdtable *fdt;
	int max_fds;

	timeout = MAX_SCHEDULE_TIMEOUT;
	s64 timeout = MAX_SCHEDULE_TIMEOUT;
	if (tvp) {
		time_t sec, usec;

		if (!access_ok(VERIFY_READ, tvp, sizeof(*tvp))
		    || __get_user(sec, &tvp->tv_sec)
		    || __get_user(usec, &tvp->tv_usec)) {
		    	ret = -EFAULT;
			goto out_nofds;
		    	return -EFAULT;
		}

		if (sec < 0 || usec < 0)
			goto out_nofds;
			return -EINVAL;

		if ((unsigned long) sec < MAX_SELECT_SECONDS) {
			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,
		}
	}

	rcu_read_lock();
	fdt = files_fdtable(current->files);
	max_fds = fdt->max_fds;
	rcu_read_unlock();
	if (n < 0 || n > max_fds)
		goto out_nofds;

	/*
	 * We need 6 bitmaps (in/out/ex for both incoming and outgoing),
	 * since we used fdset we need to allocate memory in units of
	 * long-words. 
	 */
	ret = -ENOMEM;
	size = FDS_BYTES(n);
	bits = kmalloc(6 * size, GFP_KERNEL);
	if (!bits)
		goto out_nofds;
	fds.in      = (unsigned long *)  bits;
	fds.out     = (unsigned long *) (bits +   size);
	fds.ex      = (unsigned long *) (bits + 2*size);
	fds.res_in  = (unsigned long *) (bits + 3*size);
	fds.res_out = (unsigned long *) (bits + 4*size);
	fds.res_ex  = (unsigned long *) (bits + 5*size);

	if ((ret = get_fd_set(n, inp->fds_bits, fds.in)) ||
	    (ret = get_fd_set(n, outp->fds_bits, fds.out)) ||
	    (ret = get_fd_set(n, exp->fds_bits, fds.ex)))
		goto out;
	zero_fd_set(n, fds.res_in);
	zero_fd_set(n, fds.res_out);
	zero_fd_set(n, fds.res_ex);

	ret = do_select(n, &fds, &timeout);

	/* OSF does not copy back the remaining time.  */

	if (ret < 0)
		goto out;
	if (!ret) {
		ret = -ERESTARTNOHAND;
		if (signal_pending(current))
			goto out;
		ret = 0;
	}

	if (set_fd_set(n, inp->fds_bits, fds.res_in) ||
	    set_fd_set(n, outp->fds_bits, fds.res_out) ||
	    set_fd_set(n, exp->fds_bits, fds.res_ex))
		ret = -EFAULT;

 out:
	kfree(bits);
 out_nofds:
	return ret;
	return core_sys_select(n, inp, outp, exp, &timeout);
}

struct rusage32 {
+9 −46
Original line number Diff line number Diff line
@@ -27,33 +27,6 @@ struct irix_termios {
	cc_t c_cc[NCCS];
};

extern void start_tty(struct tty_struct *tty);
static struct tty_struct *get_tty(int fd)
{
	struct file *filp;
	struct tty_struct *ttyp = NULL;

	rcu_read_lock();
	filp = fcheck(fd);
	if(filp && filp->private_data) {
		ttyp = (struct tty_struct *) filp->private_data;

		if(ttyp->magic != TTY_MAGIC)
			ttyp =NULL;
	}
	rcu_read_unlock();
	return ttyp;
}

static struct tty_struct *get_real_tty(struct tty_struct *tp)
{
	if (tp->driver->type == TTY_DRIVER_TYPE_PTY &&
	   tp->driver->subtype == PTY_TYPE_MASTER)
		return tp->link;
	else
		return tp;
}

asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg)
{
	struct tty_struct *tp, *rtp;
@@ -146,34 +119,24 @@ asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg)
		error = sys_ioctl(fd, TIOCNOTTY, arg);
		break;

	case 0x00007416:
	case 0x00007416: {
		pid_t pid;
#ifdef DEBUG_IOCTLS
		printk("TIOCGSID, %08lx) ", arg);
#endif
		tp = get_tty(fd);
		if(!tp) {
			error = -EINVAL;
		old_fs = get_fs(); set_fs(get_ds());
		error = sys_ioctl(fd, TIOCGSID, (unsigned long)&pid);
		set_fs(old_fs);
		if (!error)
			error = put_user(pid, (unsigned long __user *) arg);
		break;
	}
		rtp = get_real_tty(tp);
#ifdef DEBUG_IOCTLS
		printk("rtp->session=%d ", rtp->session);
#endif
		error = put_user(rtp->session, (unsigned long __user *) arg);
		break;

	case 0x746e:
		/* TIOCSTART, same effect as hitting ^Q */
#ifdef DEBUG_IOCTLS
		printk("TIOCSTART, %08lx) ", arg);
#endif
		tp = get_tty(fd);
		if(!tp) {
			error = -EINVAL;
			break;
		}
		rtp = get_real_tty(tp);
		start_tty(rtp);
		error = sys_ioctl(fd, TCXONC, TCOON);
		break;

	case 0x20006968:
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/sched.h>
#include <linux/unistd.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/fs.h>
#include <linux/syscalls.h>
#include <linux/workqueue.h>
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <linux/elf.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/fs.h>
#include <linux/list.h>
#include <linux/module.h>
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@

#include <linux/audit.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/tty.h>

struct tty_audit_buf {
Loading