From patchwork Fri Sep 6 17:04:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Medvedkin X-Patchwork-Id: 143758 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 95CBD45920; Fri, 6 Sep 2024 19:04:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 805C642E82; Fri, 6 Sep 2024 19:04:40 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by mails.dpdk.org (Postfix) with ESMTP id 64349400D5; Fri, 6 Sep 2024 19:04:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725642280; x=1757178280; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yuJFnRgjR7uEVvSg6IgEgesgXoMmgSBvRq8WIxj2bjo=; b=YLqF//gluJq/pAa3FMXZywZa+7oRcKWGzZokigX/6JB/Q3BZV5OEn34Z kCEetwq1Q7TUZeC38dXNH5u08Lw5zGKfyEYTPA+9LzaKe2WN6as2oSSen v6AdZT+qbuDWTbAjh7vn7nEljn7PbIRH4xhtBl26XaD4V6KBmGRfwOHV0 65Cr2ukuIfvQ0+nXHHsuE8qcm4kvqxTBtXLAWCZqcr4CCE/WP231CB/LQ uuCsdO/jlXrfzzA02pFKEnaMFVqG/3b02l7DPLwonQ7/cGc92WeaVLJ36 gsaWVF9qVgWvMGbJrmCbl7O46/mMcEDVLncbbX9nca7dlWZVSLsBLxD4V g==; X-CSE-ConnectionGUID: B9o2xY+VSeemTZeJRgXDVg== X-CSE-MsgGUID: vkW6rbC0RC20as84Ff8cuw== X-IronPort-AV: E=McAfee;i="6700,10204,11187"; a="24558713" X-IronPort-AV: E=Sophos;i="6.10,208,1719903600"; d="scan'208";a="24558713" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2024 10:04:39 -0700 X-CSE-ConnectionGUID: my3jHIl5RR27UDSJQQX2KQ== X-CSE-MsgGUID: FVID6KGKRAyiIlVGdOhUtQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,208,1719903600"; d="scan'208";a="65649934" Received: from silpixa00401176.ir.intel.com ([10.243.22.170]) by fmviesa006.fm.intel.com with ESMTP; 06 Sep 2024 10:04:37 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: stable@dpdk.org Subject: [PATCH] fib: fix vector lookup Date: Fri, 6 Sep 2024 17:04:36 +0000 Message-Id: <20240906170436.1324677-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Vector lookup uses gather instructions which loads data in 4byte chunks. This could lead to out of bounds access at the end of the tbl24 in case of 1 or 2 byte entries if e.g. lookup is attempted for 255.255.255.255 in IPv4 case. This patch fixes potential out of bound access by gather instruction allocating an extra 4 byte in the end of the tbl24. Fixes: 7dc7868b200d ("fib: add DIR24-8 dataplane algorithm") Fixes: c3e12e0f0354 ("fib: add dataplane algorithm for IPv6") Cc: stable@dpdk.org Signed-off-by: Vladimir Medvedkin --- lib/fib/dir24_8.c | 4 ++-- lib/fib/trie.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fib/dir24_8.c b/lib/fib/dir24_8.c index c739e92304..07c324743b 100644 --- a/lib/fib/dir24_8.c +++ b/lib/fib/dir24_8.c @@ -526,8 +526,8 @@ dir24_8_create(const char *name, int socket_id, struct rte_fib_conf *fib_conf) snprintf(mem_name, sizeof(mem_name), "DP_%s", name); dp = rte_zmalloc_socket(name, sizeof(struct dir24_8_tbl) + - DIR24_8_TBL24_NUM_ENT * (1 << nh_sz), RTE_CACHE_LINE_SIZE, - socket_id); + DIR24_8_TBL24_NUM_ENT * (1 << nh_sz) + sizeof(uint32_t), + RTE_CACHE_LINE_SIZE, socket_id); if (dp == NULL) { rte_errno = ENOMEM; return NULL; diff --git a/lib/fib/trie.c b/lib/fib/trie.c index 09470e7287..265135c57d 100644 --- a/lib/fib/trie.c +++ b/lib/fib/trie.c @@ -645,8 +645,8 @@ trie_create(const char *name, int socket_id, snprintf(mem_name, sizeof(mem_name), "DP_%s", name); dp = rte_zmalloc_socket(name, sizeof(struct rte_trie_tbl) + - TRIE_TBL24_NUM_ENT * (1 << nh_sz), RTE_CACHE_LINE_SIZE, - socket_id); + TRIE_TBL24_NUM_ENT * (1 << nh_sz) + sizeof(uint32_t), + RTE_CACHE_LINE_SIZE, socket_id); if (dp == NULL) { rte_errno = ENOMEM; return dp;