Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1948550imm; Thu, 24 May 2018 03:26:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoT327AbHMFsfX+w8+spOe/zUipbR3Oh/iHVWx2ktxYzNL/CE84XL44WVBDyrgQgP25jEyL X-Received: by 2002:a17:902:bf0a:: with SMTP id bi10-v6mr6614627plb.235.1527157607871; Thu, 24 May 2018 03:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157607; cv=none; d=google.com; s=arc-20160816; b=QFaMtf4/EFA7JdME2ys6UUNAM/8z8Et3bo64FDtLcOR/a0sRWHiv3QTL+KF59GK690 2vOx2JICc6eCwXL62gx+Toc0jGi/SVnxXt8Tct1RA0B4qk/wh0MHud5Dk9tiOOW0dMto ZRnWEblpQc0mnolmni/Gy7sm6meS2QfOHuMXtrA5lEi2bFGWwwQzomHNgQ3lF33oy8qF E3+mw1naRlGvBLAIEN9SnL+snFtPauRSL3r4v3mDbU6bBjMwls9FtU4IGc/8FEpMp6DJ +v/JYmVkymbJ5cEevpVk2UWtOKvwdAJa18zlgSTtDFOCPS7BYZRaiF+cIz3NnUfj+MDe YPdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=JQqKRAOxXgKyELPRD+wGZpXUpAA67hcf8eAvmopxPzA=; b=o3LcsLpmetqG6oDF25/Jry18YgiTUHtZrb6OL17BTEqeNjKhIiJmiddV+AqLRKGCjk /xoNe6T1jCPfSti1sT0gCR//OsAEIdcRqG0yEhFPttNRiKEvtuRr8zOd+dJLpzMBXvRT kpbyaOkonIxdZ6pdvkLj1gBqywZneiOwn+drMJkEg0QuZfkD4xTXdIxCCxpbOtdVcca8 gJ0PK+Oll17+9j6P7JxI/DbsOIZBtpUyZA9hOH2fwwtmJBZLQTn1prsGYndAS3QEKE22 vPpkcBmuFWQXoFOD8qZg0XUEq5YKKn/fX4kNEbKi8ZaRaPwGYqKuEQDk13c/9lB/dj4F sKiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ctOA5Wji; 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 n7-v6si139998pgu.362.2018.05.24.03.26.33; Thu, 24 May 2018 03:26:47 -0700 (PDT) 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=ctOA5Wji; 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 S1031038AbeEXKCB (ORCPT + 99 others); Thu, 24 May 2018 06:02:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:47852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031003AbeEXKBr (ORCPT ); Thu, 24 May 2018 06:01:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 E4E7920890; Thu, 24 May 2018 10:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156107; bh=UiD3rDseCuZelj1aNAOgMD0dCxIHgkjU6OTACbP/l6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ctOA5WjiU9laOk7UkQE08/57eCM4TYNBgFpOQ+wHa7VpnHPggif53jwUaLVBKHLhH 1bgibnHv2vnOKcmFs0UfnYQubOZJjfkUtfex/7vL2KHQQV0rAGKYponk4sbpdT0XpV lof1S6NGj53KFbfhhQj3t+Zp2wuKJqyemeGieExw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ariel Elior , Michal Kalderon , "David S. Miller" Subject: [PATCH 4.16 031/161] qed: Fix possibility of list corruption during rmmod flows Date: Thu, 24 May 2018 11:37:36 +0200 Message-Id: <20180524093022.068814571@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michal Kalderon [ Upstream commit ffd2c0d12752a69e480366031ec7a7d723dd2510 ] The ll2 flows of flushing the txq/rxq need to be synchronized with the regular fp processing. Caused list corruption during load/unload stress tests. Fixes: 0a7fb11c23c0f ("qed: Add Light L2 support") Signed-off-by: Ariel Elior Signed-off-by: Michal Kalderon Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qed/qed_ll2.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c @@ -292,6 +292,7 @@ static void qed_ll2_txq_flush(struct qed struct qed_ll2_tx_packet *p_pkt = NULL; struct qed_ll2_info *p_ll2_conn; struct qed_ll2_tx_queue *p_tx; + unsigned long flags = 0; dma_addr_t tx_frag; p_ll2_conn = qed_ll2_handle_sanity_inactive(p_hwfn, connection_handle); @@ -300,6 +301,7 @@ static void qed_ll2_txq_flush(struct qed p_tx = &p_ll2_conn->tx_queue; + spin_lock_irqsave(&p_tx->lock, flags); while (!list_empty(&p_tx->active_descq)) { p_pkt = list_first_entry(&p_tx->active_descq, struct qed_ll2_tx_packet, list_entry); @@ -309,6 +311,7 @@ static void qed_ll2_txq_flush(struct qed list_del(&p_pkt->list_entry); b_last_packet = list_empty(&p_tx->active_descq); list_add_tail(&p_pkt->list_entry, &p_tx->free_descq); + spin_unlock_irqrestore(&p_tx->lock, flags); if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO) { struct qed_ooo_buffer *p_buffer; @@ -328,7 +331,9 @@ static void qed_ll2_txq_flush(struct qed b_last_frag, b_last_packet); } + spin_lock_irqsave(&p_tx->lock, flags); } + spin_unlock_irqrestore(&p_tx->lock, flags); } static int qed_ll2_txq_completion(struct qed_hwfn *p_hwfn, void *p_cookie) @@ -556,6 +561,7 @@ static void qed_ll2_rxq_flush(struct qed struct qed_ll2_info *p_ll2_conn = NULL; struct qed_ll2_rx_packet *p_pkt = NULL; struct qed_ll2_rx_queue *p_rx; + unsigned long flags = 0; p_ll2_conn = qed_ll2_handle_sanity_inactive(p_hwfn, connection_handle); if (!p_ll2_conn) @@ -563,13 +569,14 @@ static void qed_ll2_rxq_flush(struct qed p_rx = &p_ll2_conn->rx_queue; + spin_lock_irqsave(&p_rx->lock, flags); while (!list_empty(&p_rx->active_descq)) { p_pkt = list_first_entry(&p_rx->active_descq, struct qed_ll2_rx_packet, list_entry); if (!p_pkt) break; - list_move_tail(&p_pkt->list_entry, &p_rx->free_descq); + spin_unlock_irqrestore(&p_rx->lock, flags); if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO) { struct qed_ooo_buffer *p_buffer; @@ -588,7 +595,9 @@ static void qed_ll2_rxq_flush(struct qed cookie, rx_buf_addr, b_last); } + spin_lock_irqsave(&p_rx->lock, flags); } + spin_unlock_irqrestore(&p_rx->lock, flags); } static u8 qed_ll2_convert_rx_parse_to_tx_flags(u16 parse_flags)