linux-stable/drivers/usb
Martin K. Petersen 3a9c459091 scsi: sd: usb_storage: uas: Access media prior to querying device properties
[ Upstream commit 321da3dc1f ]

It has been observed that some USB/UAS devices return generic properties
hardcoded in firmware for mode pages for a period of time after a device
has been discovered. The reported properties are either garbage or they do
not accurately reflect the characteristics of the physical storage device
attached in the case of a bridge.

Prior to commit 1e029397d1 ("scsi: sd: Reorganize DIF/DIX code to
avoid calling revalidate twice") we would call revalidate several
times during device discovery. As a result, incorrect values would
eventually get replaced with ones accurately describing the attached
storage. When we did away with the redundant revalidate pass, several
cases were reported where devices reported nonsensical values or would
end up in write-protected state.

An initial attempt at addressing this issue involved introducing a
delayed second revalidate invocation. However, this approach still
left some devices reporting incorrect characteristics.

Tasos Sahanidis debugged the problem further and identified that
introducing a READ operation prior to MODE SENSE fixed the problem and that
it wasn't a timing issue. Issuing a READ appears to cause the devices to
update their state to reflect the actual properties of the storage
media. Device properties like vendor, model, and storage capacity appear to
be correctly reported from the get-go. It is unclear why these devices
defer populating the remaining characteristics.

Match the behavior of a well known commercial operating system and
trigger a READ operation prior to querying device characteristics to
force the device to populate the mode pages.

The additional READ is triggered by a flag set in the USB storage and
UAS drivers. We avoid issuing the READ for other transport classes
since some storage devices identify Linux through our particular
discovery command sequence.

Link: https://lore.kernel.org/r/20240213143306.2194237-1-martin.petersen@oracle.com
Fixes: 1e029397d1 ("scsi: sd: Reorganize DIF/DIX code to avoid calling revalidate twice")
Cc: stable@vger.kernel.org
Reported-by: Tasos Sahanidis <tasos@tasossah.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Tasos Sahanidis <tasos@tasossah.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-13 13:05:24 +02:00
..
atm
c67x00
cdns3 usb: cdns3: fix memory double free when handle zero packet 2024-03-01 13:26:34 +01:00
chipidea usb: chipidea: wait controller resume finished for wakeup irq 2024-01-25 15:27:40 -08:00
class usb: cdc-wdm: close race between read and workqueue 2024-04-03 15:19:50 +02:00
common usb: ulpi: Fix debugfs directory leak 2024-02-23 09:12:34 +01:00
core USB: core: Fix deadlock in usb_deauthorize_interface() 2024-04-03 15:19:55 +02:00
dwc2 usb: dwc2: gadget: LPM flow fix 2024-04-03 15:19:52 +02:00
dwc3 usb: dwc3-am62: fix module unload/reload behavior 2024-04-03 15:19:50 +02:00
early usb: early: xhci-dbc: Fix a potential out-of-bound memory access 2023-03-10 09:33:35 +01:00
gadget usb: gadget: uvc: mark incomplete frames with UVC_STREAM_ERR 2024-04-13 13:05:17 +02:00
host usb: sl811-hcd: only defined function checkdone if QUIRK2 is defined 2024-04-13 13:05:18 +02:00
image
isp1760
misc usb: misc: onboard_hub: add support for Microchip USB2412 USB 2.0 hub 2023-10-25 12:03:08 +02:00
mon usb: mon: Fix atomicity violation in mon_bin_vma_fault 2024-01-25 15:27:40 -08:00
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-11 23:03:30 +09:00
musb usb: musb: Modify the "HWVers" register address 2023-10-19 23:08:55 +02:00
phy Revert "usb: phy: generic: Get the vbus supply" 2024-04-03 15:19:50 +02:00
renesas_usbhs
roles usb: roles: don't get/set_role() when usb_role_switch is unregistered 2024-03-01 13:26:34 +01:00
serial USB: serial: cp210x: add pid/vid for TDK NC0110013M and MM0110113M 2024-04-03 15:19:30 +02:00
storage scsi: sd: usb_storage: uas: Access media prior to querying device properties 2024-04-13 13:05:24 +02:00
typec usb: typec: tcpci: add generic tcpci fallback compatible 2024-04-13 13:05:18 +02:00
usbip USB: usbip: fix stub_dev hub disconnect 2023-11-20 11:52:10 +01:00
Kconfig
Makefile
usb-skeleton.c