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, Alan Stern <stern@rowland.harvard.edu>,
	David Heinzelmann <heinzelmann.david@gmail.com>,
	Paul Zimmerman <pauldzim@gmail.com>
Subject: [PATCH 4.19 27/97] USB: hub: Dont record a connect-change event during reset-resume
Date: Thu, 27 Feb 2020 14:36:35 +0100	[thread overview]
Message-ID: <20200227132219.039506809@linuxfoundation.org> (raw)
In-Reply-To: <20200227132214.553656188@linuxfoundation.org>

From: Alan Stern <stern@rowland.harvard.edu>

commit 8099f58f1ecddf4f374f4828a3dff8397c7cbd74 upstream.

Paul Zimmerman reports that his USB Bluetooth adapter sometimes
crashes following system resume, when it receives a
Get-Device-Descriptor request while it is busy doing something else.

Such a request was added by commit a4f55d8b8c14 ("usb: hub: Check
device descriptor before resusciation").  It gets sent when the hub
driver's work thread checks whether a connect-change event on an
enabled port really indicates a new device has been connected, as
opposed to an old device momentarily disconnecting and then
reconnecting (which can happen with xHCI host controllers, since they
automatically enable connected ports).

The same kind of thing occurs when a port's power session is lost
during system suspend.  When the system wakes up it sees a
connect-change event on the port, and if the child device's
persist_enabled flag was set then hub_activate() sets the device's
reset_resume flag as well as the port's bit in hub->change_bits.  The
reset-resume code then takes responsibility for checking that the same
device is still attached to the port, and it does this as part of the
device's resume pathway.  By the time the hub driver's work thread
starts up again, the device has already been fully reinitialized and
is busy doing its own thing.  There's no need for the work thread to
do the same check a second time, and in fact this unnecessary check is
what caused the problem that Paul observed.

Note that performing the unnecessary check is not actually a bug.
Devices are supposed to be able to send descriptors back to the host
even when they are busy doing something else.  The underlying cause of
Paul's problem lies in his Bluetooth adapter.  Nevertheless, we
shouldn't perform the same check twice in a row -- and as a nice side
benefit, removing the extra check allows the Bluetooth adapter to work
more reliably.

The work thread performs its check when it sees that the port's bit is
set in hub->change_bits.  In this situation that bit is interpreted as
though a connect-change event had occurred on the port _after_ the
reset-resume, which is not what actually happened.

One possible fix would be to make the reset-resume code clear the
port's bit in hub->change_bits.  But it seems simpler to just avoid
setting the bit during hub_activate() in the first place.  That's what
this patch does.

(Proving that the patch is correct when CONFIG_PM is disabled requires
a little thought.  In that setting hub_activate() will be called only
for initialization and resets, since there won't be any resumes or
reset-resumes.  During initialization and hub resets the hub doesn't
have any child devices, and so this code path never gets executed.)

Reported-and-tested-by: Paul Zimmerman <pauldzim@gmail.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://marc.info/?t=157949360700001&r=1&w=2
CC: David Heinzelmann <heinzelmann.david@gmail.com>
CC: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2001311037460.1577-100000@iolanthe.rowland.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/core/hub.c |    5 -----
 1 file changed, 5 deletions(-)

--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1190,11 +1190,6 @@ static void hub_activate(struct usb_hub
 #ifdef CONFIG_PM
 			udev->reset_resume = 1;
 #endif
-			/* Don't set the change_bits when the device
-			 * was powered off.
-			 */
-			if (test_bit(port1, hub->power_bits))
-				set_bit(port1, hub->change_bits);
 
 		} else {
 			/* The power session is gone; tell hub_wq */



  parent reply	other threads:[~2020-02-27 14:05 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 13:36 [PATCH 4.19 00/97] 4.19.107-stable review Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 01/97] iommu/qcom: Fix bogus detach logic Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 02/97] ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 03/97] ALSA: hda/realtek - Apply quirk for MSI GP63, too Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 04/97] ALSA: hda/realtek - Apply quirk for yet another MSI laptop Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 05/97] ASoC: sun8i-codec: Fix setting DAI data format Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 06/97] ecryptfs: fix a memory leak bug in parse_tag_1_packet() Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 07/97] ecryptfs: fix a memory leak bug in ecryptfs_init_messaging() Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 08/97] thunderbolt: Prevent crash if non-active NVMem file is read Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 09/97] USB: misc: iowarrior: add support for 2 OEMed devices Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 10/97] USB: misc: iowarrior: add support for the 28 and 28L devices Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 11/97] USB: misc: iowarrior: add support for the 100 device Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 12/97] floppy: check FDC index for errors before assigning it Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 13/97] vt: fix scrollback flushing on background consoles Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 14/97] vt: selection, handle pending signals in paste_selection Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 15/97] vt: selection, close sel_buffer race Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 16/97] vt: vt_ioctl: fix race in VT_RESIZEX Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 17/97] staging: android: ashmem: Disallow ashmem memory from being remapped Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 18/97] staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 19/97] xhci: Force Maximum Packet size for Full-speed bulk devices to valid range Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 20/97] xhci: fix runtime pm enabling for quirky Intel hosts Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 21/97] xhci: Fix memory leak when caching protocol extended capability PSI tables - take 2 Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 22/97] usb: host: xhci: update event ring dequeue pointer on purpose Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 23/97] USB: core: add endpoint-blacklist quirk Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 24/97] USB: quirks: blacklist duplicate ep on Sound Devices USBPre2 Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 25/97] usb: uas: fix a plug & unplug racing Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 26/97] USB: Fix novation SourceControl XL after suspend Greg Kroah-Hartman
2020-02-27 13:36 ` Greg Kroah-Hartman [this message]
2020-02-27 13:36 ` [PATCH 4.19 28/97] USB: hub: Fix the broken detection of USB3 device in SMSC hub Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 29/97] usb: dwc2: Fix SET/CLEAR_FEATURE and GET_STATUS flows Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 30/97] usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 31/97] staging: rtl8188eu: Fix potential security hole Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 32/97] staging: rtl8188eu: Fix potential overuse of kernel memory Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 33/97] staging: rtl8723bs: Fix potential security hole Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 34/97] staging: rtl8723bs: Fix potential overuse of kernel memory Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 35/97] powerpc/tm: Fix clearing MSR[TS] in current when reclaiming on signal delivery Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 36/97] jbd2: fix ocfs2 corrupt when clearing block group bits Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 37/97] x86/mce/amd: Publish the bank pointer only after setup has succeeded Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 38/97] x86/mce/amd: Fix kobject lifetime Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 39/97] x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 40/97] serial: 8250: Check UPF_IRQ_SHARED in advance Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 41/97] tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 42/97] tty: serial: imx: setup the correct sg entry for tx dma Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 43/97] serdev: ttyport: restore client ops on deregistration Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 44/97] MAINTAINERS: Update drm/i915 bug filing URL Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 45/97] Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()" Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 46/97] mm/memcontrol.c: lost css_put in memcg_expand_shrinker_maps() Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 47/97] nvme-multipath: Fix memory leak with ana_log_buf Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 48/97] genirq/irqdomain: Make sure all irq domain flags are distinct Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 49/97] mm/vmscan.c: dont round up scan size for online memory cgroup Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 50/97] drm/amdgpu/soc15: fix xclk for raven Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 51/97] xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 52/97] KVM: nVMX: Dont emulate instructions in guest mode Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 53/97] KVM: x86: dont notify userspace IOAPIC on edge-triggered interrupt EOI Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 54/97] tty: serial: qcom_geni_serial: Fix UART hang Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 55/97] tty: serial: qcom_geni_serial: Remove interrupt storm Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 56/97] tty: serial: qcom_geni_serial: Remove use of *_relaxed() and mb() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 57/97] tty: serial: qcom_geni_serial: Remove set_rfr_wm() and related variables Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 58/97] tty: serial: qcom_geni_serial: Remove xfer_mode variable Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 59/97] tty: serial: qcom_geni_serial: Fix RX cancel command failure Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 60/97] lib/stackdepot: Fix outdated comments Greg Kroah-Hartman
2020-02-28 13:05   ` Pavel Machek
2020-02-28 13:24     ` Greg Kroah-Hartman
2020-02-28 13:30       ` Greg Kroah-Hartman
2020-02-28 18:05         ` Sasha Levin
2020-02-27 13:37 ` [PATCH 4.19 61/97] lib/stackdepot.c: fix global out-of-bounds in stack_slabs Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 62/97] drm/nouveau/kms/gv100-: Re-set LUT after clearing for modesets Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 63/97] ext4: fix a data race in EXT4_I(inode)->i_disksize Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 64/97] ext4: add cond_resched() to __ext4_find_entry() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 65/97] ext4: fix potential race between online resizing and write operations Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 66/97] ext4: fix potential race between s_group_info online resizing and access Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 67/97] ext4: fix potential race between s_flex_groups " Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 68/97] ext4: fix mount failure with quota configured as module Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 69/97] ext4: rename s_journal_flag_rwsem to s_writepages_rwsem Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 70/97] ext4: fix race between writepages and enabling EXT4_EXTENTS_FL Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 71/97] KVM: nVMX: Refactor IO bitmap checks into helper function Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 72/97] KVM: nVMX: Check IO instruction VM-exit conditions Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 73/97] KVM: nVMX: handle nested posted interrupts when apicv is disabled for L1 Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 74/97] KVM: apic: avoid calculating pending eoi from an uninitialized val Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 75/97] btrfs: fix bytes_may_use underflow in prealloc error condtition Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 76/97] btrfs: reset fs_root to NULL on error in open_ctree Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 77/97] btrfs: do not check delayed items are empty for single transaction cleanup Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 78/97] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 79/97] Revert "dmaengine: imx-sdma: Fix memory leak" Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 80/97] scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout" Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 81/97] scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session" Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 82/97] usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 83/97] usb: dwc2: Fix in ISOC request length checking Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 84/97] staging: rtl8723bs: fix copy of overlapping memory Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 85/97] staging: greybus: use after free in gb_audio_manager_remove_all() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 86/97] ecryptfs: replace BUG_ON with error handling code Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 87/97] iommu/vt-d: Fix compile warning from intel-svm.h Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 88/97] genirq/proc: Reject invalid affinity masks (again) Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 89/97] bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 90/97] ALSA: rawmidi: Avoid bit fields for state flags Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 91/97] ALSA: seq: Avoid concurrent access to queue flags Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 92/97] ALSA: seq: Fix concurrent access to queue current tick/time Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 93/97] netfilter: xt_hashlimit: limit the max size of hashtable Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 94/97] rxrpc: Fix call RCU cleanup using non-bh-safe locks Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 95/97] ata: ahci: Add shutdown to freeze hardware resources of ahci Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 96/97] xen: Enable interrupts when calling _cond_resched() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 97/97] s390/mm: Explicitly compare PAGE_DEFAULT_KEY against zero in storage_key_init_range Greg Kroah-Hartman
2020-02-27 15:51 ` [PATCH 4.19 00/97] 4.19.107-stable review Chris Paterson
2020-02-28 13:51   ` Greg Kroah-Hartman
     [not found] ` <20200227132214.553656188-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
2020-02-27 18:52   ` Jon Hunter
2020-02-27 18:52     ` Jon Hunter
2020-02-27 19:41 ` Guenter Roeck
2020-02-28  3:35 ` Naresh Kamboju
2020-02-28  3:39 ` shuah

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=20200227132219.039506809@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=heinzelmann.david@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pauldzim@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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.