public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	Chris Wedgwood <reviews@ml.cw.f00f.org>,
	Michael Krufky <mkrufky@linuxtv.org>,
	Chuck Ebbert <cebbert@redhat.com>,
	Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
	Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
	Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Brandon Philips <bphilips@suse.de>,
	Oliver Neukum <oliver@neukum.org>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [patch 38/46] USB: cdc-acm.c: fix recursive lock in acm_start_wb error path
Date: Sun, 16 Nov 2008 23:16:51 -0800	[thread overview]
Message-ID: <20081117071651.GM29522@kroah.com> (raw)
In-Reply-To: <20081117071333.GA29522@kroah.com>

[-- Attachment #1: usb-cdc-acm.c-fix-recursive-lock-in-acm_start_wb-error-path.patch --]
[-- Type: text/plain, Size: 2998 bytes --]

2.6.27-stable review patch.  If anyone has any objections, please let us know.

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

From: Brandon Philips <brandon@ifup.org>

commit ad0b65efd12d020b046cde8d6f474e37bb98dd73 upstream.

Fixes an obvious bug in cdc-acm by avoiding a recursive lock on
acm_start_wb()'s error path. Should apply towards 2.6.27 stable and
2.6.28.

=============================================
[ INFO: possible recursive locking detected ]
2.6.27-2-pae #109
---------------------------------------------
python/31449 is trying to acquire lock:
 (&acm->write_lock){++..}, at: [<f89a0348>] acm_start_wb+0x5c/0x7b [cdc_acm]

but task is already holding lock:
 (&acm->write_lock){++..}, at: [<f89a04fb>] acm_tty_write+0xe1/0x167 [cdc_acm]

other info that might help us debug this:
2 locks held by python/31449:
 #0:  (&tty->atomic_write_lock){--..}, at: [<c0260fae>] tty_write_lock+0x14/0x3b
 #1:  (&acm->write_lock){++..}, at: [<f89a04fb>] acm_tty_write+0xe1/0x167 [cdc_acm]

stack backtrace:
Pid: 31449, comm: python Not tainted 2.6.27-2-pae #109
 [<c030f42f>] ? printk+0xf/0x18
 [<c0149f33>] __lock_acquire+0xc7b/0x1316
 [<c014a63e>] lock_acquire+0x70/0x97
 [<f89a0348>] ? acm_start_wb+0x5c/0x7b [cdc_acm]
 [<c0312109>] _spin_lock_irqsave+0x37/0x47
 [<f89a0348>] ? acm_start_wb+0x5c/0x7b [cdc_acm]
 [<f89a0348>] acm_start_wb+0x5c/0x7b [cdc_acm]
 [<f89a055d>] acm_tty_write+0x143/0x167 [cdc_acm]
 [<c0262a98>] write_chan+0x1cd/0x297
 [<c012527e>] ? default_wake_function+0x0/0xd
 [<c026111e>] tty_write+0x149/0x1b9
 [<c02628cb>] ? write_chan+0x0/0x297
 [<c01912c5>] ? rw_verify_area+0x76/0x98
 [<c0260fd5>] ? tty_write+0x0/0x1b9
 [<c01919ba>] vfs_write+0x8c/0x136
 [<c0191afd>] sys_write+0x3b/0x60
 [<c0103beb>] sysenter_do_call+0x12/0x3f
 =======================

Signed-off-by: Brandon Philips <bphilips@suse.de>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/class/cdc-acm.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -158,16 +158,12 @@ static int acm_wb_is_avail(struct acm *a
 }
 
 /*
- * Finish write.
+ * Finish write. Caller must hold acm->write_lock
  */
 static void acm_write_done(struct acm *acm, struct acm_wb *wb)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&acm->write_lock, flags);
 	wb->use = 0;
 	acm->transmitting--;
-	spin_unlock_irqrestore(&acm->write_lock, flags);
 }
 
 /*
@@ -482,6 +478,7 @@ static void acm_write_bulk(struct urb *u
 {
 	struct acm_wb *wb = urb->context;
 	struct acm *acm = wb->instance;
+	unsigned long flags;
 
 	if (verbose || urb->status
 			|| (urb->actual_length != urb->transfer_buffer_length))
@@ -490,7 +487,9 @@ static void acm_write_bulk(struct urb *u
 			urb->transfer_buffer_length,
 			urb->status);
 
+	spin_lock_irqsave(&acm->write_lock, flags);
 	acm_write_done(acm, wb);
+	spin_unlock_irqrestore(&acm->write_lock, flags);
 	if (ACM_READY(acm))
 		schedule_work(&acm->work);
 	else

-- 

  parent reply	other threads:[~2008-11-17  7:38 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20081117070621.430169021@blue.kroah.org>
2008-11-17  7:13 ` [patch 00/46] 2.6.27.7-stable review Greg KH
2008-11-17  7:14   ` [patch 01/46] touch_mnt_namespace when the mount flags change Greg KH
2008-11-17  7:14   ` [patch 02/46] iwlagn: avoid sleep in softirq context Greg KH
2008-11-17  7:14   ` [patch 03/46] ath5k: fix suspend-related oops on rmmod Greg KH
2008-11-17  7:14   ` [patch 04/46] ath5k: Fix reset sequence for AR5212 in general and RF5111 in particular Greg KH
2008-11-17  7:14   ` [patch 05/46] bnx2x: Removing the PMF indication when unloading Greg KH
2008-11-17  7:14   ` [patch 06/46] bnx2x: PCI configuration bug on big-endian Greg KH
2008-11-17  7:14   ` [patch 07/46] bnx2x: Calling netif_carrier_off at the end of the probe Greg KH
2008-11-17  7:14   ` [patch 08/46] ARM: 5329/1: Feroceon: fix feroceon_l2_inv_range Greg KH
2008-11-17  7:14   ` [patch 09/46] Fix platform drivers that crash on suspend/resume Greg KH
2008-11-17  7:14   ` [patch 10/46] hostap: pad the skb->cb usage in lieu of a proper fix Greg KH
2008-11-17  7:14   ` [patch 11/46] ACPI: avoid empty file name in sysfs Greg KH
2008-11-17  7:14   ` [patch 12/46] ACPI: EC: make kernel messages more useful when GPE storm is detected Greg KH
2008-11-17  7:15   ` [patch 13/46] hugetlb: make unmap_ref_private multi-size-aware Greg KH
2008-11-17  7:15   ` [patch 14/46] rtl8187: Add Abocom USB ID Greg KH
2008-11-17  7:15   ` [patch 15/46] rtl8187 : support for Sitecom WL-168 0001 v4 Greg KH
2008-11-17  7:15   ` [patch 16/46] kbuild: Fixup deb-pkg target to generate separate firmware deb Greg KH
2008-11-17  7:15   ` [patch 17/46] block: fix nr_phys_segments miscalculation bug Greg KH
2008-11-17  7:15   ` [patch 18/46] powerpc/mpic: Fix regression caused by change of default IRQ affinity Greg KH
2008-11-17  7:15   ` [patch 19/46] Input: ALPS - add signature for DualPoint found in Dell Latitude E6500 Greg KH
2008-11-17  7:15   ` [patch 20/46] memory hotplug: fix page_zone() calculation in test_pages_isolated() Greg KH
2008-11-17  7:15   ` [patch 21/46] r8169: select MII in Kconfig Greg KH
2008-11-17  7:15   ` [patch 22/46] sony-laptop: ignore missing _DIS method on pic device Greg KH
2008-11-17  7:15   ` [patch 23/46] net: fix /proc/net/snmp as memory corruptor Greg KH
2008-11-17  7:15   ` [patch 24/46] Fix broken ownership of /proc/sys/ files Greg KH
2008-11-17 20:09     ` Theodore Tso
2008-11-17 21:35       ` [stable] " Greg KH
2008-11-17 22:25         ` Rafael J. Wysocki
2008-11-17 23:45           ` Peter Palfrader
2008-11-17  7:15   ` [patch 25/46] V4L/DVB (9624): CVE-2008-5033: fix OOPS on tvaudio when controlling bass/treble Greg KH
2008-11-17 13:31     ` Mauro Carvalho Chehab
2008-11-17  7:15   ` [patch 26/46] S390: cpu topology: fix locking Greg KH
2008-11-17  7:15   ` [patch 27/46] ACPI : Load device driver according to the status of acpi device Greg KH
2008-11-17  7:16   ` [patch 28/46] m68k: Fix off-by-one in m68k_setup_user_interrupt() Greg KH
2008-11-17  7:16   ` [patch 29/46] SCSI: qla2xxx: Return a FAILED status when abort mailbox-command fails Greg KH
2008-11-17  7:16   ` [patch 30/46] SCSI: qla2xxx: Do not honour max_vports from firmware for 2G ISPs and below Greg KH
2008-11-17  7:16   ` [patch 31/46] SCSI: qla2xxx: Correct Atmel flash-part handling Greg KH
2008-11-17  7:16   ` [patch 32/46] SCSI: dpt_i2o: fix transferred data length for scsi_set_resid() Greg KH
2008-11-17  7:16   ` [patch 33/46] dm raid1: flush workqueue before destruction Greg KH
2008-11-17  7:16   ` [patch 34/46] USB: remove optional bus bindings in isp1760, fixing runtime warning Greg KH
2008-11-17  7:16   ` [patch 35/46] USB: gadget: cdc-acm deadlock fix Greg KH
2008-11-17  7:16   ` [patch 36/46] USB: unusual_devs entry for Argosy USB mass-storage interface Greg KH
2008-11-17  7:16   ` [patch 37/46] USB: Fix PS3 USB shutdown problems Greg KH
2008-11-17  7:16   ` Greg KH [this message]
2008-11-17  7:16   ` [patch 39/46] USB: EHCI: fix divide-by-zero bug Greg KH
2008-11-17  7:16   ` [patch 40/46] USB: EHCI: fix handling of dead controllers Greg KH
2008-11-17  7:17   ` [patch 41/46] USB: dont register endpoints for interfaces that are going away Greg KH
2008-11-17  7:17   ` [patch 42/46] ACPI: EC: revert msleep patch Greg KH
2008-11-17  7:17   ` [patch 43/46] ACPI: EC: wait for last write gpe Greg KH
2008-11-17  7:17   ` [patch 44/46] ACPI: EC: restart failed command Greg KH
2008-11-17  7:17   ` [patch 45/46] ACPI: EC: lower interrupt storm treshold Greg KH
2008-11-17  7:17   ` [patch 46/46] ACPI: EC: Dont do transaction from GPE handler in poll mode Greg KH

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=20081117071651.GM29522@kroah.com \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=bphilips@suse.de \
    --cc=cavokz@gmail.com \
    --cc=cebbert@redhat.com \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=eteo@redhat.com \
    --cc=jake@lwn.net \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkrufky@linuxtv.org \
    --cc=oliver@neukum.org \
    --cc=rbranco@la.checkpoint.com \
    --cc=rdunlap@xenotime.net \
    --cc=reviews@ml.cw.f00f.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=w@1wt.eu \
    --cc=zwane@arm.linux.org.uk \
    /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