From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 9959A10A3 for ; Mon, 13 Aug 2018 18:04:25 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id i134-v6so806409wmf.0 for ; Mon, 13 Aug 2018 09:04:25 -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; bh=vL1TzIqTe1LAOJkHIuM54CcHasjpoqL1GCaSc7X86FQ=; b=N0cGte2bjjCCSdVj4CYJaXc88nwc1lRIdf8Km2JDa3DmEl+LIT1YjXYNLDeywNabBm 41uir7G3eTpDrT01zBxmz4Vgxi2mj7Oc6GV9zBE854pN8WsL3/l73PVdgIoDFG9tKWX4 YGzMZjwzOcJlNVbIXDWM0nn2vJZeOHhHNkf+O9Ojcn16uPYKXGgpIRsvzLun1+iKoq0/ nVLQSzPlUa2niZYQTnfwi/kHuakKbUZDcFv9uJXjxxL628j9NsjCeN4ZgpHKGM8QHECa ZJ2j3EoolSI6/i3Std08nMQ5FqFL0qYZMsVdYbsbBCbIr2SOAJUdwLAT6+0N1mRywhpu 1eRA== 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; bh=vL1TzIqTe1LAOJkHIuM54CcHasjpoqL1GCaSc7X86FQ=; b=sXUPkJULhUU9qMxtWDjwkMntUUgCd4N5eKZdr0CCSsnvvrPKQfBBYGgf4t/vhQ6TKR Hoos4TfAqVEMkl+4kMzf8ghMmtiFJ+Heo+zSdEJN1phcVrcmKLojIjL8m1A4nV3aRvVK 0w3sQmWiGHbarfsgI1d0lgtMgPKgwUPFUSwLZ1seCwel8HfYs11G34F+NV0yp35UBdP6 OZy8ZTVRKztZXiMR8PlRuEnCUyFPKB7uiq9Z+KSDpt06nrlv2OWq4Kmr8SaKN6oarabM ejRTAHWpOBYeggw5KVPXqpXbYOZrHeREZWHMj+9RjVStLkFjbjeyfKgy5KcuyPequqPV mjaA== X-Gm-Message-State: AOUpUlHkrEdfbqyQNRwcrUZ5lo9bPmqw9KfNrLdgyk46axyETHRkm/Pt ld5GdbKkC+aKKnSt/lBpprehCwAsW9w= X-Google-Smtp-Source: AA+uWPzbTXNUV16A7VtpXd2rMXhu+eeRqkvlk94yFlS2bZZOjnX6XPf6tE+dalrRfm3Hp4Vnlc//mA== X-Received: by 2002:a1c:202:: with SMTP id 2-v6mr8134097wmc.91.1534176265012; Mon, 13 Aug 2018 09:04:25 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id m207-v6sm10613247wma.31.2018.08.13.09.04.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Aug 2018 09:04:24 -0700 (PDT) From: David Marchand To: dev@dpdk.org Cc: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz Date: Mon, 13 Aug 2018 18:03:45 +0200 Message-Id: <1534176226-21911-1-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [RFC 1/2] mbuf: add a sanity check 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, 13 Aug 2018 16:04:25 -0000 Add some basic check 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index e714c5a..7eeef12 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -200,6 +200,8 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) pkt_len = m->pkt_len; do { + if (m->data_off + m->data_len > m->buf_len) + rte_panic("bad segment metadata\n"); nb_segs -= 1; pkt_len -= m->data_len; } while ((m = m->next) != NULL); -- 2.7.4