Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9103590pxu; Mon, 28 Dec 2020 06:43:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOCm7QW1KcCjUBRBAl0NxkgkL7MostqMnLPsLwRrpqd8QiQYemwS2JeZzHbloviSYJD5gy X-Received: by 2002:a50:becf:: with SMTP id e15mr43631426edk.138.1609166618665; Mon, 28 Dec 2020 06:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166618; cv=none; d=google.com; s=arc-20160816; b=dEfVjFr0KLBvbTfL2T+hSQ4e70Qqs8MlbczusX1M84Jek1GTbUpF1286BZowaneGip fg9SXTUjJhlAmz5Enj01XTR5XN1kfZA97G1gNeRFwy+AJy1pNMyTHmnHulQnActg8FLC VdAmv838GL7b3r3E+T19Qe7Z3c3IjsEoEmGPHpw/DrkEgaY46Y+ntAQwWB071hdhoH2H d3kv1QYJDNKiBO4gML9bLvnxhBc0TXnEcyhnaokFpbN3FM1LvOLyg26kzr2JfxUI904T G9RREgrLg60NvUd329eyidfQkLSy7paj4JZYl89kUv6jXaQMuUZhrCXNzNQaH0JpPbHS aiag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qksgMdkC/M9kBh9MbNQ76yPBN3PKnHSnOfxgFO9UW5U=; b=lnFaTooNm6/MtUOEan34T51J2CvXdrqvvDJIXyv82o8Z3h4JGUR+lhvxhfuzFMvg6q ygsXV1p0XZDRZ+8Ow0IvKsTlRf02lNqjcGjYIkGP+ZIp+QRQ6pkWfJh0XOMDKPdXD7fl h6kG2Ll3wUSSaOXBWpqQPdMm8fiLWibPCzHgZEgO+iAWkvsFFwBbwOjHGoNf8eis66sA +MS8UZD8yLlVo6ZL1XAsbNEtbe0BwkFll1ofcCOrDS25kytwHwoHIThjGvUrOKwu9eKg TQFGetNp9+Igfyeo2pP+uqMFtBF3dykGi+Y/xaQ/I9IX77qFHr1Dn3aFg8ji0WZJzzzX ryYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HXborXoh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay21si20400113edb.575.2020.12.28.06.43.15; Mon, 28 Dec 2020 06:43:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HXborXoh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2506041AbgL1Old (ORCPT + 99 others); Mon, 28 Dec 2020 09:41:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:36346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502448AbgL1O2b (ORCPT ); Mon, 28 Dec 2020 09:28:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 771CC20715; Mon, 28 Dec 2020 14:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165671; bh=gUQzAdPCX55oMJ9NUDZLCAt00yC3cJNBAcYgtNs8HK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HXborXoh9y6WYXE36XafFvxafh+Qw2u9HJljhWIzvNKEtg6gTKYMGcgw/Z0pwMaBd +9hvr/U31cxiwZB1BlQ+GPBodJ3yhIyO9XAJUiRlKKcC6coQsCrN6hqJ55T165UL06 d/ZB6RrzXno4gIMyA0AsLLT7P5PYwsizh1SGmoFg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , Johan Hovold Subject: [PATCH 5.10 582/717] USB: serial: keyspan_pda: fix write deadlock Date: Mon, 28 Dec 2020 13:49:40 +0100 Message-Id: <20201228125048.802622732@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit 7353cad7ee4deaefc16e94727e69285563e219f6 upstream. The write() callback can be called in interrupt context (e.g. when used as a console) so interrupts must be disabled while holding the port lock to prevent a possible deadlock. Fixes: e81ee637e4ae ("usb-serial: possible irq lock inversion (PPP vs. usb/serial)") Fixes: 507ca9bc0476 ("[PATCH] USB: add ability for usb-serial drivers to determine if their write urb is currently being used.") Cc: stable # 2.6.19 Acked-by: Sebastian Andrzej Siewior Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/keyspan_pda.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -443,6 +443,7 @@ static int keyspan_pda_write(struct tty_ int request_unthrottle = 0; int rc = 0; struct keyspan_pda_private *priv; + unsigned long flags; priv = usb_get_serial_port_data(port); /* guess how much room is left in the device's ring buffer, and if we @@ -462,13 +463,13 @@ static int keyspan_pda_write(struct tty_ the TX urb is in-flight (wait until it completes) the device is full (wait until it says there is room) */ - spin_lock_bh(&port->lock); + spin_lock_irqsave(&port->lock, flags); if (!test_bit(0, &port->write_urbs_free) || priv->tx_throttled) { - spin_unlock_bh(&port->lock); + spin_unlock_irqrestore(&port->lock, flags); return 0; } clear_bit(0, &port->write_urbs_free); - spin_unlock_bh(&port->lock); + spin_unlock_irqrestore(&port->lock, flags); /* At this point the URB is in our control, nobody else can submit it again (the only sudden transition was the one from EINPROGRESS to