From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Soeren Moch <smoch@web.de>,
Alan Stern <stern@rowland.harvard.edu>
Subject: [ 042/124] USB: EHCI: fix bug in iTD/siTD DMA pool allocation
Date: Tue, 2 Apr 2013 15:10:24 -0700 [thread overview]
Message-ID: <20130402221109.089283689@linuxfoundation.org> (raw)
In-Reply-To: <20130402221104.163133110@linuxfoundation.org>
3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Soeren Moch <smoch@web.de>
commit 85ecd0322b9a1a9f451d9150e9460ab42fd17219 upstream.
[Description written by Alan Stern]
Soeren tracked down a very difficult bug in ehci-hcd's DMA pool
management of iTD and siTD structures. Some background: ehci-hcd
gives each isochronous endpoint its own set of active and free itd's
(or sitd's for full-speed devices). When a new itd is needed, it is
taken from the head of the free list, if possible. However, itd's
must not be used twice in a single frame because the hardware
continues to access the data structure for the entire duration of a
frame. Therefore if the itd at the head of the free list has its
"frame" member equal to the current value of ehci->now_frame, it
cannot be reused and instead a new itd is allocated from the DMA pool.
The entries on the free list are not released back to the pool until
the endpoint is no longer in use.
The bug arises from the fact that sometimes an itd can be moved back
onto the free list before itd->frame has been set properly. In
Soeren's case, this happened because ehci-hcd can allocate one more
itd than it actually needs for an URB; the extra itd may or may not be
required depending on how the transfer aligns with a frame boundary.
For example, an URB with 8 isochronous packets will cause two itd's to
be allocated. If the URB is scheduled to start in microframe 3 of
frame N then it will require both itds: one for microframes 3 - 7 of
frame N and one for microframes 0 - 2 of frame N+1. But if the URB
had been scheduled to start in microframe 0 then it would require only
the first itd, which could cover microframes 0 - 7 of frame N. The
second itd would be returned to the end of the free list.
The itd allocation routine initializes the entire structure to 0, so
the extra itd ends up on the free list with itd->frame set to 0
instead of a meaningful value. After a while the itd reaches the head
of the list, and occasionally this happens when ehci->now_frame is
equal to 0. Then, even though it would be okay to reuse this itd, the
driver thinks it must get another itd from the DMA pool.
For as long as the isochronous endpoint remains in use, this flaw in
the mechanism causes more and more itd's to be taken slowly from the
DMA pool. Since none are released back, the pool eventually becomes
exhausted.
This reuslts in memory allocation failures, which typically show up
during a long-running audio stream. Video might suffer the same
effect.
The fix is very simple. To prevent allocations from the pool when
they aren't needed, make sure that itd's sent back to the free list
prematurely have itd->frame set to an invalid value which can never be
equal to ehci->now_frame.
This should be applied to -stable kernels going back to 3.6.
Signed-off-by: Soeren Moch <smoch@web.de>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/host/ehci-sched.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1214,6 +1214,7 @@ itd_urb_transaction (
memset (itd, 0, sizeof *itd);
itd->itd_dma = itd_dma;
+ itd->frame = 9999; /* an invalid value */
list_add (&itd->itd_list, &sched->td_list);
}
spin_unlock_irqrestore (&ehci->lock, flags);
@@ -1915,6 +1916,7 @@ sitd_urb_transaction (
memset (sitd, 0, sizeof *sitd);
sitd->sitd_dma = sitd_dma;
+ sitd->frame = 9999; /* an invalid value */
list_add (&sitd->sitd_list, &iso_sched->td_list);
}
next prev parent reply other threads:[~2013-04-02 23:13 UTC|newest]
Thread overview: 157+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 22:09 [ 000/124] 3.8.6-stable review Greg Kroah-Hartman
2013-04-02 22:09 ` [ 001/124] SUNRPC: Add barriers to ensure read ordering in rpc_wake_up_task_queue_locked Greg Kroah-Hartman
2013-04-02 22:09 ` [ 002/124] tile: expect new initramfs name from hypervisor file system Greg Kroah-Hartman
2013-04-02 22:09 ` [ 003/124] Bluetooth: Fix not closing SCO sockets in the BT_CONNECT2 state Greg Kroah-Hartman
2013-04-02 22:09 ` [ 004/124] Bluetooth: Add support for Dell[QCA 0cf3:0036] Greg Kroah-Hartman
2013-04-02 22:09 ` [ 005/124] Bluetooth: Add support for Dell[QCA 0cf3:817a] Greg Kroah-Hartman
2013-04-02 22:09 ` [ 006/124] staging: comedi: s626: fix continuous acquisition Greg Kroah-Hartman
2013-04-02 22:09 ` [ 007/124] Revert "crypto: talitos - add IPsec ESN support" Greg Kroah-Hartman
2013-04-02 22:09 ` [ 008/124] Revert "crypto: caam " Greg Kroah-Hartman
2013-04-02 22:09 ` [ 009/124] sysfs: fix race between readdir and lseek Greg Kroah-Hartman
2013-04-02 22:09 ` [ 010/124] sysfs: handle failure path correctly for readdir() Greg Kroah-Hartman
2013-04-02 22:09 ` [ 011/124] can: sja1000: fix define conflict on SH Greg Kroah-Hartman
2013-04-02 22:09 ` [ 012/124] ath9k_hw: revert chainmask to user configuration after calibration Greg Kroah-Hartman
2013-04-02 22:09 ` [ 013/124] ath9k: limit tx path hang check to normal data queues Greg Kroah-Hartman
2013-04-02 22:09 ` [ 014/124] ath9k: avoid queueing hw check work when suspended Greg Kroah-Hartman
2013-04-02 22:09 ` [ 015/124] HID: usbhid: quirk for Realtek Multi-card reader Greg Kroah-Hartman
2013-04-02 22:09 ` [ 016/124] HID: usbhid: quirk for MSI GX680R led panel Greg Kroah-Hartman
2013-04-02 22:09 ` [ 017/124] HID: usbhid: fix build problem Greg Kroah-Hartman
2013-04-02 22:10 ` [ 018/124] rtlwifi: usb: add missing freeing of skbuff Greg Kroah-Hartman
2013-04-02 22:10 ` [ 019/124] iwlwifi: fix length check in multi-TB HCMD Greg Kroah-Hartman
2013-04-02 22:10 ` [ 020/124] b43: N-PHY: increase initial value of "mind" in RSSI calibration Greg Kroah-Hartman
2013-04-02 22:10 ` [ 021/124] b43: A fix for DMA transmission sequence errors Greg Kroah-Hartman
2013-04-02 22:10 ` [ 022/124] b43: N-PHY: use more bits for offset in RSSI calibration Greg Kroah-Hartman
2013-04-02 22:10 ` [ 023/124] tg3: fix length overflow in VPD firmware parsing Greg Kroah-Hartman
2013-04-02 22:10 ` [ 024/124] mac80211: always synchronize_net() during station removal Greg Kroah-Hartman
2013-04-02 22:10 ` [ 025/124] iommu/amd: Make sure dma_ops are set for hotplug devices Greg Kroah-Hartman
2013-04-02 22:10 ` [ 026/124] xen-pciback: notify hypervisor about devices intended to be assigned to guests Greg Kroah-Hartman
2013-04-02 22:10 ` [ 027/124] xen/blkback: correctly respond to unknown, non-native requests Greg Kroah-Hartman
2013-04-02 22:10 ` [ 028/124] xen-blkback: fix dispatch_rw_block_io() error path Greg Kroah-Hartman
2013-04-02 22:10 ` [ 029/124] xen-blkfront: switch from llist to list Greg Kroah-Hartman
2013-04-02 22:10 ` [ 030/124] tty: atmel_serial_probe(): index of atmel_ports[] fix Greg Kroah-Hartman
2013-04-02 22:10 ` [ 031/124] usb: ftdi_sio: Add support for Mitsubishi FX-USB-AW/-BD Greg Kroah-Hartman
2013-04-02 22:10 ` [ 032/124] vt: synchronize_rcu() under spinlock is not nice Greg Kroah-Hartman
2013-04-02 22:10 ` [ 033/124] mwifiex: fix race when queuing commands Greg Kroah-Hartman
2013-04-02 22:10 ` [ 034/124] mwifiex: skip pending commands after function shutdown Greg Kroah-Hartman
2013-04-02 22:10 ` [ 035/124] mwifiex: cancel cmd timer and free curr_cmd in shutdown process Greg Kroah-Hartman
2013-04-02 22:10 ` [ 036/124] pnfs-block: removing DM device maybe cause oops when call dev_remove Greg Kroah-Hartman
2013-04-02 22:10 ` [ 037/124] NFSv4: Fix the string length returned by the idmapper Greg Kroah-Hartman
2013-04-02 22:10 ` [ 038/124] NFSv4.1: Fix a race in pNFS layoutcommit Greg Kroah-Hartman
2013-04-02 22:10 ` [ 039/124] NFSv4.1: Always clear the NFS_INO_LAYOUTCOMMIT in layoutreturn Greg Kroah-Hartman
2013-04-02 22:10 ` [ 040/124] net/irda: add missing error path release_sock call Greg Kroah-Hartman
2013-04-02 22:10 ` [ 041/124] Nest rename_lock inside vfsmount_lock Greg Kroah-Hartman
2013-04-02 22:10 ` Greg Kroah-Hartman [this message]
2013-04-02 22:10 ` [ 043/124] usb: xhci: Fix TRB transfer length macro used for Event TRB Greg Kroah-Hartman
2013-04-02 22:10 ` [ 044/124] target: Fix RESERVATION_CONFLICT status regression for iscsi-target special case Greg Kroah-Hartman
2013-04-02 22:10 ` [ 045/124] media: [REGRESSION] bt8xx: Fix too large height in cropcap Greg Kroah-Hartman
2013-04-02 22:10 ` [ 046/124] mac80211: prevent spurious HT/VHT downgrade message Greg Kroah-Hartman
2013-04-02 22:10 ` [ 047/124] scm: Require CAP_SYS_ADMIN over the current pidns to spoof pids Greg Kroah-Hartman
2013-04-02 22:10 ` [ 048/124] pid: Handle the exit of a multi-threaded init Greg Kroah-Hartman
2013-04-02 22:10 ` [ 049/124] userns: Dont allow creation if the user is chrooted Greg Kroah-Hartman
2013-04-02 22:10 ` [ 050/124] vfs: Add a mount flag to lock read only bind mounts Greg Kroah-Hartman
2013-04-02 22:10 ` [ 051/124] vfs: Carefully propogate mounts across user namespaces Greg Kroah-Hartman
2013-04-02 22:10 ` [ 052/124] ipc: Restrict mounting the mqueue filesystem Greg Kroah-Hartman
2013-04-02 22:10 ` [ 053/124] userns: Restrict when proc and sysfs can be mounted Greg Kroah-Hartman
2013-04-02 22:10 ` [ 054/124] Btrfs: use set_nlink if our i_nlink is 0 Greg Kroah-Hartman
2013-04-02 22:10 ` [ 055/124] Btrfs: fix locking on ROOT_REPLACE operations in tree mod log Greg Kroah-Hartman
2013-04-02 22:10 ` [ 056/124] Btrfs: fix race between mmap writes and compression Greg Kroah-Hartman
2013-04-02 22:10 ` [ 057/124] Btrfs: limit the global reserve to 512mb Greg Kroah-Hartman
2013-04-02 22:10 ` [ 058/124] Btrfs: dont drop path when printing out tree errors in scrub Greg Kroah-Hartman
2013-04-02 22:10 ` [ 059/124] USB: serial: add modem-status-change wait queue Greg Kroah-Hartman
2013-04-02 22:10 ` [ 060/124] USB: serial: fix hang when opening port Greg Kroah-Hartman
2013-04-02 22:10 ` [ 061/124] USB: quatech2: fix use-after-free in TIOCMIWAIT Greg Kroah-Hartman
2013-04-02 22:10 ` [ 062/124] USB: mos7840: fix broken TIOCMIWAIT Greg Kroah-Hartman
2013-04-02 22:10 ` [ 063/124] USB: io_ti: fix use-after-free in TIOCMIWAIT Greg Kroah-Hartman
2013-04-02 22:10 ` [ 064/124] USB: oti6858: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 065/124] USB: ftdi_sio: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 066/124] USB: pl2303: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 067/124] USB: mos7840: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 068/124] USB: spcp8x5: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 069/124] USB: ssu100: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 070/124] USB: ch341: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 071/124] USB: io_edgeport: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 072/124] USB: f81232: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 073/124] USB: ark3116: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 074/124] USB: mct_u232: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 075/124] USB: cypress_m8: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 076/124] USB: ti_usb_3410_5052: " Greg Kroah-Hartman
2013-04-02 22:10 ` [ 077/124] usb: gadget: udc-core: fix a regression during gadget driver unbinding Greg Kroah-Hartman
2013-04-02 22:11 ` [ 078/124] signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer Greg Kroah-Hartman
2013-04-02 22:11 ` [ 079/124] kernel/signal.c: use __ARCH_HAS_SA_RESTORER instead of SA_RESTORER Greg Kroah-Hartman
2013-04-02 22:11 ` [ 080/124] loop: prevent bdev freeing while device in use Greg Kroah-Hartman
2013-04-02 22:11 ` [ 081/124] ARM: cns3xxx: fix mapping of private memory region Greg Kroah-Hartman
2013-04-02 22:11 ` [ 082/124] ARM: imx: fix sync issue between imx_cpu_die and imx_cpu_kill Greg Kroah-Hartman
2013-04-02 22:11 ` [ 083/124] ARM: kirkwood: Fix chip-delay for GoFlex Net Greg Kroah-Hartman
2013-04-02 22:11 ` [ 084/124] ARM: OMAP: clocks: Delay clk inits atleast until slab is initialized Greg Kroah-Hartman
2013-04-02 22:11 ` [ 085/124] virtio: console: rename cvq_lock to c_ivq_lock Greg Kroah-Hartman
2013-04-02 22:11 ` [ 086/124] virtio: console: add locking around c_ovq operations Greg Kroah-Hartman
2013-04-02 22:11 ` [ 087/124] nfsd4: reject "negative" acl lengths Greg Kroah-Hartman
2013-04-02 22:11 ` [ 088/124] drm/i915: Use the fixed pixel clock for eDP in intel_dp_set_m_n() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 089/124] drm/i915: Dont clobber crtc->fb when queue_flip fails Greg Kroah-Hartman
2013-04-02 22:11 ` [ 090/124] iwlwifi: dvm: dont send HCMD in restart flow Greg Kroah-Hartman
2013-04-02 22:11 ` [ 091/124] Btrfs: fix space leak when we fail to reserve metadata space Greg Kroah-Hartman
2013-04-02 22:11 ` [ 092/124] xen/events: avoid race with raising an event in unmask_evtchn() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 093/124] tracing: Prevent buffer overwrite disabled for latency tracers Greg Kroah-Hartman
2013-04-02 22:11 ` [ 094/124] efivars: explicitly calculate length of VariableName Greg Kroah-Hartman
2013-04-02 22:11 ` [ 095/124] efivars: Handle duplicate names from get_next_variable() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 096/124] regulator: Fix memory garbage dev_err printout Greg Kroah-Hartman
2013-04-02 22:11 ` [ 097/124] net: remove a WARN_ON() in net_enable_timestamp() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 098/124] sky2: Receive Overflows not counted Greg Kroah-Hartman
2013-04-02 22:11 ` [ 099/124] sky2: Threshold for Pause Packet is set wrong Greg Kroah-Hartman
2013-04-02 22:11 ` [ 100/124] tcp: preserve ACK clocking in TSO Greg Kroah-Hartman
2013-04-02 22:11 ` [ 101/124] tcp: undo spurious timeout after SACK reneging Greg Kroah-Hartman
2013-04-02 22:11 ` [ 102/124] 8021q: fix a potential use-after-free Greg Kroah-Hartman
2013-04-02 22:11 ` [ 103/124] thermal: shorten too long mcast group name Greg Kroah-Hartman
2013-04-02 22:11 ` [ 104/124] unix: fix a race condition in unix_release() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL Greg Kroah-Hartman
2013-04-03 11:41 ` Sven Joachim
2013-04-03 14:00 ` Eric Dumazet
2013-04-03 15:10 ` Sven Joachim
2013-04-03 15:27 ` Greg Kroah-Hartman
2013-04-03 19:11 ` Stefan Lippers-Hollmann
2013-04-03 15:35 ` Eric Dumazet
2013-04-03 17:58 ` Andy Lutomirski
2013-04-03 18:43 ` Eric Dumazet
2013-04-03 19:01 ` Andy Lutomirski
2013-04-04 0:14 ` Eric W. Biederman
2013-04-04 0:05 ` Eric W. Biederman
2013-04-04 0:19 ` Eric Dumazet
2013-04-04 0:30 ` Eric Dumazet
2013-04-04 1:01 ` Eric W. Biederman
2013-04-04 2:13 ` [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" Eric W. Biederman
2013-04-04 2:14 ` [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages Eric W. Biederman
2013-04-04 3:28 ` [PATCH 3/2] scm: Stop passing struct cred Eric W. Biederman
2013-04-05 4:47 ` David Miller
2013-04-04 7:56 ` [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages dingtianhong
2013-04-04 10:36 ` Eric W. Biederman
2013-04-05 4:47 ` David Miller
2013-04-04 7:51 ` [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" dingtianhong
2013-04-04 10:22 ` Eric W. Biederman
2013-04-05 4:47 ` David Miller
2013-04-04 0:47 ` [ 105/124] af_unix: dont send SCM_CREDENTIAL when dest socket is NULL Eric W. Biederman
2013-04-04 0:53 ` Andy Lutomirski
2013-04-04 2:24 ` Eric W. Biederman
2013-04-05 4:47 ` David Miller
2013-04-05 16:24 ` Greg KH
2013-04-07 21:17 ` Ben Hutchings
2013-04-02 22:11 ` [ 106/124] bonding: remove already created master sysfs link on failure Greg Kroah-Hartman
2013-04-02 22:11 ` [ 107/124] bonding: fix disabling of arp_interval and miimon Greg Kroah-Hartman
2013-04-02 22:11 ` [ 108/124] drivers: net: ethernet: davinci_emac: use netif_wake_queue() while restarting tx queue Greg Kroah-Hartman
2013-04-02 22:11 ` [ 109/124] drivers: net: ethernet: cpsw: " Greg Kroah-Hartman
2013-04-02 22:11 ` [ 110/124] net: fix *_DIAG_MAX constants Greg Kroah-Hartman
2013-04-02 22:11 ` [ 111/124] aoe: reserve enough headroom on skbs Greg Kroah-Hartman
2013-04-02 22:11 ` [ 112/124] atl1e: drop pci-msi support because of packet corruption Greg Kroah-Hartman
2013-04-02 22:11 ` [ 113/124] DM9000B: driver initialization upgrade Greg Kroah-Hartman
2013-04-02 22:11 ` [ 114/124] fec: Fix the build as module Greg Kroah-Hartman
2013-04-02 22:11 ` [ 115/124] ipv6: fix bad free of addrconf_init_net Greg Kroah-Hartman
2013-04-02 22:11 ` [ 116/124] ipv6: dont accept multicast traffic with scope 0 Greg Kroah-Hartman
2013-04-02 22:11 ` [ 117/124] ipv6: dont accept node local multicast traffic from the wire Greg Kroah-Hartman
2013-04-02 22:11 ` [ 118/124] ks8851: Fix interpretation of rxlen field Greg Kroah-Hartman
2013-04-02 22:11 ` [ 119/124] net: add a synchronize_net() in netdev_rx_handler_unregister() Greg Kroah-Hartman
2013-04-02 22:11 ` [ 120/124] net: ethernet: cpsw: fix erroneous condition in error check Greg Kroah-Hartman
2013-04-02 22:11 ` [ 121/124] net: fix the use of this_cpu_ptr Greg Kroah-Hartman
2013-04-02 22:11 ` [ 122/124] net: fq_codel: Fix off-by-one error Greg Kroah-Hartman
2013-04-02 22:11 ` [ 123/124] pch_gbe: fix ip_summed checksum reporting on rx Greg Kroah-Hartman
2013-04-02 22:11 ` [ 124/124] smsc75xx: fix jumbo frame support Greg Kroah-Hartman
2013-04-03 15:17 ` [ 000/124] 3.8.6-stable review Shuah Khan
2013-04-03 15:28 ` Greg Kroah-Hartman
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=20130402221109.089283689@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=smoch@web.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox