From: Anant Thazhemadam <firstname.lastname@example.org>
Anant Thazhemadam <email@example.com>,
H Hartley Sweeten <firstname.lastname@example.org>,
Ian Abbott <email@example.com>,
Subject: [Linux-kernel-mentees] [PATCH] staging: comedi: check validity of wMaxPacketSize of usb endpoints found
Date: Fri, 9 Oct 2020 21:50:29 +0530 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
While finding usb endpoints in vmk80xx_find_usb_endpoints(), check if
wMaxPacketSize = 0 for the endpoints found.
Some devices have isochronous endpoints that have wMaxPacketSize = 0
(as required by the USB-2 spec).
However, since this doesn't apply here, wMaxPacketSize = 0 can be
considered to be invalid.
Signed-off-by: Anant Thazhemadam <email@example.com>
The error (as detected by syzbot) is generated in
vmk80xx_write_packet() (which is called in vmk80xx_reset_device()) when
it tries to assign devpriv->usb_tx_buf = cmd.
This NULL pointer dereference issue arises because
size = usb_endpoint_maxp(devpriv->ep_tx) = 0.
This can be traced back to vmk80xx_find_usb_endpoints(), where the usb
endpoints are found, and assigned accordingly.
(For some more insight, in vmk80xx_find_usb_endpoints(),
if one of intf->cur_altsetting->iface_desc->endpoints' desc value = 0,
and consequently this endpoint is assigned to devpriv->ep_tx,
this issue gets triggered.)
Checking if the wMaxPacketSize of an endpoint is invalid and returning
an error value accordingly, seems to fix the error.
We could also alternatively perform this checking (if the size is 0 or not)
in vmk80xx_reset_device() itself, but it only seemed like covering up the issue
at that place, rather than fixing it, so I wasn't sure that was any better.
However, if I'm not wrong, this might end up causing the probe to fail, and I'm
not sure if that's the right thing to do in cases like this, and if it isn't I'd
like some input on what exactly is the required course of action in cases like this.
drivers/staging/comedi/drivers/vmk80xx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
index 65dc6c51037e..cb0a965d3c37 100644
@@ -667,6 +667,9 @@ static int vmk80xx_find_usb_endpoints(struct comedi_device *dev)
if (!devpriv->ep_rx || !devpriv->ep_tx)
+ if (!usb_endpoint_maxp(devpriv->ep_rx) || !usb_endpoint_maxp(devpriv->ep_tx))
+ return -EINVAL;
Linux-kernel-mentees mailing list
next reply other threads:[~2020-10-09 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 16:20 Anant Thazhemadam [this message]
2020-10-10 7:00 ` [Linux-kernel-mentees] [PATCH] staging: comedi: check validity of wMaxPacketSize of usb endpoints found Greg Kroah-Hartman
2020-10-10 1:59 ` Anant Thazhemadam
2020-10-10 8:09 ` Greg Kroah-Hartman
2020-10-10 8:26 ` Anant Thazhemadam
-- strict thread matches above, loose matches on Subject: below --
2020-10-09 16:16 Anant Thazhemadam
2020-10-09 16:24 ` Anant Thazhemadam
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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).