From patchwork Fri Jan 20 04:41:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122399 X-Patchwork-Delegate: thomas@monjalon.net 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 30C624242A; Fri, 20 Jan 2023 05:42:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56E7042D9F; Fri, 20 Jan 2023 05:41:54 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id D9DF540223 for ; Fri, 20 Jan 2023 05:41:51 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1845861DFF; Fri, 20 Jan 2023 04:41:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F32ACC433F1; Fri, 20 Jan 2023 04:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189710; bh=FaS3SzHlXHGou9wl3yM4zcmfJ3tMtgw8yUdefcdotOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gS4FEkMc3RDPyeLnWxLfU30wdjMvVwMksQvxyDvor1Mp5tjIdylerT+MhR06iYxWW n4ubwWZ7xAoVWvNkJ9fyEteoV7IXZ3MDWWWcMXawTC2bx3wMqu8nBmyBc+uHxGAM8H YCMLPfF/YfO3z02JeOeeGHBQ2dnk7wS8tsY1wq+a6SVALeriSG564VdGKXdvoW9JQj 4AYgHX8vgEyrYbyLlYdaAG9Pojmvxpbx9T9xnhAkVWT6rVFQX62UeVbJMdktkL72ji ysHtu3p7mr8FVh+dBEgjheobzh/o+/4HsA05OCQ/RHPq9H1gQ3S3D4ctGjQldkmnqJ m2BYkHEa4mfWA== From: okaya@kernel.org To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 01/10] ethdev: check return result of rte_eth_dev_info_get Date: Thu, 19 Jan 2023 23:41:31 -0500 Message-Id: <20230120044140.95975-2-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya rte_class_eth: eth_mac_cmp: The status of this call to rte_eth_dev_info_get is not checked, potentially leaving dev_info uninitialized. Signed-off-by: Sinan Kaya Reviewed-by: Morten Brørup --- lib/ethdev/rte_class_eth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c index 838b3a8f9f..559ce22491 100644 --- a/lib/ethdev/rte_class_eth.c +++ b/lib/ethdev/rte_class_eth.c @@ -50,8 +50,10 @@ eth_mac_cmp(const char *key __rte_unused, if (rte_ether_unformat_addr(value, &mac) < 0) return -1; /* invalid devargs value */ + if (rte_eth_dev_info_get(data->port_id, &dev_info) < 0) + return -1; + /* Return 0 if devargs MAC is matching one of the device MACs. */ - rte_eth_dev_info_get(data->port_id, &dev_info); for (index = 0; index < dev_info.max_mac_addrs; index++) if (rte_is_same_ether_addr(&mac, &data->mac_addrs[index])) return 0; From patchwork Fri Jan 20 04:41:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122398 X-Patchwork-Delegate: thomas@monjalon.net 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 031EE4242A; Fri, 20 Jan 2023 05:41:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CA6A42D14; Fri, 20 Jan 2023 05:41:53 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id D57F9400D5 for ; Fri, 20 Jan 2023 05:41:51 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 50B6C61E02; Fri, 20 Jan 2023 04:41:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C065CC433EF; Fri, 20 Jan 2023 04:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189711; bh=K5pugBFGoxJAPUF3ZEC7fWyznWQWud30IQqSknljZ7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLQCL1hJJn45IzGbXGduV5UM9Xdw707LNYxyfAzjciMr56xB3Nk2MGbJTyukycm7j WsKB9uflB24mihiQsXp3Hs6mwNyTZrwLGN79uR8G0CwcuF6nsmy0KU+7+WPgb316Jc 149bFawBTDXH9BzU0oGP04eoDvRBC3kErd/nVFo/+fPzbzFaBcFuw6Mzfb1FhkCUKO F6ZBR88vSGp8SuklFYEFlrnhtQZUX8TT4ZpsnwEpSdDWcOTE/3G3RjhWZX6fRCDSz5 bNJrfQUvT7uSECRRRV5SIinKO4s7PSE5lk2DJIFkqzbdpc52PtctHohcAZYhf4aYx2 RJrHC8BoXXpig== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 02/10] memzone: check result of rte_fbarray_get Date: Thu, 19 Jan 2023 23:41:32 -0500 Message-Id: <20230120044140.95975-3-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In memzone_lookup_thread_unsafe result of call to rte_fbarray_get is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memzone.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 860fb5fb64..8d472505eb 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -41,7 +41,7 @@ memzone_lookup_thread_unsafe(const char *name) i = rte_fbarray_find_next_used(arr, 0); while (i >= 0) { mz = rte_fbarray_get(arr, i); - if (mz->addr != NULL && + if ((mz != NULL) && (mz->addr != NULL) && !strncmp(name, mz->name, RTE_MEMZONE_NAMESIZE)) return mz; i = rte_fbarray_find_next_used(arr, i + 1); @@ -358,6 +358,10 @@ dump_memzone(const struct rte_memzone *mz, void *arg) fprintf(f, "physical segments used:\n"); ms_idx = RTE_PTR_DIFF(mz->addr, msl->base_va) / page_sz; ms = rte_fbarray_get(&msl->memseg_arr, ms_idx); + if (ms == NULL) { + RTE_LOG(DEBUG, EAL, "Skipping bad memzone\n"); + return; + } do { fprintf(f, " addr: %p iova: 0x%" PRIx64 " " From patchwork Fri Jan 20 04:41:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122400 X-Patchwork-Delegate: thomas@monjalon.net 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 31ADA4242A; Fri, 20 Jan 2023 05:42:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C568442DB4; Fri, 20 Jan 2023 05:41:56 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id D3BA641101 for ; Fri, 20 Jan 2023 05:41:52 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5832B615FE; Fri, 20 Jan 2023 04:41:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6866BC433EF; Fri, 20 Jan 2023 04:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189711; bh=VjI2Ec8kMto3iRfsRyn5fX9hQQiC6ztV5fVsgiMS9yw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ObaN/NVXe5VKl3HtehwIFBRD/9pI/nRV3Y2me1l/067vmuF3VTJIdRBxrh/4SChPk Uyw343Urd40HgfovU9Hh9KtNSNdcbRBGGsJ7wJjYwhTk5eGb7pINcyvYR+YpR954tC FTtzgBVotKnXcXfPdkG1ra2g+JRsYbSknlglgvk8uE5Xjz8rWOjdx2vkT8YJUJmlOC wI4dKXebPWa73/4sn6gumZPxzWZBBOSojVWKmZOZOvOlGeYmC/YMLPSGcKbAAaImDs 6swbL8juSQ5nYysqCvyoNZPWvDSenzId53O8HHtoN7l9SHVWtCNrTD/TKtZQ5O0x0Q 7F+XyPcnjjvuQ== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 03/10] memzone: check result of malloc_elem_from_data Date: Thu, 19 Jan 2023 23:41:33 -0500 Message-Id: <20230120044140.95975-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In memzone_reserve_aligned_thread_unsafe result of call to malloc_elem_from_data is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memzone.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 8d472505eb..930fee5fdc 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -169,6 +169,10 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, } struct malloc_elem *elem = malloc_elem_from_data(mz_addr); + if (elem == NULL) { + rte_errno = ENOSPC; + return NULL; + } /* fill the zone in config */ mz_idx = rte_fbarray_find_next_free(arr, 0); From patchwork Fri Jan 20 04:41:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122401 X-Patchwork-Delegate: thomas@monjalon.net 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 8EDAA4242A; Fri, 20 Jan 2023 05:42:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A82E42DB8; Fri, 20 Jan 2023 05:41:57 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 1A64642D14 for ; Fri, 20 Jan 2023 05:41:53 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9445861E05; Fri, 20 Jan 2023 04:41:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1278CC433F0; Fri, 20 Jan 2023 04:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189712; bh=e6AgEAXqwllsqVV5gZDAaE6+cqbUME7lx6SR302L8wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VwjJ4tV8sKcwM0vql26CN1Wy9kXUffk28SRE+gXfGdjCBlSWdG7dfER1bxSxLp4b3 cX1YFUEYUvPo1FDQ+IEl82h99cdFzRWTGvrm0+TL13R4tqvmtXwqdS1JBvx+Zdx0+J zMs4nKqA+PeFBxwMC9JcE/r8t5L5WoTTO5D0z24P/jfBjqXWoVxsah4iaURX2u3Zw5 Fb24a7zdVlxq43y3TMi/PhKqB0SHlGcTF+CXILKRP/c//ykH/SkZV7BWxr7M1zjx0D ZzkiB43Da6XcOPfZQUk3h+O0MK16yd25835xs6hZHCMYkp7d0CMfRhIk5Hyqa3bglW aCf25aBEMmL8g== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 04/10] malloc: malloc_elem_join_adjacent_free can return null Date: Thu, 19 Jan 2023 23:41:34 -0500 Message-Id: <20230120044140.95975-5-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In malloc_heap_add_memory result of call to malloc_elem_join_adjacent_free is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/malloc_heap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index d7c410b786..503e551bf9 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -97,6 +97,8 @@ malloc_heap_add_memory(struct malloc_heap *heap, struct rte_memseg_list *msl, malloc_elem_insert(elem); elem = malloc_elem_join_adjacent_free(elem); + if (elem == NULL) + return NULL; malloc_elem_free_list_insert(elem); From patchwork Fri Jan 20 04:41:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122402 X-Patchwork-Delegate: thomas@monjalon.net 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 6886E4242A; Fri, 20 Jan 2023 05:42:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6BD0642DBE; Fri, 20 Jan 2023 05:41:58 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id A961C42D65 for ; Fri, 20 Jan 2023 05:41:53 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 37F8B61E06; Fri, 20 Jan 2023 04:41:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACC78C433EF; Fri, 20 Jan 2023 04:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189713; bh=OA9aKvIimBSPp+xtTJJVhYWAQ4KuSadN9gXKHvpeV1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PyI7NGUpdhBFRF5bud7SmadwEs70zI1TwHTO0KBrbBAP7kk94al8RZyih1idr/S4U I/PqdayNYL2WwzEZ230I22XcIfjfQbQ4XzyojtweJbKNl1s3/Q8vWcRqqiDfaDnYVF BUrXRfWi6FLtO6sPUnUJMpBfID3OlXVONgoSNxR19nuF6FlibXnIT+p5WxB/twzLmk xxdziznSW/RBCuKJwkkbO6veuyXKpOSBSzikfKWuRag/uUK/nomLeJpW6cySAESZaM W62OPF/N9YALF8Ccq3Puz1VECxJ307s9HM/vvvNFNsYqtDdHdpQewBJxuEsA+75FPy zCASTAGYEafbw== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 05/10] malloc: check result of rte_mem_virt2memseg_list Date: Thu, 19 Jan 2023 23:41:35 -0500 Message-Id: <20230120044140.95975-6-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In alloc_pages_on_heap result of call to rte_mem_virt2memseg_list is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/malloc_heap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 503e551bf9..3f41430e42 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -323,6 +323,8 @@ alloc_pages_on_heap(struct malloc_heap *heap, uint64_t pg_sz, size_t elt_size, map_addr = ms[0]->addr; msl = rte_mem_virt2memseg_list(map_addr); + if (msl == NULL) + return NULL; /* check if we wanted contiguous memory but didn't get it */ if (contig && !eal_memalloc_is_contig(msl, map_addr, alloc_sz)) { From patchwork Fri Jan 20 04:41:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122403 X-Patchwork-Delegate: thomas@monjalon.net 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 C30554242A; Fri, 20 Jan 2023 05:42:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B1C642DC7; Fri, 20 Jan 2023 05:41:59 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id B364B42DA1 for ; Fri, 20 Jan 2023 05:41:54 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 39CA2615FE; Fri, 20 Jan 2023 04:41:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E126C433F0; Fri, 20 Jan 2023 04:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189713; bh=b9XPdlFmqr0VZaZ/G6xeC3g+pdTGxgCDoDwiCqKPQLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sgvl5p7p+8qTDpeSTim8IPZZhATQcQkDXqAtNJldi9Vo+RjZcx33ZhHFNFzmRKjko 3TyGG/mMjoB7Ttnv5Kg6kjMBdsfQwyac/nNKzW2T7bLJEsqE7UEpWBqtl3j1hI3bcE l9zs8vL0pDZtB8+RY4Sg0caUN4lCcfbbAcjRd+57oTYAPKfIReLbRkP6Y2Yw5COaPV xWzvDxlICJ8PW6JWSlSqASFnnERbAFBt2bhnlaG/9IDu7d4v1O5keHa2FFNr125xdi ihugI/Xd39ygS4QaderErySKVe9cdG0sf3Y/3lXrUBSE/xahKnu1qlFar79PGKwaCi DrsGXl/+OU++g== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 06/10] malloc: check result of rte_fbarray_get Date: Thu, 19 Jan 2023 23:41:36 -0500 Message-Id: <20230120044140.95975-7-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In eal_memalloc_is_contig result of call to rte_fbarray_get is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memalloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_memalloc.c b/lib/eal/common/eal_common_memalloc.c index ab04479c1c..24506f8447 100644 --- a/lib/eal/common/eal_common_memalloc.c +++ b/lib/eal/common/eal_common_memalloc.c @@ -126,6 +126,9 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start, /* skip first iteration */ ms = rte_fbarray_get(&msl->memseg_arr, start_seg); + if (ms == NULL) + return false; + cur = ms->iova; expected = cur + pgsz; @@ -137,7 +140,7 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start, cur_seg++, expected += pgsz) { ms = rte_fbarray_get(&msl->memseg_arr, cur_seg); - if (ms->iova != expected) + if ((ms != NULL) && (ms->iova != expected)) return false; } } From patchwork Fri Jan 20 04:41:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122404 X-Patchwork-Delegate: thomas@monjalon.net 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 BEFCD4242A; Fri, 20 Jan 2023 05:42:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1640842DCD; Fri, 20 Jan 2023 05:42:00 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id D193A42DAE for ; Fri, 20 Jan 2023 05:41:55 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9B784B81AFA; Fri, 20 Jan 2023 04:41:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3722C433D2; Fri, 20 Jan 2023 04:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189714; bh=W2hMNo666ixKADSmKcIGEqrJdVzX4Yclf2h5OFo6Gqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCbm/0UqmmvjRJuf9zMow/N04aUhN8A6bmOAoMSI6/suMBZnsB8oj8gcvr3/+b3hY Mme68pGwc1N8H3YbrnY5Fy3Mseo1hmjRAxLsdOCq2NxOHdaS58BUkBeSLyGD/l5mIR DUD6HmXWS3POQVz++9xFeNVAnLUKacvWOw1MFNgFLKnHY4/AaTLgho+pufiLSz86z4 ZqhZRHQ8TVH+jFfwq+2M/fhn2ebF6aGW1ux4UygCUAtTzWc771pYT0xUXkd4Wqj/OO L4OdNZyc3wBGSBjDZjNiVOR+ctdxRTIeWj2S8xZmQ95kXChtFd5wNZUCRJibr2Xzn5 pRP6R/+Hjn9Ng== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 07/10] malloc: check result of rte_mem_virt2memseg Date: Thu, 19 Jan 2023 23:41:37 -0500 Message-Id: <20230120044140.95975-8-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In malloc_elem_find_max_iova_contig result of call to rte_mem_virt2memseg is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/malloc_elem.c | 11 ++++++++--- lib/eal/common/malloc_heap.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/eal/common/malloc_elem.c b/lib/eal/common/malloc_elem.c index 83f05497cc..8f49812846 100644 --- a/lib/eal/common/malloc_elem.c +++ b/lib/eal/common/malloc_elem.c @@ -63,6 +63,8 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align) cur_page = RTE_PTR_ALIGN_FLOOR(contig_seg_start, page_sz); ms = rte_mem_virt2memseg(cur_page, elem->msl); + if (ms == NULL) + return 0; /* do first iteration outside the loop */ page_end = RTE_PTR_ADD(cur_page, page_sz); @@ -91,9 +93,12 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align) * we're not blowing past data end. */ ms = rte_mem_virt2memseg(contig_seg_start, elem->msl); - cur_page = ms->addr; - /* don't trigger another recalculation */ - expected_iova = ms->iova; + if (ms != NULL) { + cur_page = ms->addr; + + /* don't trigger another recalculation */ + expected_iova = ms->iova; + } continue; } /* cur_seg_end ends on a page boundary or on data end. if we're diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 3f41430e42..88270ce4d2 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -930,7 +930,7 @@ malloc_heap_free(struct malloc_elem *elem) const struct rte_memseg *tmp = rte_mem_virt2memseg(aligned_start, msl); - if (tmp->flags & RTE_MEMSEG_FLAG_DO_NOT_FREE) { + if ((tmp != NULL) && (tmp->flags & RTE_MEMSEG_FLAG_DO_NOT_FREE)) { /* this is an unfreeable segment, so move start */ aligned_start = RTE_PTR_ADD(tmp->addr, tmp->len); } From patchwork Fri Jan 20 04:41:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122405 X-Patchwork-Delegate: thomas@monjalon.net 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 4BED44242A; Fri, 20 Jan 2023 05:42:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E430642DCE; Fri, 20 Jan 2023 05:42:00 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 7D50642DAE for ; Fri, 20 Jan 2023 05:41:56 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 49DB3B81FB6; Fri, 20 Jan 2023 04:41:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D2B6C433EF; Fri, 20 Jan 2023 04:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189715; bh=RigiKorR3dMZBI+SxDLNAndkSDREvu4zoNk+V8ONMkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mtIhrJwhMkVjhDiq6agdbl3TCZkMRCv8YIt11eu+Hl8ewl5xjlVi091S6BlHIkiXs UV97rQsuvqEiGgpVaIs+ySi5jGkhRccaXM37Rh+f9LbOlRW2YalSdhgmtUbblXT5Kr KuibAOsMOybS2ZBrEZgP/VYJ1r8HOaNfon/H8wz5PErGA4GSmED9v2a+qY5PtIuBjy DJfWrHg2rQmYQ1L2pOnSwPK8kYPhDb4FpwIcwHP0GZ4aGWrwF8CswnYyMuJLzNqCcI +pf/s0GjXeIPjA6E9sM6DNYTVDok4BfwRgdx+6Z8gbLPTkGUQIrY2ZFAdjObOG5kTb 7hODYkpV36cJw== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 08/10] malloc: check result of malloc_elem_free Date: Thu, 19 Jan 2023 23:41:38 -0500 Message-Id: <20230120044140.95975-9-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In malloc_heap_free result of call to malloc_elem_free is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/malloc_heap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 88270ce4d2..6eb6fcda5e 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -892,6 +892,9 @@ malloc_heap_free(struct malloc_elem *elem) /* anything after this is a bonus */ ret = 0; + if (elem == NULL) + goto free_unlock; + /* ...of which we can't avail if we are in legacy mode, or if this is an * externally allocated segment. */ From patchwork Fri Jan 20 04:41:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122406 X-Patchwork-Delegate: thomas@monjalon.net 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 DBC8E4242A; Fri, 20 Jan 2023 05:42:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C14A742DD2; Fri, 20 Jan 2023 05:42:01 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 1B62742DB5 for ; Fri, 20 Jan 2023 05:41:57 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DE141B81F5C; Fri, 20 Jan 2023 04:41:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C7E8C433F1; Fri, 20 Jan 2023 04:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189715; bh=Gu6++k0mjtkUURmjVcfqxEPEyPswM/yWIdKGnG3Ae4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNizsPydvf9c8Wz8YtxT66MIlNDRGPMMPeHqbRDVE0fXI19hOmzkPm9/5oZ/COHmq PqvqEfxgZD/y56zM0H+zxd6oMqBiDdvXHBqVtPDZLrQNrQoxa2fb+uOVH/NABnWeG3 SD+n93GNujzBlxaL1f9ZzliKq1MkYk9IoVVfE16DeRIdwc5v/WJe2WBTIvWM5T2QOz HNqsIdFydMJhBxyAAqaEtcuJeNPCIdDb4hIizUF+nMABfTpaq5HL1YqzScrCvsGKaT VgQPXw78PkrR5Wz62+5NkikuKYBFnXJBvkRVeq2rPYTYHXDOr7CVp6JVqJ9AWW/wvH 7trZO1YE7naZA== From: okaya@kernel.org To: Anatoly Burakov Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 09/10] malloc: check result of elem_start_pt Date: Thu, 19 Jan 2023 23:41:39 -0500 Message-Id: <20230120044140.95975-10-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In malloc_elem_alloc result of call to elem_start_pt is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/malloc_elem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/malloc_elem.c b/lib/eal/common/malloc_elem.c index 8f49812846..26296f2dba 100644 --- a/lib/eal/common/malloc_elem.c +++ b/lib/eal/common/malloc_elem.c @@ -435,6 +435,9 @@ malloc_elem_alloc(struct malloc_elem *elem, size_t size, unsigned align, { struct malloc_elem *new_elem = elem_start_pt(elem, size, align, bound, contig); + if (new_elem == NULL) + return NULL; + const size_t old_elem_size = (uintptr_t)new_elem - (uintptr_t)elem; const size_t trailer_size = elem->size - old_elem_size - size - MALLOC_ELEM_OVERHEAD; From patchwork Fri Jan 20 04:41:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 122407 X-Patchwork-Delegate: thomas@monjalon.net 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 3BD524242A; Fri, 20 Jan 2023 05:42:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B1B7C42DD7; Fri, 20 Jan 2023 05:42:02 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id D532B42DA9 for ; Fri, 20 Jan 2023 05:41:57 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A2254B8200A; Fri, 20 Jan 2023 04:41:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2D60C43392; Fri, 20 Jan 2023 04:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674189716; bh=zhQlLud4UOlAbT2TTNLEE5YWdFRWN//Go5LU98Xsdek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MtA5ANmJ8XUT1+IG9VNu7XPbLsBLSzpHM08xMx1KCwRTGcwbYeeJAAxhVqWwqqqfL s58IewSdQPC40Hp7Rat8vHGMpgzyD4qzbTxekFZCXSRFXQjt99lKwkNiffXw0OQ+pt mY0J9rBtHGxSt4MZSx5Bxfhcfmd4EbovR/1hwxcgjX9Pv/6/3mcOEVB8cysvZstTbF 341jao2fnWWgGLZZrfYTFc3FQGz24dwnp7StSrso6XBG+jiTRv8IiRHOs3y5eSGfG/ N7hTcHcn/bhWwsWximK60wBwxcDmALH0+ZBWIx/Zpdd5gVlPSpm6VDzYm3doitNCnq 328uI2wIdfCjw== From: okaya@kernel.org To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org, Sinan Kaya Subject: [PATCH v3 10/10] bus/vdev: check result of rte_vdev_device_name Date: Thu, 19 Jan 2023 23:41:40 -0500 Message-Id: <20230120044140.95975-11-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120044140.95975-1-okaya@kernel.org> References: <20230120044140.95975-1-okaya@kernel.org> 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 From: Sinan Kaya In rte_eth_vdev_allocate result of call to rte_vdev_device_name is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/ethdev/ethdev_vdev.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ethdev/ethdev_vdev.h b/lib/ethdev/ethdev_vdev.h index 364f140f91..6d94a65d97 100644 --- a/lib/ethdev/ethdev_vdev.h +++ b/lib/ethdev/ethdev_vdev.h @@ -34,6 +34,8 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size) { struct rte_eth_dev *eth_dev; const char *name = rte_vdev_device_name(dev); + if (name == NULL) + return NULL; eth_dev = rte_eth_dev_allocate(name); if (!eth_dev)