Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp39201imu; Thu, 8 Nov 2018 14:21:56 -0800 (PST) X-Google-Smtp-Source: AJdET5dIdUeJOviWNsrvmSu/t/2KuDS7T3+R7bbgaBKEiEJkRn16E4mVfYh/9Uf0cyO56262wPs2 X-Received: by 2002:a62:9702:: with SMTP id n2-v6mr6312433pfe.222.1541715716937; Thu, 08 Nov 2018 14:21:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541715716; cv=none; d=google.com; s=arc-20160816; b=VusHJ7mj4OgPYD0RUVo0T0qJt45u8vl3DoHUi55tUHBckXTRWUyIYMcPC+R15dQvMY 5W4YFk6a66CN/2qWHD33jG92n/y6y1r0njKseWXU1CKTQTzCRXFI2JNe65SyJDp+c0MV M66woT7qSLXEohc91i6IR5U4f6kWmQyybAsj2sy+f0imO46SEL2whsADfmxdlTBF0muV gk/NDifhFO+ex+/Yndvzffk+nXv4Hirv99GpojOJrVMCsQ/FuF4Ac6yXdCGnGfjhqbp4 a1+mqKyTHayLRO9L3vTpRidW+876IVh/sXpw+m4NV6smAmpanv3J8gOFb0lDUUoTY6MI GXNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vw69rXDbNv9DYjtGQ+CTetIPJYQasDasyoDl2qqvX7k=; b=uJCMczjIFxJFkIjnI0bxivwXQJTClhhU1tBbBKQuiu7QME52JSZYl/hdOaGoJIbO7s H8sQ4QVDcQcsNR0TAPsPpEm89espkV5wVWiM8kuTrDykejijfQqVOh8LJC1IiyRN5e+s 8zrwBJjaCgEZTYe1aZ/cbhLBgDaVWu+G6BI7fbt0WKSLSgp3hw3s+qVLzYxhwPeKdzwO fejH4mVzClvRync6pj8tD64sl4JJJkjI/KxUX8Dt516ppWOSjjjK6Q4b0AA01e2DNESZ YK+WFXXmRqGRXhkH79+8BSsQKs57pDqj0TsqlTWkaVd7PeBnlUoxcmIxPlmP0z6MPGTT C0mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WJ4OhMsJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si5087190pgh.305.2018.11.08.14.21.41; Thu, 08 Nov 2018 14:21:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WJ4OhMsJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728014AbeKIH6y (ORCPT + 99 others); Fri, 9 Nov 2018 02:58:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:35818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727227AbeKIHn0 (ORCPT ); Fri, 9 Nov 2018 02:43:26 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E2E220892; Thu, 8 Nov 2018 22:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714756; bh=DVoUi4tWamRKu1Czsfrvv9+rJkWxgCXhZEymfhVMqG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WJ4OhMsJBmuczmnjuQa6O/pSnfcHt8tWNJ4dVn2714G87nNTNgZprvHKtpPR5Kvkf B9mi54UazFxkvLupYo+/iqLGJ8i07Ykdzhl86iiDvhzuN7ulqFV5Vbrn1NzhZf9Eg0 BWwxIWFVzoowC/cQ7Hq4Xsmb/gJa+CPENrbU1C0g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Shemesh , Saeed Mahameed , Sasha Levin Subject: [PATCH 4.9 078/171] net/mlx5: Fix health work queue spin lock to IRQ safe Date: Thu, 8 Nov 2018 13:50:48 -0800 Message-Id: <20181108215133.199210073@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215127.257643509@linuxfoundation.org> References: <20181108215127.257643509@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 6377ed0bbae6fa28853e1679d068a9106c8a8908 ] spin_lock/unlock of health->wq_lock should be IRQ safe. It was changed to spin_lock_irqsave since adding commit 0179720d6be2 ("net/mlx5: Introduce trigger_health_work function") which uses spin_lock from asynchronous event (IRQ) context. Thus, all spin_lock/unlock of health->wq_lock should have been moved to IRQ safe mode. However, one occurrence on new code using this lock missed that change, resulting in possible deadlock: kernel: Possible unsafe locking scenario: kernel: CPU0 kernel: ---- kernel: lock(&(&health->wq_lock)->rlock); kernel: kernel: lock(&(&health->wq_lock)->rlock); kernel: #012 *** DEADLOCK *** Fixes: 2a0165a034ac ("net/mlx5: Cancel delayed recovery work when unloading the driver") Signed-off-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/health.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 448e71e07668..264f51b3409d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -369,10 +369,11 @@ void mlx5_drain_health_wq(struct mlx5_core_dev *dev) void mlx5_drain_health_recovery(struct mlx5_core_dev *dev) { struct mlx5_core_health *health = &dev->priv.health; + unsigned long flags; - spin_lock(&health->wq_lock); + spin_lock_irqsave(&health->wq_lock, flags); set_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags); - spin_unlock(&health->wq_lock); + spin_unlock_irqrestore(&health->wq_lock, flags); cancel_delayed_work_sync(&dev->priv.health.recover_work); } -- 2.17.1