From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7136BA0571; Tue, 3 Mar 2020 19:00:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 170C61C07D; Tue, 3 Mar 2020 18:59:53 +0100 (CET) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 56C1E1C044 for ; Tue, 3 Mar 2020 18:59:50 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id j9so1840840pfa.8 for ; Tue, 03 Mar 2020 09:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BR2FGVaXEaIy8R2p8pSAKFFtFJubdo86cCSrcBUH+ls=; b=JhW9NHMP/o7FD7qrGBBR634YSx/hQwYwn7PX6OsqTYdBvhN7/sJVc0X9JXEXRv6xxM 0haVzn9YKEhr6FSwI6n+xX8GHuZ4rxLcW3TYe/VVDsoKUhIykoMuMdvZed77zQu/v16M /6B8/pyuSgt8sZ9oUOVjFYPltT56ge9JgisA4d/cN9Lv4Osnan2FroGu6BYx0SPrdisB uinbO2woCofQKgN0hayC6NZwPANbpAM6PrDaaot1pom7Rvj+X85ZNcsUWVpDR9widgcm llPaG+H7KxVQNbEFHQSkB7VG+TuOgcP547VoOH7oecXSVnBEmomTX4FjnZM/vAP5XaJI ZYnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BR2FGVaXEaIy8R2p8pSAKFFtFJubdo86cCSrcBUH+ls=; b=jd3zhsktlaypkZAnmNyrX0W3YshVxzMMFs4PIitpNKVa4Cgy0m7U1pRO9yIUFwPpIc C8t/SfF/NNfxdgbcnFyTK4X12NAgWIXqmrX9s2VaNqsDAQ8hwaBxftUpQdCNxURjLsJx zulku0Qw1l9yYNbeD635SqFrRmliFE6CcJ4DXGl4NtA9Z/3iRY2RN80MYF1V/Zd50Qil ip/KcTmc5zFlJqNBx+UxRyZOG3ZcrWPgk0Hs478zcFyNPHVPOpd2l1dELwgRmu+oWvHc oxINozWhIQkHbHyn2HdqKmgB1nZR17178FSy8jgoPYh1YKhqgKPUjGmu1l8039p+FYz3 RoBA== X-Gm-Message-State: ANhLgQ1kkvyRaz+b5lbWGIeq8LOeGfRjCkx5bjy/ZNn+Uivfpemi3Bd9 rg6whCNYyMGnQ9bztreE7tJ2yw== X-Google-Smtp-Source: ADFU+vuZpRyjQSXmLzoIdQxfQW4tQmsl29OmRYYj+Hph1tL6crSFYemfjeS3y+6pd4AQZdchD/jZtQ== X-Received: by 2002:a62:5bc7:: with SMTP id p190mr5257975pfb.16.1583258389548; Tue, 03 Mar 2020 09:59:49 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id w195sm22012158pfd.65.2020.03.03.09.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 09:59:48 -0800 (PST) From: Stephen Hemminger To: ajit.khaparde@broadcom.com, somnath.kotur@broadcom.com Cc: dev@dpdk.org, Stephen Hemminger , Christopher Ertl Date: Tue, 3 Mar 2020 09:59:38 -0800 Message-Id: <20200303175938.14292-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303175938.14292-1-stephen@networkplumber.org> References: <20200303175938.14292-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 6/6] net/bnxt: sanitize max_l2_ctx X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If max_l2_ctx is very large, then adding the additional value could cause wraparound. Reported-by: Christopher Ertl Signed-off-by: Stephen Hemminger --- drivers/net/bnxt/bnxt_hwrm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index d878320aa110..099e04fa550a 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -651,8 +651,15 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id); bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows); bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs); - if (!BNXT_CHIP_THOR(bp)) - bp->max_l2_ctx += bp->max_rx_em_flows; + if (!BNXT_CHIP_THOR(bp)) { + uint16_t max_l2_ctx; + + if (rte_add_overflow(bp->max_l2_ctx, bp->max_rx_em_flows, + &max_l2_ctx)) + return -EINVAL; + bp->max_l2_ctx = max_l2_ctx; + } + /* TODO: For now, do not support VMDq/RFS on VFs. */ if (BNXT_PF(bp)) { if (bp->pf.max_vfs) -- 2.20.1