Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2459715yba; Mon, 15 Apr 2019 12:06:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5nH/Uy1yP7nebrhLJC9G+QmxErmrHvFNv/tiIIAnLIELUMn/mZwiirULnGcxewEu/co+H X-Received: by 2002:a17:902:4a0c:: with SMTP id w12mr48877274pld.52.1555355170903; Mon, 15 Apr 2019 12:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355170; cv=none; d=google.com; s=arc-20160816; b=0btBeKH8Yhg8PqUMihsb1Z6hwGjLLDLkffqbPXTvD+THwSYju7gk/xbPcc7d9+UsTp y/XylajV896NRPU3wTp/D9+JAyJY/1/XgOYrlGNl/QHmLxhR4p78bEFGMuWcFeh5ajUw kWmkz3pcdl9dIwxgX9e6yQVfoXrea0TMxrtdD4IOKXrinDgXd8D3yNijTq1E09Fcoo4u A/2DHVzvEFX2gkeMLr7Wfjjb7uRXsLHkZ2KUkI9cq69sFNM7MYx6ULoXOdNkk+WjMKd7 bW7NE+obNmaAny0wNTkq4rd2f1LvC/oGdscUpEASbKackXDuQ3LTdaV8nCv2NYspFTAP 4mLg== 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=/oL/bv09ReP+WXff07R8HckmIMx51upv/tMMAA0IdqI=; b=DxaQqH5mBrYHcQLt/LRgcO3uFWdfTs1b31iFfj8ikeVj/vFyT5W6/xit9LHW9AKWyV Gt3Vvm4HSj5Rgg3beXjLvmeSVOa4nMPtdWAALlPcPq2z8QQGtNGA2lDa6xEdWuP7vCbp 5TTEXYuGzfPVbSQzU0/SJ2+PoLr2ewcXfxV4lM8cqVXnBqKOOpjuqjGPbQeFHkFnIWlo 3lfTAE+MQLhnxXAuEtMMLw/QJ39s2AHzahgDAFxunc8uE+5fnILUQL+dpSUpz2C8NIB2 o4PfxuJZLe5jBsEW1qXnrJ14+kp8ISmr5LXtUO/QqjcIAkDdlyD/dhNv+bHydtJeybew A1BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TX7Y2kIZ; 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 y11si6669489plr.384.2019.04.15.12.05.54; Mon, 15 Apr 2019 12:06:10 -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=TX7Y2kIZ; 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 S1728255AbfDOTDa (ORCPT + 99 others); Mon, 15 Apr 2019 15:03:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:35238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729214AbfDOTDY (ORCPT ); Mon, 15 Apr 2019 15:03:24 -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 1099721919; Mon, 15 Apr 2019 19:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355003; bh=sDrm8jyvBa7A+2cNEmb9S0o2rOBZtu44DqzSyuXNTr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TX7Y2kIZ8lAT2YIiE0cJ0vrM83VlBE0HZ2c/BlKofsCt9Jxv7CfzhKKYH59G88dc7 VhBvcDh5fWaCNYwrroxibkWbgJPK+Qg3xoiyf/Bvj28V9K6MGDA8cH5TPBPpTSXv3N vpSiPPrepGdevsMvH5Nz0mW1xLMZIn3TAhbE6wIg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Chan , "David S. Miller" Subject: [PATCH 4.14 31/69] bnxt_en: Improve RX consumer index validity check. Date: Mon, 15 Apr 2019 20:58:49 +0200 Message-Id: <20190415183731.578234487@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183726.036654568@linuxfoundation.org> References: <20190415183726.036654568@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: Michael Chan [ 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: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1076,6 +1076,8 @@ static void bnxt_tpa_start(struct bnxt * 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; } @@ -1528,15 +1530,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, } 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);