From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Sarah Sharp <sarah.a.sharp@linux.intel.com>,
Vincent Thiele <vincentthiele@gmail.com>
Subject: [ 10/39] xhci: Avoid NULL pointer deref when host dies.
Date: Fri, 2 Aug 2013 18:18:20 +0800 [thread overview]
Message-ID: <20130802101458.260672812@linuxfoundation.org> (raw)
In-Reply-To: <20130802101456.800497005@linuxfoundation.org>
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarah Sharp <sarah.a.sharp@linux.intel.com>
commit 203a86613fb3bf2767335659513fa98563a3eb71 upstream.
When the host controller fails to respond to an Enable Slot command, and
the host fails to respond to the register write to abort the command
ring, the xHCI driver will assume the host is dead, and call
usb_hc_died().
The USB device's slot_id is still set to zero, and the pointer stored at
xhci->devs[0] will always be NULL. The call to xhci_check_args in
xhci_free_dev should have caught the NULL virt_dev pointer.
However, xhci_free_dev is designed to free the xhci_virt_device
structures, even if the host is dead, so that we don't leak kernel
memory. xhci_free_dev checks the return value from the generic
xhci_check_args function. If the return value is -ENODEV, it carries on
trying to free the virtual device.
The issue is that xhci_check_args looks at the host controller state
before it looks at the xhci_virt_device pointer. It will return -ENIVAL
because the host is dead, and xhci_free_dev will ignore the return
value, and happily dereference the NULL xhci_virt_device pointer.
The fix is to make sure that xhci_check_args checks the xhci_virt_device
pointer before it checks the host state.
See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1203453 for
further details. This patch doesn't solve the underlying issue, but
will ensure we don't see any more NULL pointer dereferences because of
the issue.
This patch should be backported to kernels as old as 3.1, that
contain the commit 7bd89b4017f46a9b92853940fd9771319acb578a "xhci: Don't
submit commands or URBs to halted hosts."
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Reported-by: Vincent Thiele <vincentthiele@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/host/xhci.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1162,9 +1162,6 @@ static int xhci_check_args(struct usb_hc
}
xhci = hcd_to_xhci(hcd);
- if (xhci->xhc_state & XHCI_STATE_HALTED)
- return -ENODEV;
-
if (check_virt_dev) {
if (!udev->slot_id || !xhci->devs[udev->slot_id]) {
printk(KERN_DEBUG "xHCI %s called with unaddressed "
@@ -1180,6 +1177,9 @@ static int xhci_check_args(struct usb_hc
}
}
+ if (xhci->xhc_state & XHCI_STATE_HALTED)
+ return -ENODEV;
+
return 1;
}
next prev parent reply other threads:[~2013-08-02 10:18 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-02 10:18 [ 00/39] 3.4.56-stable review Greg Kroah-Hartman
2013-08-02 10:18 ` [ 01/39] iscsi-target: Fix tfc_tpg_nacl_auth_cit configfs length overflow Greg Kroah-Hartman
2013-08-02 10:18 ` [ 02/39] USB: storage: Add MicroVault Flash Drive to unusual_devs Greg Kroah-Hartman
2013-08-02 10:18 ` [ 03/39] ASoC: max98088 - fix element type of the register cache Greg Kroah-Hartman
2013-08-02 10:18 ` [ 04/39] ASoC: wm8962: Remove remaining direct register cache accesses Greg Kroah-Hartman
2013-08-02 10:18 ` [ 05/39] SCSI: sd: fix crash when UA received on DIF enabled device Greg Kroah-Hartman
2013-08-02 10:18 ` [ 06/39] SCSI: qla2xxx: Properly set the tagging for commands Greg Kroah-Hartman
2013-08-02 10:18 ` [ 07/39] tracing: Fix irqs-off tag display in syscall tracing Greg Kroah-Hartman
2013-08-02 10:18 ` [ 08/39] usb: host: xhci: Enable XHCI_SPURIOUS_SUCCESS for all controllers with xhci 1.0 Greg Kroah-Hartman
2013-08-02 10:18 ` [ 09/39] xhci: fix null pointer dereference on ring_doorbell_for_active_rings Greg Kroah-Hartman
2013-08-02 10:18 ` Greg Kroah-Hartman [this message]
2013-08-02 10:18 ` [ 11/39] usb: dwc3: fix wrong bit mask in dwc3_event_type Greg Kroah-Hartman
2013-08-02 10:18 ` [ 12/39] usb: dwc3: gadget: dont prevent gadget from being probed if we fail Greg Kroah-Hartman
2013-08-02 10:18 ` [ 13/39] USB: ti_usb_3410_5052: fix dynamic-id matching Greg Kroah-Hartman
2013-08-02 10:18 ` [ 14/39] USB: misc: Add Manhattan Hi-Speed USB DVI Converter to sisusbvga Greg Kroah-Hartman
2013-08-02 10:18 ` [ 15/39] usb: Clear both buffers when clearing a control transfer TT buffer Greg Kroah-Hartman
2013-08-02 10:18 ` [ 16/39] staging: comedi: COMEDI_CANCEL ioctl should wake up read/write Greg Kroah-Hartman
2013-08-02 10:18 ` [ 17/39] Btrfs: fix lock leak when resuming snapshot deletion Greg Kroah-Hartman
2013-08-02 10:18 ` [ 18/39] Btrfs: re-add root to dead root list if we stop dropping it Greg Kroah-Hartman
2013-08-02 10:18 ` [ 19/39] xen/blkback: Check device permissions before allowing OP_DISCARD Greg Kroah-Hartman
2013-08-02 10:18 ` [ 20/39] ata: Fix DVD not dectected at some platform with Wellsburg PCH Greg Kroah-Hartman
2013-08-02 10:18 ` [ 21/39] libata: make it clear that sata_inic162x is experimental Greg Kroah-Hartman
2013-08-02 10:18 ` [ 22/39] powerpc/modules: Module CRC relocation fix causes perf issues Greg Kroah-Hartman
2013-08-02 10:18 ` [ 23/39] ACPI / memhotplug: Fix a stale pointer in error path Greg Kroah-Hartman
2013-08-02 10:18 ` [ 24/39] dm verity: fix inability to use a few specific devices sizes Greg Kroah-Hartman
2013-08-02 10:18 ` [ 25/39] drm/radeon: fix endian issues with DP handling (v3) Greg Kroah-Hartman
2013-08-02 10:18 ` [ 26/39] drm/radeon: fix combios tables on older cards Greg Kroah-Hartman
2013-08-02 10:18 ` [ 27/39] drm/radeon: improve dac adjust heuristics for legacy pdac Greg Kroah-Hartman
2013-08-02 10:18 ` [ 28/39] drm/radeon/atom: initialize more atom interpretor elements to 0 Greg Kroah-Hartman
2013-08-02 10:18 ` [ 29/39] USB: serial: ftdi_sio: add more RT Systems ftdi devices Greg Kroah-Hartman
2013-08-02 10:18 ` [ 30/39] livelock avoidance in sget() Greg Kroah-Hartman
2013-08-02 10:18 ` [ 31/39] md/raid5: fix interaction of replace and recovery Greg Kroah-Hartman
2013-08-02 10:18 ` [ 32/39] md/raid10: remove use-after-free bug Greg Kroah-Hartman
2013-08-02 10:18 ` [ 33/39] xen/evtchn: avoid a deadlock when unbinding an event channel Greg Kroah-Hartman
2013-08-02 10:18 ` [ 34/39] firewire: fix libdc1394/FlyCap2 iso event regression Greg Kroah-Hartman
2013-08-02 10:18 ` [ 35/39] [SCSI] zfcp: status read buffers on first adapter open with link down Greg Kroah-Hartman
2013-08-02 10:18 ` [ 36/39] s390: move dummy io_remap_pfn_range() to asm/pgtable.h Greg Kroah-Hartman
2013-08-02 10:18 ` [ 37/39] virtio: support unlocked queue poll Greg Kroah-Hartman
2013-08-02 10:18 ` [ 38/39] virtio_net: fix race in RX VQ processing Greg Kroah-Hartman
2013-08-02 10:18 ` [ 39/39] mm/memory-hotplug: fix lowmem count overflow when offline pages Greg Kroah-Hartman
2013-08-02 19:58 ` [ 00/39] 3.4.56-stable review Shuah Khan
2013-08-03 2:38 ` 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=20130802101458.260672812@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sarah.a.sharp@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=vincentthiele@gmail.com \
/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).