All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Kuen-Han Tsai <khtsai@google.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, stern@rowland.harvard.edu
Subject: Re: [RFT PATCH 1/2] xhci: Reconfigure endpoint 0 max packet size only during endpoint reset
Date: Wed, 29 Nov 2023 16:57:23 +0200	[thread overview]
Message-ID: <0d6880a5-0cf4-9961-97ab-04777cccd9ed@linux.intel.com> (raw)
In-Reply-To: <CAKzKK0psOFJdBsPkqdRi4_5V=5z9XMnFPCYbcE1Nj6A1zj8Gmw@mail.gmail.com>

>> +       ep_index = xhci_get_endpoint_index(&host_ep->desc);
>> +
>> +       /*
>> +        * Usb core assumes a max packet value for ep0 on FS devices until the
>> +        * real value is read from the descriptor. Core resets Ep0 if values
>> +        * mismatch. Reconfigure the xhci ep0 endpoint context here in that case
>> +        */
>> +       if (usb_endpoint_xfer_control(&host_ep->desc) && ep_index == 0) {
>> +               udev = container_of(host_ep, struct usb_device, ep0);
>> +               if (udev->speed == USB_SPEED_FULL)
>> +                       xhci_check_ep0_maxpacket(xhci, xhci->devs[udev->slot_id]);
>> +               /* Nothing else should be done here for ep0 during ep reset */
>> +               return;
>> +       }
>> +
> 
> Could there be a race condition between the xhci_endpoint_reset() and
> xhci_free_dev() functions, resulting in the xhci->devs[udev->slot_id]
> becoming null?
> If so, a null pointer dereference will happen in
> xhci_check_ep0_maxpacket() when accessing vdev->out_ctx.

should not race. xhci_free_dev() and xhci_endpoint_reset() for endpoint 0 should only
be called by hub driver hub_free_dev() and usb_ep0_reinit() respectively.

Hub driver takes care of concurrency for these

Thanks
Mathias


  reply	other threads:[~2023-11-29 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17  7:21 [PATCH] xhci: fix null pointer deref for xhci_urb_enqueue Kuen-Han Tsai
2023-11-17 13:32 ` Mathias Nyman
2023-11-18 10:19   ` Kuen-Han Tsai
2023-11-20 15:33     ` Mathias Nyman
2023-11-28 13:57       ` Mathias Nyman
2023-11-28 14:01         ` [RFT PATCH 1/2] xhci: Reconfigure endpoint 0 max packet size only during endpoint reset Mathias Nyman
2023-11-28 14:01           ` [RFT PATCH 2/2] xhci: fix possible null pointer deref during xhci urb enqueue Mathias Nyman
2023-11-28 15:32           ` [RFT PATCH 1/2] xhci: Reconfigure endpoint 0 max packet size only during endpoint reset Kuen-Han Tsai
2023-11-29 14:57             ` Mathias Nyman [this message]
2023-11-28 15:01         ` [PATCH] xhci: fix null pointer deref for xhci_urb_enqueue Kuen-Han Tsai
2023-11-17 13:53 ` Greg KH
2023-11-18 11:19   ` Kuen-Han Tsai
2023-11-23  1:54 ` kernel test robot

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=0d6880a5-0cf4-9961-97ab-04777cccd9ed@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=khtsai@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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.