From: Johan Hovold <johan@kernel.org>
To: linux-usb@vger.kernel.org
Cc: Andrey Konovalov <andreyknvl@google.com>,
linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
stable <stable@vger.kernel.org>
Subject: [PATCH 1/2] USB: serial: console: fix use-after-free on disconnect
Date: Wed, 4 Oct 2017 11:01:12 +0200 [thread overview]
Message-ID: <20171004090113.24218-2-johan@kernel.org> (raw)
In-Reply-To: <20171004090113.24218-1-johan@kernel.org>
A clean-up patch removing removing two redundant NULL-checks from the
console disconnect handler inadvertently also removed a third check.
This could lead to the struct usb_serial being prematurely freed by the
console code when a driver accepts but does not register any ports for
an interface which also lacks endpoint descriptors.
Fixes: 0e517c93dc02 ("USB: serial: console: clean up sanity checks")
Cc: stable <stable@vger.kernel.org> # 4.11
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/console.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index fdf89800ebc3..ed8ba3ef5c79 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -265,7 +265,7 @@ static struct console usbcons = {
void usb_serial_console_disconnect(struct usb_serial *serial)
{
- if (serial->port[0] == usbcons_info.port) {
+ if (serial->port[0] && serial->port[0] == usbcons_info.port) {
usb_serial_console_exit();
usb_serial_put(serial);
}
--
2.14.2
next parent reply other threads:[~2017-10-04 9:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20171004090113.24218-1-johan@kernel.org>
2017-10-04 9:01 ` Johan Hovold [this message]
2017-10-04 14:39 ` [PATCH 1/2] USB: serial: console: fix use-after-free on disconnect Greg KH
2017-10-07 8:56 ` Jaejoong Kim
2017-10-09 10:41 ` Johan Hovold
2017-10-09 11:05 ` Andrey Konovalov
2017-10-09 11:10 ` Johan Hovold
2017-10-04 9:01 ` [PATCH 2/2] USB: serial: console: fix use-after-free after failed setup Johan Hovold
2017-10-04 14:39 ` Greg KH
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=20171004090113.24218-2-johan@kernel.org \
--to=johan@kernel.org \
--cc=andreyknvl@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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;
as well as URLs for NNTP newsgroup(s).