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 2D18CA0571; Tue, 3 Mar 2020 19:00:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 647821C067; Tue, 3 Mar 2020 18:59:51 +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 119DD1C02D for ; Tue, 3 Mar 2020 18:59:49 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id y21so1858287pfp.1 for ; Tue, 03 Mar 2020 09:59:48 -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=iiAVPSYe+1K5FDYKO4RyAgdhe04D6OI+9Bp5TS20wUs=; b=MB4wLR87I4s7Q+AchMhR/+6yfeD/NIFbfLYdLikxhOC64dS1psRQ9rQOGVlWmrTI8i +8s6FWIs/qvpr0C2ncFfnLxh/m024g0bWk4SaYV4benYitjuFNxjtkifY4pJLaiuE6hV NfxxDAY0aVcE1x2IuJHmzqcctofP192sVNq5JNoxxAe5ajtNDvJioOHrXOdZ6r+85iJ2 +IZC0ANQf0QZbTZRXMndr9d+jYKjTwd+ThgbclMR80KvHPX4wy6t2p2io1LSi1J9i/vv ggQsA2TIZiZGDV413QaeE0OwPp8WV/AADMmiydl++qp1f1LGWBKbDUI9llEFpcNKW6Ja sFmA== 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=iiAVPSYe+1K5FDYKO4RyAgdhe04D6OI+9Bp5TS20wUs=; b=FYg+Mw6yGVYcgw5sQE19v4mjx9GGm617r1mHUrUKgU17jTK9eyp762GyK2Yfkgvl0r p21Tk6G0zx8uLfOyOz86D1qswJQo9HoQkKDLBpdaxAK8i1j/jld19aXuL+AKTjQV4w7p 1G7sW48M9yfLUrcyNNnt/dE3hVXf99s2j9BfsvnE0hxcpHSyehOPVe1vDFOlKvo3C6Bs HleaH4iUyslgeNd8vdRoBh7aJIOB5BPsSthYpGvvH8DzEpoVBj2YQy9mTYcVec5TVIrz Y3W2OLtMAPUmYAyDWHHO5ozArRr1DEe1zwsmZA1/ExIZ5TVZD6Dg0wVUFO4Ej5mxBZmv tkug== X-Gm-Message-State: ANhLgQ1V8t58lmehSoJjBcQ+Jx11VUCxbmEsfCfp9YATRoW0k/AJyoqQ R0apfh3fMsxQe53II8QyFzqjYg== X-Google-Smtp-Source: ADFU+vvBCee2vDXXe4+2g+PmijXOiVPP714K1dVrMuGpX5m6Oebp5Z8g501hSy7HIAw5pxgl7v41QA== X-Received: by 2002:aa7:85c8:: with SMTP id z8mr789579pfn.66.1583258388271; Tue, 03 Mar 2020 09:59:48 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 09:59:47 -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:37 -0800 Message-Id: <20200303175938.14292-6-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 5/6] net/bnxt: add integer underflow check 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 a request to read a small value is passed to nvram reader it would underflow. Reported-by: Christopher Ertl Signed-off-by: Stephen Hemminger --- drivers/net/bnxt/bnxt_hwrm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 6beb215d604f..d878320aa110 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -3859,6 +3859,9 @@ int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data) *data++ = dir_entries; *data++ = entry_length; + if (len <= 2) + return -EINVAL; + len -= 2; memset(data, 0xff, len); -- 2.20.1