All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Pavel Emelyanov <xemul@parallels.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Jiri Slaby <jslaby@suse.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: Question on release_one_tty
Date: Thu, 7 Aug 2014 13:18:12 +0400	[thread overview]
Message-ID: <20140807091812.GR20553@moon> (raw)
In-Reply-To: <53E34158.9070009@parallels.com>

On Thu, Aug 07, 2014 at 01:05:28PM +0400, Pavel Emelyanov wrote:
> > 
> > So how this code supposed to work then? I mean tty_driver_kref_put must never call
> > for destruct_tty_driver, otherwise we're accessing freed memory.
> 
> mod = driver->owner;
> tty_driver_kref_put(driver);
> module_put(mod);
> 
> Check the upstream whether the same issue exists there.

Same in tty.git

static void release_one_tty(struct work_struct *work)
{
	struct tty_struct *tty =
		container_of(work, struct tty_struct, hangup_work);
	struct tty_driver *driver = tty->driver;

	if (tty->ops->cleanup)
		tty->ops->cleanup(tty);

	tty->magic = 0;
	tty_driver_kref_put(driver);
	module_put(driver->owner);

	spin_lock(&tty_files_lock);
	list_del_init(&tty->tty_files);
	spin_unlock(&tty_files_lock);

	put_pid(tty->pgrp);
	put_pid(tty->session);
	free_tty_struct(tty);
}

so I think yes, the fix is needed. I'll prepare the patch
and test/post for review.

  reply	other threads:[~2014-08-07  9:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-07  8:25 Question on release_one_tty Cyrill Gorcunov
2014-08-07  8:28 ` Pavel Emelyanov
2014-08-07  8:34   ` Cyrill Gorcunov
2014-08-07  9:05     ` Pavel Emelyanov
2014-08-07  9:18       ` Cyrill Gorcunov [this message]
2014-08-07  9:34         ` [PATCH] tty: Fix potential use after free in release_one_tty Cyrill Gorcunov
2014-08-07 20:22           ` Greg Kroah-Hartman

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=20140807091812.GR20553@moon \
    --to=gorcunov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xemul@parallels.com \
    /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.