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 05694A04B5; Thu, 1 Oct 2020 12:36:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9136C1DAFE; Thu, 1 Oct 2020 12:22:53 +0200 (CEST) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by dpdk.org (Postfix) with ESMTP id EBF831DAF8 for ; Thu, 1 Oct 2020 12:22:50 +0200 (CEST) Received: by mail-qt1-f194.google.com with SMTP id y11so3832879qtn.9 for ; Thu, 01 Oct 2020 03:22:50 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=TfhGEOwCD8FHLioOVqBXNZ7zon0lRTk22WIVFBrFGkI=; b=o6xScIeSd5RRaHf/UCQoWTwddKiD/T7rPlLRtWxwNy9jS6g+iKHpoF23v1Y3bReL2z SbXB8TDE+WCo3k8Uo6+o/nwART5nJgPXcjqeEfEl6keXQvSMdapKLsbMjhqUobqYuH46 6Z5M4mw5xKBX2Da2d/Ruwu1d8uPmsOq8w4yYw7i2WGSLV40lRLC8tOm/XQuZekKCF8Sd y/xVYFEWNSNGB9zL2xRR2nBI/YFb+L5dI3braWuUq2ZcSUD0ZqdrYJuw+LDMuJ8qa2OU LdBBeW4ZcYldw588nZm+D8gI11stbXO4GyJRe3m8C5Ow+pKuguDHSc/In2df9U5jsvF+ t1hQ== 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=TfhGEOwCD8FHLioOVqBXNZ7zon0lRTk22WIVFBrFGkI=; b=CBBZHYYCoWugiK0jAeJXxQRNvDwx9AlVLObgXQPQHfzNfAxQwKXxuyFAqLHNLEtBBy a3Prl+qYsmadv3n2cmSdTRaUzk7+TrlDyVX7aLRwNGMnaZoJ+JbH/wPcBCS/V2LK8CU0 RfCMGXVSVpZk4Drxa/9c0s1oT9XQWY3seEhjCKXWCHqDzg8Qfe9n9/1tv5+A7FGJC6yC /pL6hmO1/N7IpvM2LNRUnl9IQgbvIuohK5xOll0BBUzqRkgHlCw5oxsKgmBjtkhuxVMY NPnryiTXdt7urbUcsi7nMl1vdwstyWBUHVjNgkPc22zdW0RWkj4plzGLpPJvKxUUWKhT XUOw== X-Gm-Message-State: AOAM5307B8b6u6aXRQstXAiQubizZNaoG6X7swmo1rddoEHfPULCaqNJ QL5KGUrhSGkXFcSElJSweMC4tDimT4J10g== X-Google-Smtp-Source: ABdhPJyHdvcujaaJ7nkuI9irwxpm1G/BJHExk8JNKLFiIYNYKzCwKRp4fvFXOFOy5+Zv5xuAefL/dg== X-Received: by 2002:ac8:1a7b:: with SMTP id q56mr6736136qtk.56.1601547770297; Thu, 01 Oct 2020 03:22:50 -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 q185sm5662399qke.25.2020.10.01.03.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 03:22:49 -0700 (PDT) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: olivier.matz@6wind.com, Chas Williams <3chas3@gmail.com> Date: Thu, 1 Oct 2020 06:22:44 -0400 Message-Id: <20201001102245.326223-1-3chas3@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200928153219.285343-1-3chas3@gmail.com> References: <20200928153219.285343-1-3chas3@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 1/2] 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. Otherwise, return failure. Fixes: c442fed81bb9 ("net: add function to calculate checksum in mbuf") Signed-off-by: Chas Williams <3chas3@gmail.com> --- lib/librte_net/rte_ip.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index fcd1eb342..b2bb5d7b9 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -225,6 +225,9 @@ rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len, break; off -= seglen; } + RTE_ASSERT(seg != NULL); + if (seg == NULL) + return -1; seglen -= off; buf = rte_pktmbuf_mtod_offset(seg, const char *, off); if (seglen >= len) { -- 2.26.2