From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Oliver Neukum <oneukum@suse.com>
Subject: [PATCH 4.19 63/66] UAS: fix alignment of scatter/gather segments
Date: Thu, 9 May 2019 20:42:38 +0200 [thread overview]
Message-ID: <20190509181308.012452081@linuxfoundation.org> (raw)
In-Reply-To: <20190509181301.719249738@linuxfoundation.org>
From: Oliver Neukum <oneukum@suse.com>
commit 3ae62a42090f1ed48e2313ed256a1182a85fb575 upstream.
This is the UAS version of
747668dbc061b3e62bc1982767a3a1f9815fcf0e
usb-storage: Set virt_boundary_mask to avoid SG overflows
We are not as likely to be vulnerable as storage, as it is unlikelier
that UAS is run over a controller without native support for SG,
but the issue exists.
The issue has been existing since the inception of the driver.
Fixes: 115bb1ffa54c ("USB: Add UAS driver")
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/storage/uas.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -796,24 +796,33 @@ static int uas_slave_alloc(struct scsi_d
{
struct uas_dev_info *devinfo =
(struct uas_dev_info *)sdev->host->hostdata;
+ int maxp;
sdev->hostdata = devinfo;
/*
- * USB has unusual DMA-alignment requirements: Although the
- * starting address of each scatter-gather element doesn't matter,
- * the length of each element except the last must be divisible
- * by the Bulk maxpacket value. There's currently no way to
- * express this by block-layer constraints, so we'll cop out
- * and simply require addresses to be aligned at 512-byte
- * boundaries. This is okay since most block I/O involves
- * hardware sectors that are multiples of 512 bytes in length,
- * and since host controllers up through USB 2.0 have maxpacket
- * values no larger than 512.
+ * We have two requirements here. We must satisfy the requirements
+ * of the physical HC and the demands of the protocol, as we
+ * definitely want no additional memory allocation in this path
+ * ruling out using bounce buffers.
*
- * But it doesn't suffice for Wireless USB, where Bulk maxpacket
- * values can be as large as 2048. To make that work properly
- * will require changes to the block layer.
+ * For a transmission on USB to continue we must never send
+ * a package that is smaller than maxpacket. Hence the length of each
+ * scatterlist element except the last must be divisible by the
+ * Bulk maxpacket value.
+ * If the HC does not ensure that through SG,
+ * the upper layer must do that. We must assume nothing
+ * about the capabilities off the HC, so we use the most
+ * pessimistic requirement.
+ */
+
+ maxp = usb_maxpacket(devinfo->udev, devinfo->data_in_pipe, 0);
+ blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
+
+ /*
+ * The protocol has no requirements on alignment in the strict sense.
+ * Controllers may or may not have alignment restrictions.
+ * As this is not exported, we use an extremely conservative guess.
*/
blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
next prev parent reply other threads:[~2019-05-09 18:49 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-09 18:41 [PATCH 4.19 00/66] 4.19.42-stable review Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 01/66] net: stmmac: Use bfsize1 in ndesc_init_rx_desc Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 02/66] scsi: libsas: fix a race condition when smp task timeout Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 03/66] Drivers: hv: vmbus: Remove the undesired put_cpu_ptr() in hv_synic_cleanup() Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 04/66] ubsan: Fix nasty -Wbuiltin-declaration-mismatch GCC-9 warnings Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 05/66] staging: greybus: power_supply: fix prop-descriptor request size Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 06/66] staging: most: cdev: fix chrdev_region leak in mod_exit Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 07/66] ASoC: tlv320aic3x: fix reset gpio reference counting Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 08/66] ASoC: hdmi-codec: fix S/PDIF DAI Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 09/66] ASoC: stm32: sai: fix iec958 controls indexation Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 10/66] ASoC: stm32: sai: fix exposed capabilities in spdif mode Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 11/66] ASoC:soc-pcm:fix a codec fixup issue in TDM case Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 12/66] ASoC:intel:skl:fix a simultaneous playback & capture issue on hda platform Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 13/66] ASoC: nau8824: fix the issue of the widget with prefix name Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 14/66] ASoC: nau8810: fix the issue of widget with prefixed name Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 15/66] ASoC: samsung: odroid: Fix clock configuration for 44100 sample rate Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 16/66] ASoC: rt5682: recording has no sound after booting Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 17/66] ASoC: wm_adsp: Add locking to wm_adsp2_bus_error Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 18/66] clk: meson-gxbb: round the vdec dividers to closest Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 19/66] ASoC: stm32: dfsdm: manage multiple prepare Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 20/66] ASoC: stm32: dfsdm: fix debugfs warnings on entry creation Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 21/66] ASoC: cs4270: Set auto-increment bit for register writes Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 22/66] ASoC: dapm: Fix NULL pointer dereference in snd_soc_dapm_free_kcontrol Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 23/66] drm/omap: hdmi4_cec: Fix CEC clock handling for PM Greg Kroah-Hartman
2019-05-09 18:41 ` [PATCH 4.19 24/66] IB/hfi1: Eliminate opcode tests on mr deref Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 25/66] IB/hfi1: Fix the allocation of RSM table Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 26/66] MIPS: KGDB: fix kgdb support for SMP platforms Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 27/66] ASoC: tlv320aic32x4: Fix Common Pins Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 28/66] drm/mediatek: Fix an error code in mtk_hdmi_dt_parse_pdata() Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 29/66] perf/x86/intel: Fix handling of wakeup_events for multi-entry PEBS Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 30/66] perf/x86/intel: Initialize TFA MSR Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 31/66] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr() Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 32/66] xtensa: fix initialization of pt_regs::syscall in start_thread Greg Kroah-Hartman
2019-05-09 18:55 ` Max Filippov
2019-05-10 6:24 ` Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 33/66] ASoC: rockchip: pdm: fix regmap_ops hang issue Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 34/66] drm/amd/display: fix cursor black issue Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 35/66] ASoC: cs35l35: Disable regulators on driver removal Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 36/66] objtool: Add rewind_stack_do_exit() to the noreturn list Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 37/66] slab: fix a crash by reading /proc/slab_allocators Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 38/66] drm/sun4i: tcon top: Fix NULL/invalid pointer dereference in sun8i_tcon_top_un/bind Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 39/66] virtio_pci: fix a NULL pointer reference in vp_del_vqs Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 40/66] RDMA/vmw_pvrdma: Fix memory leak on pvrdma_pci_remove Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 41/66] RDMA/hns: Fix bug that caused srq creation to fail Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 42/66] scsi: csiostor: fix missing data copy in csio_scsi_err_handler() Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 43/66] drm/mediatek: fix possible object reference leak Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 44/66] ASoC: Intel: kbl: fix wrong number of channels Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 45/66] virtio-blk: limit number of hw queues by nr_cpu_ids Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 46/66] nvme-fc: correct csn initialization and increments on error Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 47/66] platform/x86: pmc_atom: Drop __initconst on dmi table Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 48/66] perf/core: Fix perf_event_disable_inatomic() race Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 49/66] iommu/amd: Set exclusion range correctly Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 50/66] genirq: Prevent use-after-free and work list corruption Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 51/66] usb: dwc3: Fix default lpm_nyet_threshold value Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 52/66] USB: serial: f81232: fix interrupt worker not stop Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 53/66] USB: cdc-acm: fix unthrottle races Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 54/66] usb-storage: Set virt_boundary_mask to avoid SG overflows Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 55/66] intel_th: pci: Add Comet Lake support Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 56/66] cpufreq: armada-37xx: fix frequency calculation for opp Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 57/66] soc: sunxi: Fix missing dependency on REGMAP_MMIO Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 58/66] scsi: lpfc: change snprintf to scnprintf for possible overflow Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 59/66] scsi: qla2xxx: Fix incorrect region-size setting in optrom SYSFS routines Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 60/66] scsi: qla2xxx: Fix device staying in blocked state Greg Kroah-Hartman
2019-05-09 20:28 ` [EXT] " Quoc Tran
2019-05-10 5:37 ` Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 61/66] Bluetooth: hidp: fix buffer overflow Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 62/66] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Greg Kroah-Hartman
2019-05-09 18:42 ` Greg Kroah-Hartman [this message]
2019-05-09 18:42 ` [PATCH 4.19 64/66] ASoC: Intel: avoid Oops if DMA setup fails Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 65/66] locking/futex: Allow low-level atomic operations to return -EAGAIN Greg Kroah-Hartman
2019-05-09 18:42 ` [PATCH 4.19 66/66] arm64: futex: Bound number of LDXR/STXR loops in FUTEX_WAKE_OP Greg Kroah-Hartman
2019-05-10 0:07 ` [PATCH 4.19 00/66] 4.19.42-stable review kernelci.org bot
2019-05-10 6:34 ` Naresh Kamboju
2019-05-10 10:16 ` Jon Hunter
2019-05-10 13:35 ` Guenter Roeck
2019-05-10 21:25 ` shuah
2019-05-11 11:19 ` Pavel Machek
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=20190509181308.012452081@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oneukum@suse.com \
--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).