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 EF80FA0093 for ; Thu, 11 Jun 2020 17:27:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F4BD1252; Thu, 11 Jun 2020 17:27:06 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 55F101515; Thu, 11 Jun 2020 17:27:04 +0200 (CEST) IronPort-SDR: iNEAC9mytCJfGRqWXod4cso89esHbSd2glcyIVdpAIUKFiDgVO6rb0AarVhG6XvHb8/P3E3iCE vYqo9WCfZwHg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 08:27:03 -0700 IronPort-SDR: 4SyNlQB8d38lsc1qYhDoIHPFZXZUrzfiEgb3BbZtbQFB/q8p23BYAlE5msikybkpQoViCaAXVr 34ibTbKMmkqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="275366391" Received: from dpdk_yexl_af_xdp.sh.intel.com ([10.67.119.201]) by orsmga006.jf.intel.com with ESMTP; 11 Jun 2020 08:27:01 -0700 From: Xiaolong Ye To: Olivier Matz , Thomas Monjalon , Konstantin Ananyev Cc: dev@dpdk.org, Xiaolong Ye , stable@dpdk.org Date: Thu, 11 Jun 2020 23:12:10 +0800 Message-Id: <20200611151210.11508-1-xiaolong.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200610150845.82462-1-xiaolong.ye@intel.com> References: <20200610150845.82462-1-xiaolong.ye@intel.com> Subject: [dpdk-stable] [PATCH v3] mbuf: fix out-of-bounds access at dyn field register X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" We should make sure off + size < sizeof(struct rte_mbuf) to avoid possible out-of-bounds access of free_space array, there is no issue currently due to the low bits of free_flags (which is adjacent to free_space) are always set to 0. But we shouldn't rely on it since it's fragile and layout of struct mbuf_dyn_shm may be changed in the future. This patch adds boundary check explicitly to avoid potential risk of out-of-bounds access. Fixes: 4958ca3a443a ("mbuf: support dynamic fields and flags") Cc: stable@dpdk.org Signed-off-by: Xiaolong Ye --- V3: update subject as Olivier suggested lib/librte_mbuf/rte_mbuf_dyn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_mbuf/rte_mbuf_dyn.c b/lib/librte_mbuf/rte_mbuf_dyn.c index d6931f847..9d6388cff 100644 --- a/lib/librte_mbuf/rte_mbuf_dyn.c +++ b/lib/librte_mbuf/rte_mbuf_dyn.c @@ -71,7 +71,8 @@ process_score(void) for (off = 0; off < sizeof(struct rte_mbuf); off++) { /* get the size of the free zone */ - for (size = 0; shm->free_space[off + size]; size++) + for (size = 0; (off + size) < sizeof(struct rte_mbuf) && + shm->free_space[off + size]; size++) ; if (size == 0) continue; -- 2.17.1