lkml.org 
[lkml]   [2015]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] Check tcsetpgrp p is a process group.
Date
This fixes a bug where a process can set the foreground process group to its
pid even if its pid is not a valid pgrp.

Signed-off-by: Patrick Donnelly <batrick@batbytes.com>
---
drivers/tty/tty_io.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 401d05e..c20a2fb 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2560,9 +2560,11 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
{
struct pid *pgrp;
pid_t pgrp_nr;
- int retval = tty_check_change(real_tty);
+ int retval;
unsigned long flags;

+ retval = tty_check_change(real_tty);
+
if (retval == -EIO)
return -ENOTTY;
if (retval)
@@ -2580,6 +2582,10 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
retval = -ESRCH;
if (!pgrp)
goto out_unlock;
+ retval = -EINVAL;
+ if (!pid_task(pgrp, PIDTYPE_PGID)) {
+ goto out_unlock;
+ }
retval = -EPERM;
if (session_of_pgrp(pgrp) != task_session(current))
goto out_unlock;
--
Patrick Donnelly


\
 
 \ /
  Last update: 2015-06-27 23:21    [W:0.131 / U:0.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site