From: Fedor Pchelkin <pchelkin@ispras.ru>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>,
ath9k-devel@qca.qualcomm.com, ldv-project@linuxtesting.org,
eli.billauer@gmail.com,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
andreyknvl@google.com, gustavoars@kernel.org,
ingrassia@epigenesys.com, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org,
oneukum@suse.com, tiwai@suse.de, syzkaller-bugs@googlegroups.com
Subject: Re: WARNING in hif_usb_alloc_rx_urbs/usb_submit_urb
Date: Fri, 26 Aug 2022 16:14:48 +0300 [thread overview]
Message-ID: <5dce2e1c-fa65-2fb3-08ad-65122f7e495d@ispras.ru> (raw)
In-Reply-To: <9ebc80d0-1b16-642c-e66b-2de52c673334@ispras.ru>
Sat, 10 Oct 2020 at 04:08:19 UTC+3, Alan Stern wrote:
> Index: usb-devel/drivers/net/wireless/ath/ath9k/hif_usb.c
> ===================================================================
> --- usb-devel.orig/drivers/net/wireless/ath/ath9k/hif_usb.c
> +++ usb-devel/drivers/net/wireless/ath/ath9k/hif_usb.c
> @@ -1307,6 +1307,20 @@ static int ath9k_hif_usb_probe(struct us
> struct usb_device *udev = interface_to_usbdev(interface);
> struct hif_device_usb *hif_dev;
> int ret = 0;
> + struct usb_host_interface *alt;
> + struct usb_endpoint_descriptor *epd;
> +
> + /* Verify the expected endpoints are present */
> + alt = interface->cur_altsetting;
> + if (!usb_find_int_in_endpoint(alt, &epd) ||
> + usb_endpoint_num(epd) != USB_REG_IN_PIPE ||
> + !usb_find_int_out_endpoint(alt, &epd) ||
> + usb_endpoint_num(epd) != USB_REG_OUT_PIPE ||
> + !usb_find_bulk_in_endpoint(alt, &epd) ||
> + usb_endpoint_num(epd) != USB_WLAN_RX_PIPE ||
> + !usb_find_bulk_out_endpoint(alt, &epd) ||
> + usb_endpoint_num(epd) != USB_WLAN_TX_PIPE)
> + return -ENODEV;
>
> if (id->driver_info == STORAGE_DEVICE)
> return send_eject_command(interface);
We've tested the suggested patch and found a null-ptr-deref. The thing
is that usb_find_{...}_endpoint() returns zero in normal case, and
non-zero value (-ENXIO) when failed (in current patch version it is
supposed to be just opposite and sometimes a NULL epd is dereferenced).
To fix it the negation signs before usb_find_{...}_endpoint() should be
removed.
And we also think usb_find_common_endpoints(...) should be used directly
as all the scanned usb_endpoint_descriptors will be passed to it and
returned in just one call.
If you wish, I may prepare the patch myself.
Fedor
next prev parent reply other threads:[~2022-08-26 13:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-19 18:34 WARNING in hif_usb_alloc_rx_urbs/usb_submit_urb Fedor Pchelkin
2022-08-19 18:46 ` Alan Stern
2022-08-19 19:07 ` Fedor Pchelkin
2022-08-26 13:14 ` Fedor Pchelkin [this message]
2022-08-26 14:45 ` Alan Stern
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=5dce2e1c-fa65-2fb3-08ad-65122f7e495d@ispras.ru \
--to=pchelkin@ispras.ru \
--cc=andreyknvl@google.com \
--cc=ath9k-devel@qca.qualcomm.com \
--cc=eli.billauer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=ingrassia@epigenesys.com \
--cc=khoroshilov@ispras.ru \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tiwai@suse.de \
/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