From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Maksim Salau <maksim.salau@gmail.com>
Subject: [PATCH 4.9 20/80] usb: misc: legousbtower: Fix buffers on stack
Date: Thu, 18 May 2017 12:48:02 +0200 [thread overview]
Message-ID: <20170518104834.636860846@linuxfoundation.org> (raw)
In-Reply-To: <20170518104833.667298773@linuxfoundation.org>
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maksim Salau <maksim.salau@gmail.com>
commit 942a48730faf149ccbf3e12ac718aee120bb3529 upstream.
Allocate buffers on HEAP instead of STACK for local structures
that are to be received using usb_control_msg().
Signed-off-by: Maksim Salau <maksim.salau@gmail.com>
Tested-by: Alfredo Rafael Vicente Boix <alviboi@gmail.com>;
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/misc/legousbtower.c | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -317,9 +317,16 @@ static int tower_open (struct inode *ino
int subminor;
int retval = 0;
struct usb_interface *interface;
- struct tower_reset_reply reset_reply;
+ struct tower_reset_reply *reset_reply;
int result;
+ reset_reply = kmalloc(sizeof(*reset_reply), GFP_KERNEL);
+
+ if (!reset_reply) {
+ retval = -ENOMEM;
+ goto exit;
+ }
+
nonseekable_open(inode, file);
subminor = iminor(inode);
@@ -364,8 +371,8 @@ static int tower_open (struct inode *ino
USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE,
0,
0,
- &reset_reply,
- sizeof(reset_reply),
+ reset_reply,
+ sizeof(*reset_reply),
1000);
if (result < 0) {
dev_err(&dev->udev->dev,
@@ -406,6 +413,7 @@ unlock_exit:
mutex_unlock(&dev->lock);
exit:
+ kfree(reset_reply);
return retval;
}
@@ -808,7 +816,7 @@ static int tower_probe (struct usb_inter
struct lego_usb_tower *dev = NULL;
struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor* endpoint;
- struct tower_get_version_reply get_version_reply;
+ struct tower_get_version_reply *get_version_reply = NULL;
int i;
int retval = -ENOMEM;
int result;
@@ -886,6 +894,13 @@ static int tower_probe (struct usb_inter
dev->interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;
dev->interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;
+ get_version_reply = kmalloc(sizeof(*get_version_reply), GFP_KERNEL);
+
+ if (!get_version_reply) {
+ retval = -ENOMEM;
+ goto error;
+ }
+
/* get the firmware version and log it */
result = usb_control_msg (udev,
usb_rcvctrlpipe(udev, 0),
@@ -893,18 +908,19 @@ static int tower_probe (struct usb_inter
USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE,
0,
0,
- &get_version_reply,
- sizeof(get_version_reply),
+ get_version_reply,
+ sizeof(*get_version_reply),
1000);
if (result < 0) {
dev_err(idev, "LEGO USB Tower get version control request failed\n");
retval = result;
goto error;
}
- dev_info(&interface->dev, "LEGO USB Tower firmware version is %d.%d "
- "build %d\n", get_version_reply.major,
- get_version_reply.minor,
- le16_to_cpu(get_version_reply.build_no));
+ dev_info(&interface->dev,
+ "LEGO USB Tower firmware version is %d.%d build %d\n",
+ get_version_reply->major,
+ get_version_reply->minor,
+ le16_to_cpu(get_version_reply->build_no));
/* we can register the device now, as it is ready */
usb_set_intfdata (interface, dev);
@@ -928,6 +944,7 @@ exit:
return retval;
error:
+ kfree(get_version_reply);
tower_delete(dev);
return retval;
}
next prev parent reply other threads:[~2017-05-18 10:48 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 10:47 [PATCH 4.9 00/80] 4.9.29-stable review Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 01/80] xen: adjust early dom0 p2m handling to xen hypervisor behavior Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 02/80] target: Fix compare_and_write_callback handling for non GOOD status Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 03/80] target/fileio: Fix zero-length READ and WRITE handling Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 04/80] iscsi-target: Set session_fall_back_to_erl0 when forcing reinstatement Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 05/80] usb: xhci: bInterval quirk for TI TUSB73x0 Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 06/80] usb: host: xhci: print correct command ring address Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 07/80] USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 08/80] USB: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 10/80] staging: vt6656: use off stack for in buffer USB transfers Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 11/80] staging: vt6656: use off stack for out " Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 12/80] staging: gdm724x: gdm_mux: fix use-after-free on module unload Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 13/80] staging: comedi: jr3_pci: fix possible null pointer dereference Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 14/80] staging: comedi: jr3_pci: cope with jiffies wraparound Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 15/80] usb: misc: add missing continue in switch Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 16/80] usb: gadget: legacy gadgets are optional Greg Kroah-Hartman
2017-05-18 10:47 ` [PATCH 4.9 17/80] usb: Make sure usb/phy/of gets built-in Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 18/80] usb: hub: Fix error loop seen after hub communication errors Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 19/80] usb: hub: Do not attempt to autosuspend disconnected devices Greg Kroah-Hartman
2017-05-18 10:48 ` Greg Kroah-Hartman [this message]
2017-05-18 10:48 ` [PATCH 4.9 21/80] x86/boot: Fix BSS corruption/overwrite bug in early x86 kernel startup Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 22/80] selftests/x86/ldt_gdt_32: Work around a glibc sigaction() bug Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 23/80] x86, pmem: Fix cache flushing for iovec write < 8 bytes Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 24/80] um: Fix PTRACE_POKEUSER on x86_64 Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 25/80] perf/x86: Fix Broadwell-EP DRAM RAPL events Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 27/80] KVM: arm/arm64: fix races in kvm_psci_vcpu_on Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 28/80] arm64: KVM: Fix decoding of Rt/Rt2 when trapping AArch32 CP accesses Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 29/80] block: fix blk_integrity_register to use templates interval_exp if not 0 Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 30/80] crypto: algif_aead - Require setkey before accept(2) Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 31/80] crypto: ccp - Use only the relevant interrupt bits Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 32/80] crypto: ccp - Disable interrupts early on unload Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 33/80] crypto: ccp - Change ISR handler method for a v3 CCP Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 34/80] crypto: ccp - Change ISR handler method for a v5 CCP Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 35/80] dm era: save spacemap metadata root after the pre-commit Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 36/80] dm rq: check blk_mq_register_dev() return value in dm_mq_init_request_queue() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 37/80] dm thin: fix a memory leak when passing discard bio down Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 38/80] vfio/type1: Remove locked page accounting workqueue Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 39/80] iov_iter: dont revert iov buffer if csum error Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 40/80] IB/core: Fix sysfs registration error flow Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 41/80] IB/core: For multicast functions, verify that LIDs are multicast LIDs Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 42/80] IB/IPoIB: ibX: failed to create mcg debug file Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 43/80] IB/mlx4: Fix ib device initialization error flow Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 44/80] IB/mlx4: Reduce SRIOV multicast cleanup warning message to debug level Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 45/80] IB/hfi1: Prevent kernel QP post send hard lockups Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 46/80] perf auxtrace: Fix no_size logic in addr_filter__resolve_kernel_syms() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 47/80] ext4: evict inline data when writing to memory map Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 48/80] orangefs: fix bounds check for listxattr Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 49/80] orangefs: clean up oversize xattr validation Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 50/80] orangefs: do not set getattr_time on orangefs_lookup Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 51/80] orangefs: do not check possibly stale size on truncate Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 52/80] fs/xattr.c: zero out memory copied to userspace in getxattr Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 53/80] ceph: fix memory leak in __ceph_setxattr() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 54/80] fs/block_dev: always invalidate cleancache in invalidate_bdev() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 55/80] mm: prevent potential recursive reclaim due to clearing PF_MEMALLOC Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 56/80] Fix match_prepath() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 57/80] Set unicode flag on cifs echo request to avoid Mac error Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 58/80] SMB3: Work around mount failure when using SMB3 dialect to Macs Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 60/80] cifs: fix leak in FSCTL_ENUM_SNAPS response handling Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 61/80] cifs: fix CIFS_ENUMERATE_SNAPSHOTS oops Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 62/80] CIFS: fix oplock break deadlocks Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 63/80] cifs: fix CIFS_IOC_GET_MNT_INFO oops Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 65/80] padata: free correct variable Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 66/80] device-dax: fix cdev leak Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 67/80] fscrypt: fix context consistency check when key(s) unavailable Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 68/80] serial: samsung: Use right device for DMA-mapping calls Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 69/80] serial: omap: fix runtime-pm handling on unbind Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 70/80] serial: omap: suspend device on probe errors Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 71/80] tty: pty: Fix ldisc flush after userspace become aware of the data already Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 72/80] Bluetooth: Fix user channel for 32bit userspace on 64bit kernel Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 73/80] Bluetooth: hci_bcm: add missing tty-device sanity check Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 74/80] Bluetooth: hci_intel: " Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 75/80] ipmi: Fix kernel panic at ipmi_ssif_thread() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 76/80] libnvdimm, region: fix flush hint detection crash Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.9 77/80] libnvdimm, pmem: fix a NULL pointer BUG in nd_pmem_notify Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.9 78/80] libnvdimm, pfn: fix npfns vs section alignment Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.9 79/80] pstore: Fix flags to enable dumps on powerpc Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.9 80/80] pstore: Shut down worker when unregistering Greg Kroah-Hartman
2017-05-18 17:32 ` [PATCH 4.9 00/80] 4.9.29-stable review Shuah Khan
2017-05-19 1:10 ` Guenter Roeck
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=20170518104834.636860846@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maksim.salau@gmail.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).