summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Vandrovec <petr@vandrovec.name>2016-11-10 13:57:14 -0800
committerBen Hutchings <ben@decadent.org.uk>2017-02-23 03:51:00 +0000
commit19b2b6a14c3321617628e6ae5903d6e521dd7ff2 (patch)
tree8b2dbfd3b38fec2eeb2dad7d7847904dba54dd3d
parenta1aa5ae641b2c7a8d7aa523754c18ebe219a20d0 (diff)
downloadlinux-19b2b6a14c3321617628e6ae5903d6e521dd7ff2.tar.gz
linux-19b2b6a14c3321617628e6ae5903d6e521dd7ff2.tar.bz2
linux-19b2b6a14c3321617628e6ae5903d6e521dd7ff2.zip
Fix USB CB/CBI storage devices with CONFIG_VMAP_STACK=y
commit 2ce9d2272b98743b911196c49e7af5841381c206 upstream. Some code (all error handling) submits CDBs that are allocated on the stack. This breaks with CB/CBI code that tries to create URB directly from SCSI command buffer - which happens to be in vmalloced memory with vmalloced kernel stacks. Let's make copy of the command in usb_stor_CB_transport. Signed-off-by: Petr Vandrovec <petr@vandrovec.name> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/usb/storage/transport.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 366395c5fa92..197fcfa0659a 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -922,10 +922,15 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
/* COMMAND STAGE */
/* let's send the command via the control pipe */
+ /*
+ * Command is sometime (f.e. after scsi_eh_prep_cmnd) on the stack.
+ * Stack may be vmallocated. So no DMA for us. Make a copy.
+ */
+ memcpy(us->iobuf, srb->cmnd, srb->cmd_len);
result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
US_CBI_ADSC,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
- us->ifnum, srb->cmnd, srb->cmd_len);
+ us->ifnum, us->iobuf, srb->cmd_len);
/* check the return code for the command */
US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result);