Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2447895yba; Mon, 15 Apr 2019 11:50:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0IlB9OW+XIPNbLgzPKAVkWT276S8/u/tiRkNH+9jT0IOtLQ3PyB8JaBiB7rDVoGDf6Fwe X-Received: by 2002:a17:902:20c9:: with SMTP id v9mr56566914plg.239.1555354250874; Mon, 15 Apr 2019 11:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354250; cv=none; d=google.com; s=arc-20160816; b=wUJbjbPII+4lcbzjQJwUuTrXz/J9GMVXn+1CEA/vFvOIW1rmXhH/lo2AZls6qYFjqd l8tFuWIzfm0BXGnHGzHypCnumBcQH7nuW/RltQAeAbEq1RnY0/qeq4L3om4CACrM3dSV hYCWBo7yviSKtQsAo6KIIpA7RhTc7HPVPCLFpG3CU+ZYwSSeOhGr3PKM/DnH9uIAB67t T7gjEGAtTnW8viphZTVhkcisTb1+khMSLbGJ9hi4WxVsnHeurMvPdpyucqdqqNouav5D yh1Bts47Z0Pj4bIg2kTGYVmMxfReFdxsvZjXYRTPazSwY6qHQj9ATr/bRucRQcJ7/e7K itBg== 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=htlDGkIlds7UAnMRWfZ0/P9pUo7Nyle/r1MoM6wTW0U=; b=ur1m+CUwqdjgo3qb7o+3C1/BDNfPrzCHG3OPxdfVZmReks8Co4uh78TVRgDxR+B0D/ HhZ6lWqfiipTcwc1K8ECmFsjma+HksdofR1JiUbwYkiY1FAVUVraRxehzR6V0JaMkGZd fLf/yidP38eLhp+ZasBkYEFOdONRxukx2B2PCv5j3jKAgdh/i5H6EznPvmtuiXJmXcgy C5jn+lqXZRpj56hbvBlM/FmlOMjTvwCwc8TZb64BzLs6rKhmTe7DVKgk7NABHKpX1f0e SByONsupVglePx7pUHtX+nb4i7041rCyZPYAIToIGTEokFoAo313XcgB3gsopBoXh1Ep gDAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1Y0hF3U/"; 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 y10si27366649pga.96.2019.04.15.11.50.34; Mon, 15 Apr 2019 11:50:50 -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="1Y0hF3U/"; 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 S1728926AbfDOSra (ORCPT + 99 others); Mon, 15 Apr 2019 14:47:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:50732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728444AbfDOSr0 (ORCPT ); Mon, 15 Apr 2019 14:47:26 -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 38371218EA; Mon, 15 Apr 2019 18:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354045; bh=OA1hSrW6M3hQwKtYysC6eRk0anbuLQQpLqiKlAFncfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Y0hF3U/zjfVVMeXs3Pvenni1XJTApo6W+5RpVxbVd9ttXGeEDr5u3Kalt48QE7yP TdHtTzTr2Z4asF5KbYaQsBpK7l/u3Z4EpabeH/MC+MenHv/06pM9N2wJrqbpZGZoRK BB0hxf2mdjokUJUjNLPykRxpp4BJtx5m7hR1rQ7E= 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.9 58/76] bnxt_en: Improve RX consumer index validity check. Date: Mon, 15 Apr 2019 20:44:22 +0200 Message-Id: <20190415183724.574617059@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -959,6 +959,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; } @@ -1377,14 +1379,16 @@ static int bnxt_rx_pkt(struct bnxt *bp, } cons = rxcmp->rx_cmp_opaque; - rx_buf = &rxr->rx_buf_ring[cons]; - data = rx_buf->data; 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; prefetch(data); agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & RX_CMP_AGG_BUFS) >>