Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9039118pxu; Mon, 28 Dec 2020 05:08:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkqZ3xwkS/9AuKnKAZja8Z58daJgvtSCc58Yzizx7r8EyF5Tgyu0LjSeMReVtwEmQ9WYO3 X-Received: by 2002:a05:6402:b4d:: with SMTP id bx13mr42322065edb.93.1609160915114; Mon, 28 Dec 2020 05:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160915; cv=none; d=google.com; s=arc-20160816; b=IKBy+SkgkfQpsvuYjaNFqqzIcYtqJ+5fabuM9cOHKfqshNmvmi8JVBv9wKgfter6lD yRnSoBV1qhamxaFvG2SjJm62byfV6m5JVBxoSihVuztnQDfwUhUU5P84ReUeSWfMmLda A/Whv8DZwyBwUG7MdJx8BiIcn5uh9+sHDXKl6sP1XwYLtdGLzS2QCnncFJmwQmtlTr2+ X1Vb2lGLxM+IxG2e/dT4vecivYuYgAg+8G4syz8FUpzR6faIxq0owof9rKMOjRvU+Vmx Ej/TE7c/TUpY5nAi4IUr2fvToXyebXslgMfKPQnOR6QTUqmKDDKXoKivp8nOBhiL04nC s2kw== 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=nspi3zKVtru/DXc/1L+kw9PcjtQ3T49yEO46sEXCQnAIglPCsGo88WyPWHC4bF3qpl fo5F5WBv4XzrlpOki92qmfoEz994hCNfhJw9tgQM2JPtJMjx9QREdZJunu6uqXpLEBJh JCCvOFXg0H+ZIfGRLnbMpAL76kCgGZpCMXbyA6SAQltARGBGqnKChA9kj9tMWXxlvA3d gpjDkG93lV6DcNg5bfl9XM17shJAjanlLlAjGrQlWcbZ0ASKAjkY+1Rb7s9hPzZVHiD/ 0OvNWi7McoV1SkJ0EkxebtAa98JwqaXotU7fRnCGbzhweJGwRlEdUBSvpprLwgMM/Oks DKvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PQlswl1p; 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 l13si18150023ejr.754.2020.12.28.05.08.12; Mon, 28 Dec 2020 05:08:35 -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=PQlswl1p; 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 S1729382AbgL1NG0 (ORCPT + 99 others); Mon, 28 Dec 2020 08:06:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:33806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729592AbgL1NF5 (ORCPT ); Mon, 28 Dec 2020 08:05:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E721F22A84; Mon, 28 Dec 2020 13:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160716; bh=r9xCeAMs5iAVd1Tko00oM32AUvZdGbhJW/nO/a7uMbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQlswl1pstoINSAHI67Ft712cJybMqQqRPr4oxIm4YkB43rD9i9jpK2rN9NGixY/O chLORpgEjEL1t7GpJrR8t0/9v03HhrGdEnvCS+uPWtkUOqvf52DeV5Sr323v+DXGce rUecUDrB419bVSSBIBSZ1ZPbV3alJOD+pWIN9rWQ= 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.9 146/175] USB: serial: keyspan_pda: fix write deadlock Date: Mon, 28 Dec 2020 13:49:59 +0100 Message-Id: <20201228124900.327629405@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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