Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9047697pxu; Mon, 28 Dec 2020 05:21:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcz5OT5zB5C3jFIVFRqXA5coJg2m5hBtaUibNS+OHUri7oMazE5dn3xfnq72hVYypVFi9+ X-Received: by 2002:a05:6402:a45:: with SMTP id bt5mr42289135edb.130.1609161704706; Mon, 28 Dec 2020 05:21:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161704; cv=none; d=google.com; s=arc-20160816; b=w1idRs9zykqUs4zmGeRcf01lpcyRzdIFcsmLnIHHwGI7Q/CMnZvNZ42WABr/mZ7ZGe 0vUaWFBq+lctQ/TgEpmaQ+qU4DXEPa5CjUKI4//1gR8H2z645cN/+FoI5zx2bDh89KlD P15lp5FBrhN7GaWiN0KtiZxOeZSgtBYTPqKOfBabvmTbtr0aw8uphXROqUPNcyzBAI7J B/wC2XE5V8CtZWA/tqq11mUsFRzKI5jMy+NqX4xbTcbnsPHybcMkvxv03gSotdK45f+N clt20Q+uQS9+Maq3QLHIeeo5wQjUXt0xPsxeU7Ta68olf7xdp2xqP3PN/aI1RxOtj2B4 7f5w== 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=xuuMKcD7SP/JHjV2CNGHcsCLfLb+r9Q/8Nv6iLB5kvo=; b=t4049NQ+sCGFaQwMv7cEH2A9jmf6YUi5uXvBoDbyNcSJ2yWXX8f0tN+pm9gfG3iNJV r6p9xugaa1ewsUkUtEpgQEyoiVp/vjYhcFCJbvzAmGAuxLyLXkjjJC53AWrLlaslAOgH XaPWo37J484h3UssNgy9EREG+G11zSktOYa8kljzILlQ1Ir5xyfbYnYI0x7qphsPWPs3 rhJfKE8qmvSYCuFtJzDqsrj2ycXb1RaE1aqgGd3bhszZtUAOxpPkuRCo1+PTExgzZDs7 O2DLdzt8YyLOEfsCuPTPRsxFAucr5cgtLQ87O8MOSGz5cX8oviXU8NXKPDYhqtJcna87 GSVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nMBJh1dh; 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 r5si20047648edo.330.2020.12.28.05.21.20; Mon, 28 Dec 2020 05:21:44 -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=nMBJh1dh; 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 S1732865AbgL1NS6 (ORCPT + 99 others); Mon, 28 Dec 2020 08:18:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:47174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732869AbgL1NS4 (ORCPT ); Mon, 28 Dec 2020 08:18:56 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3D65206ED; Mon, 28 Dec 2020 13:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161520; bh=r9xCeAMs5iAVd1Tko00oM32AUvZdGbhJW/nO/a7uMbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nMBJh1dhbMm5ld/YIXjdBYQYUTRN8Zp3UYQ5Ek3M0cSBb/b+Z+vdiKZ/bGw6f8uGV OrfFX/UpfZ1ZBZkRHWckprJWrLiA1f+nV6p7cORDrDU5RH7r+gSMDMrF5Un9q7tVR+ j1QnL2pbUwFnCx6C7+zF7gDvwaIRP+YRPJSwiVaA= 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 4.14 201/242] USB: serial: keyspan_pda: fix write deadlock Date: Mon, 28 Dec 2020 13:50:06 +0100 Message-Id: <20201228124914.573434701@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 @@ -447,6 +447,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 @@ -466,13 +467,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