From patchwork Thu Mar 11 18:09:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 398175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94DC1C433E6 for ; Thu, 11 Mar 2021 18:08:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4356664F99 for ; Thu, 11 Mar 2021 18:08:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbhCKSIU (ORCPT ); Thu, 11 Mar 2021 13:08:20 -0500 Received: from mga09.intel.com ([134.134.136.24]:47785 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbhCKSH7 (ORCPT ); Thu, 11 Mar 2021 13:07:59 -0500 IronPort-SDR: DCTDTctkttIsX/oSKiOAEy3AXWzuGDIrfKpQG5PB81rmjGcpy3vzOQpIhrtBknbU1y3WQzgIP3 mjl8rUeEmXNg== X-IronPort-AV: E=McAfee;i="6000,8403,9920"; a="188809484" X-IronPort-AV: E=Sophos;i="5.81,241,1610438400"; d="scan'208";a="188809484" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2021 10:07:58 -0800 IronPort-SDR: jLeJl/IaYygL2ab2DcV17NKZcVNg2czv8fbpLvdbLIqLaKgPIr7KLGrTm15SPtQMtMI9pDKOMt SbElGogkrePA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,241,1610438400"; d="scan'208";a="409570564" Received: from anguy11-desk2.jf.intel.com ([10.166.244.147]) by orsmga007.jf.intel.com with ESMTP; 11 Mar 2021 10:07:58 -0800 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org Cc: Vitaly Lifshits , netdev@vger.kernel.org, sassmann@redhat.com, anthony.l.nguyen@intel.com, sasha.neftin@intel.com, Dvora Fuxbrumer Subject: [PATCH net 5/6] e1000e: add rtnl_lock() to e1000_reset_task Date: Thu, 11 Mar 2021 10:09:14 -0800 Message-Id: <20210311180915.1489936-6-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210311180915.1489936-1-anthony.l.nguyen@intel.com> References: <20210311180915.1489936-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vitaly Lifshits A possible race condition was found in e1000_reset_task, after discovering a similar issue in igb driver via commit 024a8168b749 ("igb: reinit_locked() should be called with rtnl_lock"). Added rtnl_lock() and rtnl_unlock() to avoid this. Fixes: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)") Suggested-by: Jakub Kicinski Signed-off-by: Vitaly Lifshits Tested-by: Dvora Fuxbrumer Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/e1000e/netdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index e9b82c209c2d..a0948002ddf8 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -5974,15 +5974,19 @@ static void e1000_reset_task(struct work_struct *work) struct e1000_adapter *adapter; adapter = container_of(work, struct e1000_adapter, reset_task); + rtnl_lock(); /* don't run the task if already down */ - if (test_bit(__E1000_DOWN, &adapter->state)) + if (test_bit(__E1000_DOWN, &adapter->state)) { + rtnl_unlock(); return; + } if (!(adapter->flags & FLAG_RESTART_NOW)) { e1000e_dump(adapter); e_err("Reset adapter unexpectedly\n"); } e1000e_reinit_locked(adapter); + rtnl_unlock(); } /**