All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Zhengjun Xing <zhengjun.xing@linux.intel.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [PATCH 4.14 08/61] xhci: Fix kernel oops in trace_xhci_free_virt_device
Date: Fri,  6 Jul 2018 07:46:32 +0200	[thread overview]
Message-ID: <20180706054712.649838840@linuxfoundation.org> (raw)
In-Reply-To: <20180706054712.332416244@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zhengjun Xing <zhengjun.xing@linux.intel.com>

commit d850c1658328e757635a46763783c6fd56390dcb upstream.

commit 44a182b9d177 ("xhci: Fix use-after-free in xhci_free_virt_device")
set dev->udev pointer to NULL in xhci_free_dev(), it will cause kernel
panic in trace_xhci_free_virt_device. This patch reimplement the trace
function trace_xhci_free_virt_device, remove dev->udev dereference and
added more useful parameters to show in the trace function,it also makes
sure dev->udev is not NULL before calling trace_xhci_free_virt_device.
This issue happened when xhci-hcd trace is enabled and USB devices hot
plug test. Original use-after-free patch went to stable so this needs so
be applied there as well.

[ 1092.022457] usb 2-4: USB disconnect, device number 6
[ 1092.092772] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
[ 1092.101694] PGD 0 P4D 0
[ 1092.104601] Oops: 0000 [#1] SMP
[ 1092.207734] Workqueue: usb_hub_wq hub_event
[ 1092.212507] RIP: 0010:trace_event_raw_event_xhci_log_virt_dev+0x6c/0xf0
[ 1092.220050] RSP: 0018:ffff8c252e883d28 EFLAGS: 00010086
[ 1092.226024] RAX: ffff8c24af86fa84 RBX: 0000000000000003 RCX: ffff8c25255c2a01
[ 1092.234130] RDX: 0000000000000000 RSI: 00000000aef55009 RDI: ffff8c252e883d28
[ 1092.242242] RBP: ffff8c252550e2c0 R08: ffff8c24af86fa84 R09: 0000000000000a70
[ 1092.250364] R10: 0000000000000a70 R11: 0000000000000000 R12: ffff8c251f21a000
[ 1092.258468] R13: 000000000000000c R14: ffff8c251f21a000 R15: ffff8c251f432f60
[ 1092.266572] FS:  0000000000000000(0000) GS:ffff8c252e880000(0000) knlGS:0000000000000000
[ 1092.275757] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1092.282281] CR2: 0000000000000000 CR3: 0000000154209001 CR4: 00000000003606e0
[ 1092.290384] Call Trace:
[ 1092.293156]  <IRQ>
[ 1092.295439]  xhci_free_virt_device.part.34+0x182/0x1a0
[ 1092.301288]  handle_cmd_completion+0x7ac/0xfa0
[ 1092.306336]  ? trace_event_raw_event_xhci_log_trb+0x6e/0xa0
[ 1092.312661]  xhci_irq+0x3e8/0x1f60
[ 1092.316524]  __handle_irq_event_percpu+0x75/0x180
[ 1092.321876]  handle_irq_event_percpu+0x20/0x50
[ 1092.326922]  handle_irq_event+0x36/0x60
[ 1092.331273]  handle_edge_irq+0x6d/0x180
[ 1092.335644]  handle_irq+0x16/0x20
[ 1092.339417]  do_IRQ+0x41/0xc0
[ 1092.342782]  common_interrupt+0xf/0xf
[ 1092.346955]  </IRQ>

Fixes: 44a182b9d177 ("xhci: Fix use-after-free in xhci_free_virt_device")
Cc: <stable@vger.kernel.org>
Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/host/xhci-mem.c   |    4 ++--
 drivers/usb/host/xhci-trace.h |   36 +++++++++++++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 7 deletions(-)

--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -891,12 +891,12 @@ void xhci_free_virt_device(struct xhci_h
 
 	dev = xhci->devs[slot_id];
 
-	trace_xhci_free_virt_device(dev);
-
 	xhci->dcbaa->dev_context_ptrs[slot_id] = 0;
 	if (!dev)
 		return;
 
+	trace_xhci_free_virt_device(dev);
+
 	if (dev->tt_info)
 		old_active_eps = dev->tt_info->active_eps;
 
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -158,6 +158,37 @@ DEFINE_EVENT(xhci_log_trb, xhci_queue_tr
 	TP_ARGS(ring, trb)
 );
 
+DECLARE_EVENT_CLASS(xhci_log_free_virt_dev,
+	TP_PROTO(struct xhci_virt_device *vdev),
+	TP_ARGS(vdev),
+	TP_STRUCT__entry(
+		__field(void *, vdev)
+		__field(unsigned long long, out_ctx)
+		__field(unsigned long long, in_ctx)
+		__field(u8, fake_port)
+		__field(u8, real_port)
+		__field(u16, current_mel)
+
+	),
+	TP_fast_assign(
+		__entry->vdev = vdev;
+		__entry->in_ctx = (unsigned long long) vdev->in_ctx->dma;
+		__entry->out_ctx = (unsigned long long) vdev->out_ctx->dma;
+		__entry->fake_port = (u8) vdev->fake_port;
+		__entry->real_port = (u8) vdev->real_port;
+		__entry->current_mel = (u16) vdev->current_mel;
+		),
+	TP_printk("vdev %p ctx %llx | %llx fake_port %d real_port %d current_mel %d",
+		__entry->vdev, __entry->in_ctx, __entry->out_ctx,
+		__entry->fake_port, __entry->real_port, __entry->current_mel
+	)
+);
+
+DEFINE_EVENT(xhci_log_free_virt_dev, xhci_free_virt_device,
+	TP_PROTO(struct xhci_virt_device *vdev),
+	TP_ARGS(vdev)
+);
+
 DECLARE_EVENT_CLASS(xhci_log_virt_dev,
 	TP_PROTO(struct xhci_virt_device *vdev),
 	TP_ARGS(vdev),
@@ -194,11 +225,6 @@ DEFINE_EVENT(xhci_log_virt_dev, xhci_all
 	TP_PROTO(struct xhci_virt_device *vdev),
 	TP_ARGS(vdev)
 );
-
-DEFINE_EVENT(xhci_log_virt_dev, xhci_free_virt_device,
-	TP_PROTO(struct xhci_virt_device *vdev),
-	TP_ARGS(vdev)
-);
 
 DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device,
 	TP_PROTO(struct xhci_virt_device *vdev),



  parent reply	other threads:[~2018-07-06  5:52 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06  5:46 [PATCH 4.14 00/61] 4.14.54-stable review Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 01/61] usb: cdc_acm: Add quirk for Uniden UBC125 scanner Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 02/61] USB: serial: cp210x: add CESINEL device ids Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 03/61] USB: serial: cp210x: add Silicon Labs IDs for Windows Update Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 04/61] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 05/61] acpi: Add helper for deactivating memory region Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 06/61] usb: typec: ucsi: acpi: Workaround for cache mode issue Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 07/61] usb: typec: ucsi: Fix for incorrect status data issue Greg Kroah-Hartman
2018-07-06  5:46 ` Greg Kroah-Hartman [this message]
2018-07-06  5:46 ` [PATCH 4.14 09/61] n_tty: Fix stall at n_tty_receive_char_special() Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 10/61] n_tty: Access echo_* variables carefully Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 11/61] staging: android: ion: Return an ERR_PTR in ion_map_kernel Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 12/61] serial: 8250_pci: Remove stalled entries in blacklist Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 13/61] serdev: fix memleak on module unload Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 14/61] vt: prevent leaking uninitialized data to userspace via /dev/vcs* Greg Kroah-Hartman
2018-07-06  5:52   ` syzbot
2018-07-06  5:46 ` [PATCH 4.14 18/61] drm/qxl: Call qxl_bo_unref outside atomic context Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 19/61] drm/atmel-hlcdc: check stride values in the first plane Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 22/61] drm/i915: Enable provoking vertex fix on Gen9 systems Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 23/61] netfilter: nf_tables: nft_compat: fix refcount leak on xt module Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 24/61] netfilter: nft_compat: prepare for indirect info storage Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 25/61] netfilter: nft_compat: fix handling of large matchinfo size Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 26/61] netfilter: nf_tables: dont assume chain stats are set when jumplabel is set Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 27/61] netfilter: nf_tables: bogus EBUSY in chain deletions Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 28/61] netfilter: nft_meta: fix wrong value dereference in nft_meta_set_eval Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 29/61] netfilter: nf_tables: disable preemption in nft_update_chain_stats() Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 30/61] netfilter: nf_tables: increase nft_counters_enabled in nft_chain_stats_replace() Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 31/61] netfilter: nf_tables: fix memory leak on error exit return Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 32/61] netfilter: nf_tables: add missing netlink attrs to policies Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 33/61] netfilter: nf_tables: fix NULL-ptr in nf_tables_dump_obj() Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 34/61] md: always hold reconfig_mutex when calling mddev_suspend() Greg Kroah-Hartman
2018-07-06  5:46 ` [PATCH 4.14 35/61] md: dont call bitmap_create() while array is quiesced Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 36/61] md: move suspend_hi/lo handling into core md code Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 37/61] md: use mddev_suspend/resume instead of ->quiesce() Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 38/61] md: allow metadata update while suspending Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 39/61] md: remove special meaning of ->quiesce(.., 2) Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 40/61] netfilter: dont set F_IFACE on ipv6 fib lookups Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 41/61] netfilter: ip6t_rpfilter: provide input interface for route lookup Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 42/61] netfilter: nf_tables: use WARN_ON_ONCE instead of BUG_ON in nft_do_chain() Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 43/61] ARM: dts: imx6q: Use correct SDMA script for SPI5 core Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 44/61] mtd: rawnand: fix return value check for bad block status Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 46/61] afs: Fix directory permissions check Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 47/61] netfilter: ebtables: handle string from userspace with care Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 48/61] s390/dasd: use blk_mq_rq_from_pdu for per request data Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 49/61] netfilter: nft_limit: fix packet ratelimiting Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 50/61] ipvs: fix buffer overflow with sync daemon and service Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 51/61] iwlwifi: pcie: compare with number of IRQs requested for, not number of CPUs Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 52/61] atm: zatm: fix memcmp casting Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 54/61] perf test: "Session topology" dumps core on s390 Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 55/61] perf bpf: Fix NULL return handling in bpf__prepare_load() Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 56/61] fs: clear writeback errors in inode_init_always Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 57/61] sched/core: Fix rules for running on online && !active CPUs Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 58/61] sched/core: Require cpu_active() in select_task_rq(), for user tasks Greg Kroah-Hartman
2018-07-06  5:47 ` [PATCH 4.14 60/61] net/sonic: Use dma_mapping_error() Greg Kroah-Hartman
2018-07-06 17:54 ` [PATCH 4.14 00/61] 4.14.54-stable review Dan Rue
2018-07-07 21:39 ` Guenter Roeck
2018-07-08 13:29   ` Greg Kroah-Hartman
2018-07-09 13:28     ` 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=20180706054712.649838840@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=zhengjun.xing@linux.intel.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 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.