Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2476314yba; Mon, 15 Apr 2019 12:26:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOxv/oTvmi+WhR0wW4lbeYim0dodl2LjgpDaxLNQjLxgsD5d/oeXOE+YJbe/vO06j4QvJF X-Received: by 2002:aa7:884b:: with SMTP id k11mr77526357pfo.49.1555356397488; Mon, 15 Apr 2019 12:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356397; cv=none; d=google.com; s=arc-20160816; b=URBTAIeHYbeQDyNxgNZLaWPUdJEAN3DAAVvLlfWOVCKfyL7Jk5JKHgrU2XCbMi9w9+ GeRC3E7DwfJECiMHxfeyQFyVkMkWaHOZpIXH6U40x26zSTMM8DEbrqHKNeOXvk1nz4Ep xXLlXTXtTvA/KxpM71FJ7/PHn+yVjwKkFrZI524PkaLmJ4Q845fzEmq84Z2x5edJg+GY j5aHbJHm9wJvjMOTptS5EoSQgl5kGuxzg881b4n663KEGjO9b9TS7Ts/d4022DMopHSY Aw3pdxI8Hcp1WHCVwhp3DV/3oEbJjE2ZAvaESBG8+zI8u72CeoOpBkcJF6EFeiXrhC5l FTWg== 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=5y/pCqabSCBT7oCjsuDVwpbkv2h4jg8ErDqorGklEt0=; b=Nq6vDX9hpf/gc8jcZj+oHTZwwIjmDzwOyP8epZ+QwiKVibfDwLI648+hJ1Cbg0K8hL GB1e7imv52d9RbtXu47pduM3jtJCwuLqvPwNu1ovcDFpWpv23dCftWyM8m6BG6nYBIn0 WN0ipaPwU4he029XZh61r9T/ZdGpk/FW6RZl+Y8HQBR7XrvM8EX8dwCrJao6Ne3MFGGJ 4ur/oYoTMzKYGpRGCtr/Ddz+pr1no84BoLfNItjnpjagEC7+D4cw09tCi7uqmT1qBpHK p+VhnVarQNOBTG8asG0hpXXVjPx9bAeY+txA7g260/qOWuofKWaU1pnO2Nat6+4a0ZpD zUgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z8bi6qxY; 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 p8si34767399plk.392.2019.04.15.12.26.21; Mon, 15 Apr 2019 12:26:37 -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=Z8bi6qxY; 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 S1730249AbfDOTZI (ORCPT + 99 others); Mon, 15 Apr 2019 15:25:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:39540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729724AbfDOTFl (ORCPT ); Mon, 15 Apr 2019 15:05:41 -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 475832087C; Mon, 15 Apr 2019 19:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355140; bh=BzuP6qCwvSJOVzQETo8lWEzdUux06hzxkSnIfsPZHR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8bi6qxYLkUA05ZeCTELqL/CSLcLn2rjo4iSDXGKGftDjmc2A4p1nZ3BQBy/3WOon Yj7Wd/5xdQFKS7wc+suTY1+nP/NvmwS6AVntTR4fIEt4p3rsfNc+MqSl2aYY9VcbRF 4cMGvkjZf7TFMgChtRPG+2w+dfavu7cZZ503fPxo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 028/101] bnxt_en: Improve RX consumer index validity check. Date: Mon, 15 Apr 2019 20:58:26 +0200 Message-Id: <20190415183741.904003577@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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 [ Upstream commit a1b0e4e684e9c300b9e759b46cb7a0147e61ddff ] There is logic to check that the RX/TPA consumer index is the expected index to work around a hardware problem. However, the potentially bad consumer index is first used to index into an array to reference an entry. This can potentially crash if the bad consumer index is beyond legal range. Improve the logic to use the consumer index for dereferencing after the validity check and log an error message. Fixes: fa7e28127a5a ("bnxt_en: Add workaround to detect bad opaque in rx completion (part 2)") Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0bd93bb7d1a2..a8abb47178be 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1092,6 +1092,8 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, tpa_info = &rxr->rx_tpa[agg_id]; if (unlikely(cons != rxr->rx_next_cons)) { + netdev_warn(bp->dev, "TPA cons %x != expected cons %x\n", + cons, rxr->rx_next_cons); bnxt_sched_reset(bp, rxr); return; } @@ -1544,15 +1546,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_napi *bnapi, u32 *raw_cons, } cons = rxcmp->rx_cmp_opaque; - rx_buf = &rxr->rx_buf_ring[cons]; - data = rx_buf->data; - data_ptr = rx_buf->data_ptr; if (unlikely(cons != rxr->rx_next_cons)) { int rc1 = bnxt_discard_rx(bp, bnapi, raw_cons, rxcmp); + netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", + cons, rxr->rx_next_cons); bnxt_sched_reset(bp, rxr); return rc1; } + rx_buf = &rxr->rx_buf_ring[cons]; + data = rx_buf->data; + data_ptr = rx_buf->data_ptr; prefetch(data_ptr); misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); -- 2.19.1