|
@@ -2990,7 +2990,8 @@ static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
|
|
|
|
|
|
static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
|
|
static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
|
|
{
|
|
{
|
|
- pid_t pgrp;
|
|
|
|
|
|
+ struct pid *pgrp;
|
|
|
|
+ pid_t pgrp_nr;
|
|
int retval = tty_check_change(real_tty);
|
|
int retval = tty_check_change(real_tty);
|
|
|
|
|
|
if (retval == -EIO)
|
|
if (retval == -EIO)
|
|
@@ -3001,14 +3002,23 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
|
|
(current->signal->tty != real_tty) ||
|
|
(current->signal->tty != real_tty) ||
|
|
(real_tty->session != process_session(current)))
|
|
(real_tty->session != process_session(current)))
|
|
return -ENOTTY;
|
|
return -ENOTTY;
|
|
- if (get_user(pgrp, p))
|
|
|
|
|
|
+ if (get_user(pgrp_nr, p))
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
- if (pgrp < 0)
|
|
|
|
|
|
+ if (pgrp_nr < 0)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
- if (session_of_pgrp(pgrp) != process_session(current))
|
|
|
|
- return -EPERM;
|
|
|
|
- real_tty->pgrp = pgrp;
|
|
|
|
- return 0;
|
|
|
|
|
|
+ rcu_read_lock();
|
|
|
|
+ pgrp = find_pid(pgrp_nr);
|
|
|
|
+ retval = -ESRCH;
|
|
|
|
+ if (!pgrp)
|
|
|
|
+ goto out_unlock;
|
|
|
|
+ retval = -EPERM;
|
|
|
|
+ if (session_of_pgrp(pgrp) != task_session(current))
|
|
|
|
+ goto out_unlock;
|
|
|
|
+ retval = 0;
|
|
|
|
+ real_tty->pgrp = pgrp_nr;
|
|
|
|
+out_unlock:
|
|
|
|
+ rcu_read_unlock();
|
|
|
|
+ return retval;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|