aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_io.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-04-30 03:53:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 11:29:40 -0400
commit5d0fdf1e01899805b6c2c0b789a707dcb731b1ea (patch)
tree19827c7b3cf365c0b403741ead6c7bc317cad51b /drivers/char/tty_io.c
parent575537b3248ee9b7578a3bb3df33fcdda2bfc4d5 (diff)
tty_io: fix remaining pid struct locking
This fixes the last couple of pid struct locking failures I know about. [oleg@tv-sign.ru: clean up do_task_stat()] Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r--drivers/char/tty_io.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index c8aa318eaa18..2460c4c76161 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3174,6 +3174,27 @@ unlock:
3174} 3174}
3175 3175
3176/** 3176/**
3177 * tty_get_pgrp - return a ref counted pgrp pid
3178 * @tty: tty to read
3179 *
3180 * Returns a refcounted instance of the pid struct for the process
3181 * group controlling the tty.
3182 */
3183
3184struct pid *tty_get_pgrp(struct tty_struct *tty)
3185{
3186 unsigned long flags;
3187 struct pid *pgrp;
3188
3189 spin_lock_irqsave(&tty->ctrl_lock, flags);
3190 pgrp = get_pid(tty->pgrp);
3191 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
3192
3193 return pgrp;
3194}
3195EXPORT_SYMBOL_GPL(tty_get_pgrp);
3196
3197/**
3177 * tiocgpgrp - get process group 3198 * tiocgpgrp - get process group
3178 * @tty: tty passed by user 3199 * @tty: tty passed by user
3179 * @real_tty: tty side of the tty pased by the user if a pty else the tty 3200 * @real_tty: tty side of the tty pased by the user if a pty else the tty
@@ -3187,13 +3208,18 @@ unlock:
3187 3208
3188static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) 3209static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
3189{ 3210{
3211 struct pid *pid;
3212 int ret;
3190 /* 3213 /*
3191 * (tty == real_tty) is a cheap way of 3214 * (tty == real_tty) is a cheap way of
3192 * testing if the tty is NOT a master pty. 3215 * testing if the tty is NOT a master pty.
3193 */ 3216 */
3194 if (tty == real_tty && current->signal->tty != real_tty) 3217 if (tty == real_tty && current->signal->tty != real_tty)
3195 return -ENOTTY; 3218 return -ENOTTY;
3196 return put_user(pid_vnr(real_tty->pgrp), p); 3219 pid = tty_get_pgrp(real_tty);
3220 ret = put_user(pid_vnr(pid), p);
3221 put_pid(pid);
3222 return ret;
3197} 3223}
3198 3224
3199/** 3225/**