008-hso-Fix-stack-corruption-on-some-architectures.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From e75dc677ff8d06ffa61bef6fee436227ae5440c6 Mon Sep 17 00:00:00 2001
  2. From: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
  3. Date: Wed, 21 Aug 2013 01:43:19 -0700
  4. Subject: [PATCH 2/2] hso: Fix stack corruption on some architectures
  5. As Sergei Shtylyov explained in the #mipslinux IRC channel:
  6. [Mon 2013-08-19 12:28:21 PM PDT] <headless> guys, are you sure it's not "DMA off stack" case?
  7. [Mon 2013-08-19 12:28:35 PM PDT] <headless> it's a known stack corruptor on non-coherent arches
  8. [Mon 2013-08-19 12:31:48 PM PDT] <DonkeyHotei> headless: for usb/ehci?
  9. [Mon 2013-08-19 12:34:11 PM PDT] <DonkeyHotei> headless: explain
  10. [Mon 2013-08-19 12:35:38 PM PDT] <headless> usb_control_msg() (or other such func) should not use buffer on stack. DMA from/to stack is prohibited
  11. [Mon 2013-08-19 12:35:58 PM PDT] <headless> and EHCI uses DMA on control xfers (as well as all the others)
  12. Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
  13. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  14. Signed-off-by: David S. Miller <davem@davemloft.net>
  15. ---
  16. drivers/net/usb/hso.c | 6 +++++-
  17. 1 file changed, 5 insertions(+), 1 deletion(-)
  18. --- a/drivers/net/usb/hso.c
  19. +++ b/drivers/net/usb/hso.c
  20. @@ -2838,13 +2838,16 @@ exit:
  21. static int hso_get_config_data(struct usb_interface *interface)
  22. {
  23. struct usb_device *usbdev = interface_to_usbdev(interface);
  24. - u8 config_data[17];
  25. + u8 *config_data = kmalloc(17, GFP_KERNEL);
  26. u32 if_num = interface->altsetting->desc.bInterfaceNumber;
  27. s32 result;
  28. + if (!config_data)
  29. + return -ENOMEM;
  30. if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
  31. 0x86, 0xC0, 0, 0, config_data, 17,
  32. USB_CTRL_SET_TIMEOUT) != 0x11) {
  33. + kfree(config_data);
  34. return -EIO;
  35. }
  36. @@ -2895,6 +2898,7 @@ static int hso_get_config_data(struct us
  37. if (config_data[16] & 0x1)
  38. result |= HSO_INFO_CRC_BUG;
  39. + kfree(config_data);
  40. return result;
  41. }