Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4414613pxa; Mon, 10 Aug 2020 08:32:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGBCumbWm8XmqDCZDAaf57uOuEx2AxCGKVuZlplc2m1fao6PVTYELpKUuvXKaKCJWYzeTP X-Received: by 2002:a05:6402:6cc:: with SMTP id n12mr22520816edy.258.1597073570759; Mon, 10 Aug 2020 08:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073570; cv=none; d=google.com; s=arc-20160816; b=qAAU3mxreRj/CGcrXHGKIO7pbZA5FQfIwEbmlhI7NuiPnNrICYcXq0pAXN1lmuSsYH 67dU0h6iFG0l6SlhfL6xxNwsNtkcJmMro9t9aRjWkloW/uhOErbNj94TK5eaX7EcUmAi mlLLBdw7Gkjn04uqFlqhtO6rT13ZYHvbIReGkFe2inWicMyG2QplS1cM+OZlYVHarnXi no9T/vm4OK0FSabXKIu12n8B1Pu3VeCwhm2nWh0o7A9eI+m3+fqU4OnKJluQQdBLORWz KK86wNGujhU5U3/hjAfPWWQML8FrhVJFgPwcBFppdAx1GrbltCNaP4QKMdGmtk0iNxIv +FiQ== 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=rXwAB1Bdd6Owb5WS3EdJC9+XOrwIdbXDU6Pp/ttzBGc=; b=qoJchu5xQ0EdL9aTxPn0Arrnj89DRD5RWIzJWK8jXEYqkNhGSV5uq9RL2ZUgCHLkJ4 r5UTU+1mYXx4WIbIQoRuCafYMtkxGrI3X+fW19RAFU4tALgWYhiqRCXZAwzuJitghj9B pkX7LEiRsMMKldT7dTdhuix4hnNSyy3gkLuj3szahjsRJ74Df3Qf8stzi5sEDbPj3SC1 9nrx1nmeQzV6WkOcWi4/4uyeSrYN4uLF6fad6OBtJdOmbPtzaOJazsKTl1MVjLJrb6j9 VdGsgtlUsog5G7eWrNCFes8uoNUNESwgTOh4WzrspIE+jb4KK82w3bBDlTxqcmdJCaAk PWUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KNKFJG3p; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x8si10759484ejs.414.2020.08.10.08.32.27; Mon, 10 Aug 2020 08:32:50 -0700 (PDT) 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=@kernel.org header.s=default header.b=KNKFJG3p; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729185AbgHJPbQ (ORCPT + 99 others); Mon, 10 Aug 2020 11:31:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:38566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729177AbgHJPbO (ORCPT ); Mon, 10 Aug 2020 11:31:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 D03FD20791; Mon, 10 Aug 2020 15:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073474; bh=ZyWuUtROHZf3ZDH6q3M+Ty6NXtyMPtEnfvtiWpfN87I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KNKFJG3pUHYmk1wMODJwco4cyFnb/99Zb9vf7VuzV5F7bSZQ+EPB/hpAVsTlM4lu2 QJxQJqgbXkTur1a5wwfRROCpdAwhVMY9nyugFOslWHs4+v4lvpXdtBTODamXqFeedN lbGUUHiZYoYCANebxaSkxyQ6t28Kl5EoA0brWLe8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Francesco Ruggeri , Aaron Brown , Tony Nguyen , Sasha Levin Subject: [PATCH 4.19 27/48] igb: reinit_locked() should be called with rtnl_lock Date: Mon, 10 Aug 2020 17:21:49 +0200 Message-Id: <20200810151805.549199604@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151804.199494191@linuxfoundation.org> References: <20200810151804.199494191@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Francesco Ruggeri [ Upstream commit 024a8168b749db7a4aa40a5fbdfa04bf7e77c1c0 ] We observed two panics involving races with igb_reset_task. The first panic is caused by this race condition: kworker reboot -f igb_reset_task igb_reinit_locked igb_down napi_synchronize __igb_shutdown igb_clear_interrupt_scheme igb_free_q_vectors igb_free_q_vector adapter->q_vector[v_idx] = NULL; napi_disable Panics trying to access adapter->q_vector[v_idx].napi_state The second panic (a divide error) is caused by this race: kworker reboot -f tx packet igb_reset_task __igb_shutdown rtnl_lock() ... igb_clear_interrupt_scheme igb_free_q_vectors adapter->num_tx_queues = 0 ... rtnl_unlock() rtnl_lock() igb_reinit_locked igb_down igb_up netif_tx_start_all_queues dev_hard_start_xmit igb_xmit_frame igb_tx_queue_mapping Panics on r_idx % adapter->num_tx_queues This commit applies to igb_reset_task the same changes that were applied to ixgbe in commit 2f90b8657ec9 ("ixgbe: this patch adds support for DCB to the kernel and ixgbe driver"), commit 8f4c5c9fb87a ("ixgbe: reinit_locked() should be called with rtnl_lock") and commit 88adce4ea8f9 ("ixgbe: fix possible race in reset subtask"). Signed-off-by: Francesco Ruggeri Tested-by: Aaron Brown Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igb/igb_main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 36db874f3c928..d85eb80d82497 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -6226,9 +6226,18 @@ static void igb_reset_task(struct work_struct *work) struct igb_adapter *adapter; adapter = container_of(work, struct igb_adapter, reset_task); + rtnl_lock(); + /* If we're already down or resetting, just bail */ + if (test_bit(__IGB_DOWN, &adapter->state) || + test_bit(__IGB_RESETTING, &adapter->state)) { + rtnl_unlock(); + return; + } + igb_dump(adapter); netdev_err(adapter->netdev, "Reset adapter\n"); igb_reinit_locked(adapter); + rtnl_unlock(); } /** -- 2.25.1