From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Catalin Marinas" <catalin.marinas@gmail.com>
Subject: [PATCH 4/4] tty: In tiocsctty when we steal a tty hang it up.
Date: Sun, 18 Mar 2007 13:13:37 -0600 [thread overview]
Message-ID: <m17itejrfi.fsf_-_@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <m1bqiqjrnx.fsf_-_@ebiederm.dsl.xmission.com> (Eric W. Biederman's message of "Sun, 18 Mar 2007 13:08:34 -0600")
The linux implementation of TIOCSCTTY includes an extention
that provides for making a tty that is already the controlling
tty of another session our controlling tty. To do this it must
steal the tty away from the previous group that used it as a
controlling tty.
The way we are currently stealing the controlling tty away is
weird. In general there is a well defined process for loosing
the controlling tty. TTY hangup processing. However the linux
extension that steals the tty from another process group does
not invoke that. And instead just forgets the controlling
tty of the processes that were part of the session.
I can not imagine how our current behaviour of stealling a tty
is correct or how a set of processes could deal with it reasonably.
So this patch modifies the tty stealing to call tty_vhangup
so we get full hanup processing when we steal a tty.
I did a quick survey of user space the only application I found using
this extended behaviour is sysvinit. I perform a limited amount of
testing and nothing appears to have broken with this change. And I
did see sysvinit pass through this piece of code.
In terms of the tty leaks that started this patch series this fix
should remove the last path into proc_clear_tty that has a session
or a process group.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
drivers/char/tty_io.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 0843fcb..0f5a781 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2982,9 +2982,7 @@ static int tiocsctty(struct tty_struct *tty, int arg)
/*
* Steal it away
*/
- read_lock(&tasklist_lock);
- session_clear_tty(tty->session);
- read_unlock(&tasklist_lock);
+ tty_vhangup(tty);
} else {
ret = -EPERM;
goto unlock;
--
1.5.0.g53756
next prev parent reply other threads:[~2007-03-18 19:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-08 17:27 Possible "struct pid" leak from tty_io.c Catalin Marinas
2007-03-08 18:11 ` Eric W. Biederman
2007-03-09 10:53 ` Catalin Marinas
2007-03-09 16:13 ` Eric W. Biederman
2007-03-09 16:53 ` Catalin Marinas
2007-03-09 16:44 ` Catalin Marinas
2007-03-09 17:09 ` Eric W. Biederman
2007-03-12 15:07 ` Catalin Marinas
2007-03-12 16:12 ` Eric W. Biederman
2007-03-13 19:31 ` Eric W. Biederman
2007-03-14 9:59 ` Catalin Marinas
2007-03-14 14:40 ` Eric W. Biederman
2007-03-14 17:08 ` Catalin Marinas
2007-03-15 19:15 ` Eric W. Biederman
2007-03-16 22:01 ` Eric W. Biederman
2007-03-16 22:44 ` Catalin Marinas
2007-03-18 18:45 ` [PATCH] tty: Fix two reported pid leaks Eric W. Biederman
2007-03-18 18:52 ` [PATCH 0/4] tty: small fixes and cleanups Eric W. Biederman
2007-03-18 18:57 ` [PATCH 1/4] tty: Remove unnecessary export of proc_clear_tty Eric W. Biederman
2007-03-18 19:03 ` [PATCH 2/4] tty: Simplify calling of put_pid Eric W. Biederman
2007-03-18 19:08 ` [PATCH 3/4] tty: Introduce no_tty and use it in selinux Eric W. Biederman
2007-03-18 19:13 ` Eric W. Biederman [this message]
2007-03-18 20:55 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m17itejrfi.fsf_-_@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®