Skip to content

Commit 2ce9d22

Browse files
petrvandrovecgregkh
authored andcommitted
Fix USB CB/CBI storage devices with CONFIG_VMAP_STACK=y
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> Cc: stable <stable@vger.kernel.org> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a25f094 commit 2ce9d22

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/usb/storage/transport.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,15 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
954954

955955
/* COMMAND STAGE */
956956
/* let's send the command via the control pipe */
957+
/*
958+
* Command is sometime (f.e. after scsi_eh_prep_cmnd) on the stack.
959+
* Stack may be vmallocated. So no DMA for us. Make a copy.
960+
*/
961+
memcpy(us->iobuf, srb->cmnd, srb->cmd_len);
957962
result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
958963
US_CBI_ADSC,
959964
USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
960-
us->ifnum, srb->cmnd, srb->cmd_len);
965+
us->ifnum, us->iobuf, srb->cmd_len);
961966

962967
/* check the return code for the command */
963968
usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n",

0 commit comments

Comments
 (0)