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 1F734A04C3; Mon, 28 Sep 2020 17:32:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 309CE1C12F; Mon, 28 Sep 2020 17:32:27 +0200 (CEST) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by dpdk.org (Postfix) with ESMTP id 316AF1C12D for ; Mon, 28 Sep 2020 17:32:25 +0200 (CEST) Received: by mail-qt1-f193.google.com with SMTP id g3so1041296qtq.10 for ; Mon, 28 Sep 2020 08:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+LlbwfSE2LiP9c+Vrj/WhWm30fBEV521ukrpht1I668=; b=EiUqI+P8132SLSiVDYi8aYUyw7fXgjR+m3Ry148cR+/JV6qoHUro0tPRKjZhF27Z7n yFPeFKEUYw1fpQwUXcm89nbO35lHmhKxO5zCkCU4c9vPQtR//6nVeoGsRirzlWs7M6/8 /WvzGF2BFrRjJPKKuk1+sn8Y2BI0GmbDlopLejUWv35SVGvft7hqdIhGdlbChhRiv34x fCROMARefRm09iHP9kapS1YFk7Jm3/ZFz2t81V/ytcXoPeB4rZ1Km4ZbWyem3vYraOD2 vR1rJoQmA9FGOmaNA/z0lrwECgBawycnBG7KYPEpt0yK+l7ganwRgGJh7tyxRe8vYfW7 akew== 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:mime-version :content-transfer-encoding; bh=+LlbwfSE2LiP9c+Vrj/WhWm30fBEV521ukrpht1I668=; b=jYDUvfggd1QeDRHuEZ5RLTrBjDRtOk3B0QLm54PBH2yM2JKeJt13pS2qG4esAuz8ar 918/Jf/BNfbbe+4HagyM3E+9jGHQcWVG4W/dP+d9qBxPsXoxwsw4MfJoi5ZdmG/cxbXo JXHA5BdoZFvaf2Oer12DDoVZlrvtWQRiMdcExylfvs/L7bcq3riY1en8G0gF6YipdwKj 8hd28FimrJxVOfHRqsHJF/tTZb0FV/wY1jHTgO6mv3xyDScRpa7m4/ZS00CZK48oSYD7 B3g+z95ouxAPAiNTd/xXj1nAAwZ5xbH+9cvi1ACVsHMdeWPi7jYkDO70hT3uBm0lgVMF nWYg== X-Gm-Message-State: AOAM530YnLwe6cRi7wIuqA8DkOmzpHfkIAHw4u72fw/An29wrO/u73xQ oeYokqAhie0an6s8PUiS/3jR3ZLkrRmO4Q== X-Google-Smtp-Source: ABdhPJyjnEsix1a4BZqs3gKcZV64VaWpB1ipoPD6YMoJcIMJbt1jRQNMgKJZQiGpylzAK9y0w/pqUA== X-Received: by 2002:ac8:6f24:: with SMTP id i4mr2047243qtv.329.1601307143498; Mon, 28 Sep 2020 08:32:23 -0700 (PDT) Received: from monolith.fios-router.home (pool-96-255-60-31.washdc.fios.verizon.net. [96.255.60.31]) by smtp.googlemail.com with ESMTPSA id k52sm1630566qtc.56.2020.09.28.08.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 08:32:22 -0700 (PDT) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: olivier.matz@6wind.com, Chas Williams <3chas3@gmail.com> Date: Mon, 28 Sep 2020 11:32:19 -0400 Message-Id: <20200928153219.285343-1-3chas3@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net: check that seg is valid before dereference 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 the overall pkt_len and segment lengths are out of agreement, it is possible for the seg to be NULL after the loop. Add assert to check this condition in debug builds. Fixes: c442fed81bb9 ("net: add function to calculate checksum in mbuf") Signed-off-by: Chas Williams <3chas3@gmail.com> --- lib/librte_net/rte_ip.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index fcd1eb342..6b3e4cdda 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -225,6 +225,7 @@ rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len, break; off -= seglen; } + RTE_ASSERT(seg != NULL); seglen -= off; buf = rte_pktmbuf_mtod_offset(seg, const char *, off); if (seglen >= len) { -- 2.26.2