All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: Johan Hovold <johan@kernel.org>, Jiri Slaby <jslaby@suse.cz>
Subject: [patch added to 3.12-stable] USB: usbtmc: add missing endpoint sanity check
Date: Mon, 10 Apr 2017 14:59:00 +0200	[thread overview]
Message-ID: <20170410125930.26495-23-jslaby@suse.cz> (raw)
In-Reply-To: <20170410125930.26495-1-jslaby@suse.cz>

From: Johan Hovold <johan@kernel.org>

This patch has been added to the 3.12 stable tree. If you have any
objections, please let us know.

===============

commit 687e0687f71ec00e0132a21fef802dee88c2f1ad upstream.

USBTMC devices are required to have a bulk-in and a bulk-out endpoint,
but the driver failed to verify this, something which could lead to the
endpoint addresses being taken from uninitialised memory.

Make sure to zero all private data as part of allocation, and add the
missing endpoint sanity check.

Note that this also addresses a more recently introduced issue, where
the interrupt-in-presence flag would also be uninitialised whenever the
optional interrupt-in endpoint is not present. This in turn could lead
to an interrupt urb being allocated, initialised and submitted based on
uninitialised values.

Fixes: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.")
Fixes: 5b775f672cc9 ("USB: add USB test and measurement class driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
[ johan: backport to v4.4 ]
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/class/usbtmc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 72ed4ac2cfad..13583a2edba7 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1102,7 +1102,7 @@ static int usbtmc_probe(struct usb_interface *intf,
 
 	dev_dbg(&intf->dev, "%s called\n", __func__);
 
-	data = kmalloc(sizeof(*data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		dev_err(&intf->dev, "Unable to allocate kernel memory\n");
 		return -ENOMEM;
@@ -1162,6 +1162,12 @@ static int usbtmc_probe(struct usb_interface *intf,
 		}
 	}
 
+	if (!data->bulk_out || !data->bulk_in) {
+		dev_err(&intf->dev, "bulk endpoints not found\n");
+		retcode = -ENODEV;
+		goto err_put;
+	}
+
 	retcode = get_capabilities(data);
 	if (retcode)
 		dev_err(&intf->dev, "can't read capabilities\n");
@@ -1185,6 +1191,7 @@ static int usbtmc_probe(struct usb_interface *intf,
 error_register:
 	sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
 	sysfs_remove_group(&intf->dev.kobj, &data_attr_grp);
+err_put:
 	kref_put(&data->kref, usbtmc_delete);
 	return retcode;
 }
-- 
2.12.2

  parent reply	other threads:[~2017-04-10 12:59 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 12:58 [patch added to 3.12-stable] Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000 Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: iforce - validate number of endpoints before using them Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: ims-pcu " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: hanwang " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: yealink " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: cm109 " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] Input: kbtab " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] ALSA: seq: Fix racy cell insertions during snd_seq_pool_done() Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: serial: qcserial: add Dell DW5811e Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] ACM gadget: fix endianness in notifications Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: uss720: fix NULL-deref at probe Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: idmouse: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] USB: wusbcore: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] usb: hub: Fix crash after failure to read BOS descriptor Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] uwb: i1480-dfu: fix NULL-deref at probe Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] uwb: hwa-rc: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] mmc: ushc: " Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] ext4: mark inode dirty after converting inline directory Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] mmc: sdhci: Do not disable interrupts while waiting for clock Jiri Slaby
2017-04-10 12:58 ` [patch added to 3.12-stable] nl80211: fix dumpit error path RTNL deadlocks Jiri Slaby
2017-04-10 12:59 ` Jiri Slaby [this message]
2017-04-10 12:59 ` [patch added to 3.12-stable] xfs: clear _XBF_PAGES from buffers when readahead page Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] block: allow WRITE_SAME commands with the SG_IO ioctl Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] uvcvideo: uvc_scan_fallback() for webcams with broken chain Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] fbcon: Fix vc attr at deinit Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] crypto: algif_hash - avoid zero-sized array Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] virtio_balloon: init 1st buffer in stats vq Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] c6x/ptrace: Remove useless PTRACE_SETREGSET implementation Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] sparc/ptrace: Preserve previous registers for short regset write Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] metag/ptrace: " Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] metag/ptrace: Reject partial NT_METAG_RPIPE writes Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] sched/rt: Add a missing rescheduling point Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] libceph: force GFP_NOIO for socket allocations Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] scsi: mpt3sas: fix hang on ata passthrough commands Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] scsi: libsas: fix ata xfer length Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] ALSA: seq: Fix race during FIFO resize Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] ACPI: Fix incompatibility with mcount-based function graph tracing Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] tty/serial: atmel: fix race condition (TX+DMA) Jiri Slaby
2017-04-10 13:47   ` Richard Genoud
2017-04-10 15:30     ` Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] USB: fix linked-list corruption in rh_call_control() Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] KVM: x86: clear bus pointer when destroyed Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd() Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] MIPS: Lantiq: Fix cascaded IRQ setup Jiri Slaby
2017-04-10 13:07   ` Amit Pundir
2017-04-10 13:09     ` Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: fix reading out alarm Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: make sure all members in the output are set Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: implement reset routine as suggested by the reference Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] rtc: s35390a: improve irq handling Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] KVM: kvm_io_bus_unregister_dev() should never fail Jiri Slaby
2017-04-10 12:59 ` [patch added to 3.12-stable] padata: avoid race in reordering Jiri Slaby

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=20170410125930.26495-23-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=johan@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.