From: Peter Hurley <peter@hurleysoftware.com>
To: "Herton R. Krzesinski" <herton@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>
Subject: Re: [PATCH] pty: fix use after free of tty->driver_data
Date: Thu, 7 Jan 2016 14:36:04 -0800 [thread overview]
Message-ID: <568EE854.20608@hurleysoftware.com> (raw)
In-Reply-To: <20151229175853.GA17652@dhcppc10.redhat.com>
On 12/29/2015 09:58 AM, Herton R. Krzesinski wrote:
> On Tue, Dec 15, 2015 at 04:05:09PM -0200, Herton R. Krzesinski wrote:
>> On Tue, Dec 15, 2015 at 09:36:26AM -0800, Peter Hurley wrote:
>>>> since in this
>>>> case any of the tty->driver_data can be stale, due to all references/
>>>> files being closed before (files related to ptmx/pts inodes set at
>>>> tty->driver_data), we have the possibility of referencing an already
>>>> freed inode.
>>>
>>> As I wrote above, I believe this is the only possible circumstance
>>> for which the file that is releasing could have stale pts inodes.
>>>
>>>
>>>> The fix here is to keep a reference on the opened master ptmx inode.
>>>> We maintain the inode referenced until the final pty_unix98_shutdown,
>>>> and only pass this inode to devpts_kill_index.
>>>
>>> Let me think some on your proposed solution.
>>
>> Ok, let me know what you think, at least I will have to repost the patch
>> with the changelog fixed, unless you think there is another/better solution
>> for the issue.
>
> Hi Peter, any news on this issue?
Sorry, I haven't forgotten this issue; just busy with the holidays, etc.
> I gave some more thought and testing into this, and I think we simply should do
> a change like below instead of my previous patch proposal:
Regarding the patch below, the slave side hasn't been hung up yet
(so could be in the middle of i/o at the time the index is released).
afaict, there is nothing wrong with your original solution, strictly
speaking. What I was wondering at the time is if we would be better off
in the long run teaching the pty driver about multi-instance devpts.
But after giving it some thought, I think those changes can wait until
a solution exists (or is part of the solution) for broken userspace
devpts setups.
IOW, please re-submit your earlier patch with the changelog edits.
Regards,
Peter Hurley
> diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
> index a45660f..73e36bd 100644
> --- a/drivers/tty/pty.c
> +++ b/drivers/tty/pty.c
> @@ -68,6 +68,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
> mutex_lock(&devpts_mutex);
> if (tty->link->driver_data)
> devpts_pty_kill(tty->link->driver_data);
> + devpts_kill_index(tty->driver_data, tty->index);
> mutex_unlock(&devpts_mutex);
> }
> #endif
> @@ -678,12 +679,6 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
> {
> }
>
> -/* this is called once with whichever end is closed last */
> -static void pty_unix98_shutdown(struct tty_struct *tty)
> -{
> - devpts_kill_index(tty->driver_data, tty->index);
> -}
> -
> static const struct tty_operations ptm_unix98_ops = {
> .lookup = ptm_unix98_lookup,
> .install = pty_unix98_install,
> @@ -697,7 +692,6 @@ static const struct tty_operations ptm_unix98_ops = {
> .unthrottle = pty_unthrottle,
> .ioctl = pty_unix98_ioctl,
> .resize = pty_resize,
> - .shutdown = pty_unix98_shutdown,
> .cleanup = pty_cleanup
> };
>
> @@ -715,7 +709,6 @@ static const struct tty_operations pty_unix98_ops = {
> .set_termios = pty_set_termios,
> .start = pty_start,
> .stop = pty_stop,
> - .shutdown = pty_unix98_shutdown,
> .cleanup = pty_cleanup,
> };
>
>
next prev parent reply other threads:[~2016-01-07 22:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-15 3:29 pty: fix use after free/oops at pty_unix98_shutdown Herton R. Krzesinski
2015-12-15 3:29 ` [PATCH] pty: fix use after free of tty->driver_data Herton R. Krzesinski
2015-12-15 17:36 ` Peter Hurley
2015-12-15 18:05 ` Herton R. Krzesinski
2015-12-15 19:23 ` Herton R. Krzesinski
2015-12-15 19:52 ` Peter Hurley
2015-12-15 20:34 ` Herton R. Krzesinski
2015-12-15 20:36 ` Peter Hurley
2015-12-29 17:58 ` Herton R. Krzesinski
2016-01-07 22:36 ` Peter Hurley [this message]
2016-01-11 14:11 ` Herton R. Krzesinski
2015-12-15 16:17 ` pty: fix use after free/oops at pty_unix98_shutdown Peter Hurley
2015-12-15 16:36 ` Herton R. Krzesinski
2015-12-15 17:28 ` Peter Hurley
2015-12-15 17:41 ` Herton R. Krzesinski
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=568EE854.20608@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=herton@redhat.com \
--cc=jslaby@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.