From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>, stable <stable@vger.kernel.org>,
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>,
David Vrabel <david.vrabel@csr.com>
Subject: [PATCH 4/6] USB: wusbcore: fix NULL-deref at probe
Date: Mon, 13 Mar 2017 13:47:51 +0100 [thread overview]
Message-ID: <20170313124753.28784-5-johan@kernel.org> (raw)
In-Reply-To: <20170313124753.28784-1-johan@kernel.org>
Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer or accessing memory beyond the endpoint array should a
malicious device lack the expected endpoints.
This specifically fixes the NULL-pointer dereference when probing HWA HC
devices.
Fixes: df3654236e31 ("wusb: add the Wire Adapter (WA) core")
Cc: stable <stable@vger.kernel.org> # 2.6.28
Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
Cc: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/wusbcore/wa-hc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/wusbcore/wa-hc.c b/drivers/usb/wusbcore/wa-hc.c
index 252c7bd9218a..d01496fd27fe 100644
--- a/drivers/usb/wusbcore/wa-hc.c
+++ b/drivers/usb/wusbcore/wa-hc.c
@@ -39,6 +39,9 @@ int wa_create(struct wahc *wa, struct usb_interface *iface,
int result;
struct device *dev = &iface->dev;
+ if (iface->cur_altsetting->desc.bNumEndpoints < 3)
+ return -ENODEV;
+
result = wa_rpipes_create(wa);
if (result < 0)
goto error_rpipes_create;
--
2.12.0
next prev parent reply other threads:[~2017-03-13 12:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20170313124753.28784-1-johan@kernel.org>
2017-03-13 12:47 ` [PATCH 1/6] USB: idmouse: fix NULL-deref at probe Johan Hovold
2017-03-13 12:47 ` [PATCH 2/6] USB: lvtest: " Johan Hovold
2017-03-13 12:47 ` [PATCH 3/6] USB: uss720: " Johan Hovold
2017-03-13 12:47 ` Johan Hovold [this message]
2017-03-13 12:47 ` [PATCH 5/6] uwb: hwa-rc: " Johan Hovold
2017-03-13 12:47 ` [PATCH 6/6] uwb: i1480-dfu: " Johan Hovold
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=20170313124753.28784-5-johan@kernel.org \
--to=johan@kernel.org \
--cc=david.vrabel@csr.com \
--cc=gregkh@linuxfoundation.org \
--cc=inaky.perez-gonzalez@intel.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).