From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0065.outbound.protection.outlook.com [104.47.1.65]) by dpdk.org (Postfix) with ESMTP id 141B32BFA for ; Tue, 11 Sep 2018 20:16:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GtTy9D6bbwgAruhNg7kMHd1xAUyxUe1c19unb5JTXr8=; b=IC7XJHOs+SkeOKkelTCGjnB9IPpE6eUpatLdg3TCJuIt0+JUL/S6k1W+KT0AuqvEzj8RYhEuK+HmkospQviy+hMjAGC0YLvmfhZuTpSKf1aQ3V9VCSgYHsvOBTl9VKNI/NTLNJeH64rTnUzrBpsgSF3xvDvbR5xccd3uvDMMTfg= Received: from AM0PR0502MB3971.eurprd05.prod.outlook.com (52.133.40.151) by AM0PR0502MB3937.eurprd05.prod.outlook.com (52.133.40.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Tue, 11 Sep 2018 18:16:00 +0000 Received: from AM0PR0502MB3971.eurprd05.prod.outlook.com ([fe80::5820:f754:a323:a19d]) by AM0PR0502MB3971.eurprd05.prod.outlook.com ([fe80::5820:f754:a323:a19d%5]) with mapi id 15.20.1122.019; Tue, 11 Sep 2018 18:16:00 +0000 From: Yongseok Koh To: David Marchand CC: "dev@dpdk.org" , "olivier.matz@6wind.com" , "wenzhuo.lu@intel.com" , "jingjing.wu@intel.com" , "bernard.iremonger@intel.com" Thread-Topic: [dpdk-dev] [PATCH 1/3] mbuf: add sanity checks on segment metadata Thread-Index: AQHUSMmTV86Yci/J/kmiGsqnE/MbA6TrZWeA Date: Tue, 11 Sep 2018 18:16:00 +0000 Message-ID: <66B1F5CF-996B-4454-B4A6-25C799649860@mellanox.com> References: <20180910054547.18494-1-david.marchand@6wind.com> <20180910054547.18494-2-david.marchand@6wind.com> In-Reply-To: <20180910054547.18494-2-david.marchand@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR0502MB3937; 6:5ughtoXV8YIYtfo52+1sUgBgjCeL1Vz8jYNYIugufTLCDx1ux8MLuV4W3KGLwIbRGn5cMiKtHifh/xp7hcGAv8sGVeaIZab4Atg19N8OFUUK0KG62hmpIA8fBu4imbf3F00fpPkyzItW9uTSXrpWZ4uICX6lyJP+6msYoGc9j0HBDdklMqMZe4P3vJrUyo+weLxbAKsjdFp15z3XItHExc+sYBQ429DhG2JN1zihhAmkodHYEUsG+nVxJydHLlcGFfwKU08nY/LaST6cLQgQAwkdkNiVODJzPzVMtUtM6y/NCrBcapp92x52C6L06OFVB5w80wuGuGJE0reXZSLEiinM7bNrYHlhbWjJlAlXBiX+R1KWDWkqw0VR9nFYfbxRB5el2fPHPdF+1OBxlPpdYw84M6WqUPIgmz+2We0d1jHsPRlq5yPsK2rJn3jLxIdRui7Xsd0UisCwGsMvlFE7Zw==; 5:6P2gzwZy9xPAD8wgai5bzT1xMFCE3pxFEv8ACA8rygAKeJOh3VPI1/MFIIE/zQ2Yyq5ScPS3S2vYqw7+RjOI0mHoyPdZuXTGTyItd3SYekuV9PqGhcl5FEhmBTd7RHpEOEy8qv4GPBJl+l/CZkOUj3xv0GuN5OzDGGywiKtLG7I=; 7:NjQCRXfxHjCZvyohZb2N5VB9s7sQ9X9rbRJsUDgCc+fWebiSa6JHNHVFg+qRc1ckSOBQp9vcP1+6sQZTtX0iWsADxg5NEbBaG9jrw9ufF8oZH3Lm6g1ixck5b4EZ6SaYoiX8rjcbUCHckTyDw1x5o/OaqtuR99CAuct3vJBpOc7+pWBi9QR+8qN7shwo/k6GL4F2B+3wkTngv0T3WZ7oqieAG2VXbYK7np3GH5qQBb03iOmE6Xpi+g8n2UDFS99x x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 578804a7-cc2c-4d39-b3e7-08d61812a0ba x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR0502MB3937; x-ms-traffictypediagnostic: AM0PR0502MB3937: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699050); SRVR:AM0PR0502MB3937; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0502MB3937; x-forefront-prvs: 0792DBEAD0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(376002)(396003)(366004)(346002)(189003)(199004)(54906003)(66066001)(53546011)(446003)(6436002)(2906002)(6506007)(229853002)(6486002)(76176011)(7736002)(6916009)(99286004)(14454004)(6512007)(316002)(8676002)(2616005)(478600001)(476003)(305945005)(53936002)(11346002)(5660300001)(6116002)(36756003)(8936002)(5250100002)(186003)(83716003)(102836004)(486006)(82746002)(105586002)(3846002)(106356001)(256004)(26005)(25786009)(33656002)(68736007)(97736004)(81156014)(81166006)(86362001)(6246003)(4326008)(2900100001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3937; H:AM0PR0502MB3971.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Jn6l8ImowBg4L9me556XtOZuieWmJ7ZmrghA0OecvHio0lvcoP4gBYnwD/851BUcfuVBtFn+G2kzvXXGAoGHPI70JCntI0XY2pgBhuwuS4VvgxsA66fBRmjYhxgRu8g7A0rqcyCsFeXhSGua2Ah7slnieplN0JVPiMqnG7ktMe1kjOWzrE6ykWXqtK/VhknJPymEsr7mdtYJtcZE87JMtkQ3JLTmtHug+RTYQDlAzDmBLhWDj/CfnxhBLrYSJoTBC2OGO/E+wkszecbAbHMoQru3fVWq0ZY4aR+jNqFS5f2ZkPOElZubYHL8nCxSFCXkdVP5SG5yJaPwZY2KCH46JLTZ5zTK7LB6h9cdbXzghk4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <0A690D75E0E2FB41B3AD8ECB2F035DDB@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 578804a7-cc2c-4d39-b3e7-08d61812a0ba X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Sep 2018 18:16:00.2710 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3937 Subject: Re: [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: Tue, 11 Sep 2018 18:16:03 -0000 > On Sep 9, 2018, at 10:45 PM, David Marchand wr= ote: >=20 > Add some basic checks on the segments offset and length metadata: > always funny to have a < 0 tailroom cast to uint16_t ;-). >=20 > Signed-off-by: David Marchand > --- > lib/librte_mbuf/rte_mbuf.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > 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 =3D m->pkt_len; >=20 > 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) Casting to uint32_t is needed? All of the three fields are uint16_t and it = would anyway happen because of the integer promotion rule. Right? Thanks, Yongseok > + rte_panic("data length too big in mbuf segment\n"); > nb_segs -=3D 1; > pkt_len -=3D m->data_len; > } while ((m =3D m->next) !=3D NULL); > --=20 > 2.17.1 >=20