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 77F1CA051F; Wed, 10 Jun 2020 17:23:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 169091BF46; Wed, 10 Jun 2020 17:23:40 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 65B451BF3C; Wed, 10 Jun 2020 17:23:38 +0200 (CEST) IronPort-SDR: 6blZCJZfvNovCc0S9+AbRWpgZx24AAE9teP+QBCi9gHRUO6NWQUQIjaoZo7R+yw7AjWJ4jKUoZ sOeVnjXNWhsw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2020 08:23:36 -0700 IronPort-SDR: q8XFxMS3Biasx+gm8NyVMqP6hZT2rZluRKZ6PvsDIDUkMV86UUUfQZMQTJnTly+cKpMt6Lc4Ee HsshEuMqPFLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,496,1583222400"; d="scan'208";a="473371290" Received: from dpdk_yexl_af_xdp.sh.intel.com ([10.67.119.201]) by fmsmga006.fm.intel.com with ESMTP; 10 Jun 2020 08:23:34 -0700 From: Xiaolong Ye To: Olivier Matz , Konstantin Ananyev , Thomas Monjalon Cc: dev@dpdk.org, Xiaolong Ye , stable@dpdk.org Date: Wed, 10 Jun 2020 23:08:45 +0800 Message-Id: <20200610150845.82462-1-xiaolong.ye@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] mbuf: fix out-of-bounds access 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" 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 --- 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..8af89dde4 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; shm->free_space[off + size] && + (off + size) < sizeof(struct rte_mbuf); size++) ; if (size == 0) continue; -- 2.17.1