From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id BAD114C91 for ; Mon, 10 Sep 2018 07:45:55 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id s12-v6so20149498wmc.0 for ; Sun, 09 Sep 2018 22:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mSgd7H/pbd5sYWV0FWi47cIfDXHrYZ8iz9to1Nv+BIA=; b=sV5UEziNirezj5zXqBeslIsNI7eWCCq7tPjxxiNfKclfEvYYjLgNRUCU/l/X9cqsLM VZHxofjrHrwhRQynLjZy3qiszTpAZvYRYAkfDBQdob42Vtiu5FH4uzcopplzyFRk3iFX 5VAedUdY2Q6OiexFD0IAEPEltOaBPrPfLey3LBCrHjPYu7kYUHSVm8GwzaQZ/QnHRG3D OUh4PIiL5/DALZhYexTZICbmsC48jwVgwU+PY4whSo8hxM247QTAlz9XiqkjD2z+jDCU KrrSYPmJXYWXhZFm/iewd174JIpQQb4GParOdMcRGELLcG0nKh92GcdTGEV57uUyvPHt 9lOw== 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; bh=mSgd7H/pbd5sYWV0FWi47cIfDXHrYZ8iz9to1Nv+BIA=; b=b53ZI5z1XIso2VINhccKPfV9lSnlAklCPi/zN3Md1eOa8imdCnxgC3VyUh4ck+dish 2dLUiEGTX6d2Fl2VIZaJtfxK5HNHZS8eNcYW4nL93UBnmaw9oSAEALHhekv4MLSMUCXJ PlydF/+YHhsgGyCQ5cpqHgpGfYcSiWh26OxK2sSNcwkeO63FQv/I/hGbdLtxZmthtflg v0i06YjGRacGoBlY/uIk0rjBYKSvORXsiUbfSv8Qsf0OEUUx0zSjfHR+NH0Qa3rmClFI B41FfZLc7RYSVwvHRLYsw9J2wy4SyxyyRkyd8akrg0mWFrtZs02kU1KPuMArBW3HxRtQ 8qvw== X-Gm-Message-State: APzg51A9Bki0Jv1I/hY/x3RmLJhZL1QB8/HZ6zyAltP30Bk+apcmWpDX UxbMREer68E9LzP2HCauRQy49LS43LE= X-Google-Smtp-Source: ANB0VdZEtLilQTVGOvN+BJFqfPOvJ2oloMl3+/Sk9OWLnRKEHWTHCDE5gwNj8QcvnOxBcgqetU5axA== X-Received: by 2002:a1c:9c56:: with SMTP id f83-v6mr10969197wme.135.1536558355115; Sun, 09 Sep 2018 22:45:55 -0700 (PDT) Received: from 6wind.com ([109.190.253.16]) by smtp.gmail.com with ESMTPSA id t4-v6sm14667473wrb.45.2018.09.09.22.45.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 22:45:54 -0700 (PDT) From: David Marchand To: dev@dpdk.org Cc: olivier.matz@6wind.com, wenzhuo.lu@intel.com, jingjing.wu@intel.com, bernard.iremonger@intel.com Date: Mon, 10 Sep 2018 07:45:45 +0200 Message-Id: <20180910054547.18494-2-david.marchand@6wind.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180910054547.18494-1-david.marchand@6wind.com> References: <20180910054547.18494-1-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH 1/3] mbuf: add sanity checks on segment metadata 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: , X-List-Received-Date: Mon, 10 Sep 2018 05:45:56 -0000 Add some basic checks on the segments offset and length metadata: always funny to have a < 0 tailroom cast to uint16_t ;-). Signed-off-by: David Marchand --- lib/librte_mbuf/rte_mbuf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index e714c5a59..137a320ed 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -200,6 +200,11 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) pkt_len = m->pkt_len; do { + if (m->data_off > m->buf_len) + rte_panic("data offset too big in mbuf segment\n"); + if ((uint32_t)m->data_off + (uint32_t)m->data_len > + (uint32_t)m->buf_len) + rte_panic("data length too big in mbuf segment\n"); nb_segs -= 1; pkt_len -= m->data_len; } while ((m = m->next) != NULL); -- 2.17.1