From patchwork Mon Aug 16 13:00:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 497658 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp83885jab; Mon, 16 Aug 2021 06:15:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOYjuHRGsM4hSdpNt8VWO/0tKG9Z8LWtQ9D05/lpy+x7g2p9268E9/H4svmzo8Gf0bPEs/ X-Received: by 2002:a17:906:a98e:: with SMTP id jr14mr15827034ejb.450.1629119708703; Mon, 16 Aug 2021 06:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629119708; cv=none; d=google.com; s=arc-20160816; b=FXefnaS7eQx9rXXSl+3jqOtyRbLp59WPCbG/Q4okDSoz6QZLeBjPMLTjLRgq1x8As0 HtAuH5zm0RemStwHwfvFgHkkPK7CLEpq+WTx52E/AeHxtbnYCbxJeej334s2eyLaS65y 6DLO5vP8e/P2qyHn2JqOZxy+mXL2Dop4MOz5P1JAGwEIzPoEgs9xSiynape4UsMOjdKX NvLo7Vf7G0JKG6ISJRL6ZYOdfUvAjm4Ub15eo5icWEs8tDPeixqDFKbnPh1WP82/Fvcv 8Yor9ia/oyVE1kE5bDqXYHn90NKN3AQXi9q25BOf+Tb8UR8j4tRCbj7AOExgkKa5kPmf m+Cw== 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=h/3nJcziILUGNOlIcfVA1VHXZ7Q4Eqom2dy2wgc15pM=; b=QRQjoqSBA1ss1HnWVdty2ueMUzhen6GK+1NBMuuOMQW2p2MGaJEAEbJobZAwVEBuZO j5+W0y8xIB8YlPtAemsoxqjwqW3wKOiMyJ++2I4vKalJkLf8rOq7muApPS/e4hVNFbZz +8auZcHTmIOSDFlAdxxsGdy/qAFAfRQ4R0uy0JxjXhI42ww8Oxtc+9p4hJ+lHxpbLCxC hu4ZyR+q145D1bvcU06Lyztz3NvzK7BwbsYpWBgy5uULDAvM5FjR8D9nOlhbQa/yhwv3 Pr4TLgBxNijkD8T69OZ9ZEV35G+OXLiR+NAH55iA05DcvM4XhUagpCsdmLX34i4FO87l 23JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X7+mau9l; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 jx13si10164233ejc.474.2021.08.16.06.15.08; Mon, 16 Aug 2021 06:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=X7+mau9l; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S239123AbhHPNPe (ORCPT + 12 others); Mon, 16 Aug 2021 09:15:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:39006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239604AbhHPNOc (ORCPT ); Mon, 16 Aug 2021 09:14:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C3FB0632A2; Mon, 16 Aug 2021 13:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629119475; bh=xWHx/EOAscR3etXZqIA2GxRKfnPuBGdPN7geStoKCLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X7+mau9lEKijKYs0/K7P3DO7xclOfRO/IHdz/fVNLIPxCaZMCfrABitOMh34TiClk RqnGty4AWIf62AyNI06xEvUWvYDQCpHWQMSnnJd5qa3abaHXCdgQQYLUM4KR9Pi//w dr+TDMLzzFJqS4cchUqVnlQkFyUHY1mP8A1U+M+w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Perrot , Loic Poulain , Sergey Ryazanov , "David S. Miller" Subject: [PATCH 5.13 023/151] net: wwan: mhi_wwan_ctrl: Fix possible deadlock Date: Mon, 16 Aug 2021 15:00:53 +0200 Message-Id: <20210816125444.832318357@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816125444.082226187@linuxfoundation.org> References: <20210816125444.082226187@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Loic Poulain commit 34737e1320db6d51f0d140d5c684b9eb32f0da76 upstream. Lockdep detected possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&mhiwwan->rx_lock); local_irq_disable(); lock(&mhi_cntrl->pm_lock); lock(&mhiwwan->rx_lock); lock(&mhi_cntrl->pm_lock); *** DEADLOCK *** To prevent this we need to disable the soft-interrupts when taking the rx_lock. Cc: stable@vger.kernel.org Fixes: fa588eba632d ("net: Add Qcom WWAN control driver") Reported-by: Thomas Perrot Signed-off-by: Loic Poulain Reviewed-by: Sergey Ryazanov Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/wwan/mhi_wwan_ctrl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/net/wwan/mhi_wwan_ctrl.c +++ b/drivers/net/wwan/mhi_wwan_ctrl.c @@ -41,14 +41,14 @@ struct mhi_wwan_dev { /* Increment RX budget and schedule RX refill if necessary */ static void mhi_wwan_rx_budget_inc(struct mhi_wwan_dev *mhiwwan) { - spin_lock(&mhiwwan->rx_lock); + spin_lock_bh(&mhiwwan->rx_lock); mhiwwan->rx_budget++; if (test_bit(MHI_WWAN_RX_REFILL, &mhiwwan->flags)) schedule_work(&mhiwwan->rx_refill); - spin_unlock(&mhiwwan->rx_lock); + spin_unlock_bh(&mhiwwan->rx_lock); } /* Decrement RX budget if non-zero and return true on success */ @@ -56,7 +56,7 @@ static bool mhi_wwan_rx_budget_dec(struc { bool ret = false; - spin_lock(&mhiwwan->rx_lock); + spin_lock_bh(&mhiwwan->rx_lock); if (mhiwwan->rx_budget) { mhiwwan->rx_budget--; @@ -64,7 +64,7 @@ static bool mhi_wwan_rx_budget_dec(struc ret = true; } - spin_unlock(&mhiwwan->rx_lock); + spin_unlock_bh(&mhiwwan->rx_lock); return ret; } @@ -130,9 +130,9 @@ static void mhi_wwan_ctrl_stop(struct ww { struct mhi_wwan_dev *mhiwwan = wwan_port_get_drvdata(port); - spin_lock(&mhiwwan->rx_lock); + spin_lock_bh(&mhiwwan->rx_lock); clear_bit(MHI_WWAN_RX_REFILL, &mhiwwan->flags); - spin_unlock(&mhiwwan->rx_lock); + spin_unlock_bh(&mhiwwan->rx_lock); cancel_work_sync(&mhiwwan->rx_refill);