From patchwork Mon Nov 21 20:40:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120005 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 CEC9EA056B; Mon, 21 Nov 2022 21:40:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4441842D34; Mon, 21 Nov 2022 21:40:34 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 14EE442D2F for ; Mon, 21 Nov 2022 21:40:33 +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 A8CCFB815DE for ; Mon, 21 Nov 2022 20:40:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B40EFC433D7; Mon, 21 Nov 2022 20:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063231; bh=RgYWMx2bXw0Kf6OSgrUuQ2FaHKOsqLyY7fKYUDdVLR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4JHcw4egEEf/kwJQerUjEG0FZupMjsSfXoMXhFkRydBdIVYrzfkxLrn0v2oNBFQ0 tSYSu/e+4qzAcGm1ZUQgHYqYDVj/1fNfsv2bc+YdIS+Qyr3zIBW+GlNlzcA9ug4D8a rRxRom/Wa4AdvwhhyNj5oqipXBCOwX6P+rd/Z09y8wVtlpm79FFB+IFvwDtjF6PEAc Jy1f8qhEHTt5S0F1+0VAowvfS4MQlECMcFKHiFN412NGcu+p8s1VCDRKk/R70TSotT GwFxnyfqIr/11hQCj+lrBo104mBVHYJav8Yf7Ohq5m14uf8j0hFMd59kG6iRSbZyr5 AtZ69DPxEtQaQ== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 01/11] ethdev: check return result of rte_eth_dev_info_get Date: Mon, 21 Nov 2022 15:40:07 -0500 Message-Id: <20221121204015.1135573-2-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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 --- 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..8165e5adc0 100644 --- a/lib/ethdev/rte_class_eth.c +++ b/lib/ethdev/rte_class_eth.c @@ -51,7 +51,9 @@ eth_mac_cmp(const char *key __rte_unused, return -1; /* invalid devargs value */ /* Return 0 if devargs MAC is matching one of the device MACs. */ - rte_eth_dev_info_get(data->port_id, &dev_info); + if (rte_eth_dev_info_get(data->port_id, &dev_info) < 0) + return -1; + 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 Mon Nov 21 20:40:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120006 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 159A3A056B; Mon, 21 Nov 2022 21:40:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2960542D3A; Mon, 21 Nov 2022 21:40:35 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id 1F81E42D30 for ; Mon, 21 Nov 2022 21:40:33 +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 98F9961458 for ; Mon, 21 Nov 2022 20:40:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1B36C433C1; Mon, 21 Nov 2022 20:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063232; bh=LY5cXO754AO/wuwLzCnfYwK2O6npgtMNjj5OeL1qiOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pI0igQo9lAOk4RXvIlv2mtyMvABhFfGnnT6FdxVy9/fvEPQplGTUF+eN3wqzoz0PO WTMZnGjs8yeke5wpZBQQPqnfxYptJaiBMg2brxqCepssMNMdbnuBzmASfUJZ7LxmUG rmaTpYd49vicl96KrCykFO5MIAoXf1wE5os88HaJwms8kz4kcvXUN1qBLkkUk/5Em2 7k/Q0rbOAdFyYDfb8sll3VTfZbC+dsP8SlNYsgHeHHeMa78E3/M3L2iM8s/ZH8By7+ 1GlX+qFT/e+OHmjTExntn5PSGbOYfxBYSJ/IiQva1ImrQaRWzSpjJ17Qtk6g88qJum ZrqbKoODRM4wQ== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 02/11] net/tap: check if name is null Date: Mon, 21 Nov 2022 15:40:08 -0500 Message-Id: <20221121204015.1135573-3-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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_pmd_tun_probe result of call to rte_vdev_device_name is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- drivers/net/tap/rte_eth_tap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index f2a6c33a19..aa640f8acc 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -2340,6 +2340,10 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev) struct rte_eth_dev *eth_dev; name = rte_vdev_device_name(dev); + if (!name) { + return -1; + } + params = rte_vdev_device_args(dev); memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN); From patchwork Mon Nov 21 20:40:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120009 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 9546FA056B; Mon, 21 Nov 2022 21:40:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31DFA42D4D; Mon, 21 Nov 2022 21:40:38 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 0EB8C42D2F for ; Mon, 21 Nov 2022 21:40:34 +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 D0C88B81608 for ; Mon, 21 Nov 2022 20:40:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49095C4347C; Mon, 21 Nov 2022 20:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063232; bh=inD0RagZjQSj9+hXo5aAH9aiN0aEqDH26GrtV5HWI4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UaH3n+kQWIpC1USQAbRyfSX/dWj0M/xlJZ1p+Zr2L6BM0TUSdDjwWvyXUrZofB/t/ ycvsVV/LKUhgHRBq3aUtZ63pZA945ImjISo/zlOck6nxjo9uZ56y3LGI0flCPCoEHD JRrS6olH3FfCNL5pr6lx3oBeqAeVSI7SH5sXniOtK9bMh9ymyti+tWO/6Tpt1VozUr 8KaSyVV5bmAA3faHL9iBUbefYneSHNPC97fax2TeK+B6AET6Vf6E0cR2Q377Taq1Aa qjv7wt0/Qm6+9bLHUudhOupjOJWARSZTaK9bhbD4A4PTqzcxVu49+ocs02g44FVzAS 59sh3uD83J7Jg== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 03/11] memzone: check result of rte_fbarray_get Date: Mon, 21 Nov 2022 15:40:09 -0500 Message-Id: <20221121204015.1135573-4-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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..0ed03ad337 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 && 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) { + RTE_LOG(DEBUG, EAL, "Skipping bad memzone\n"); + return; + } do { fprintf(f, " addr: %p iova: 0x%" PRIx64 " " From patchwork Mon Nov 21 20:40:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120007 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 A7790A056B; Mon, 21 Nov 2022 21:40:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B0EC42D41; Mon, 21 Nov 2022 21:40:36 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id B422642D2F for ; Mon, 21 Nov 2022 21:40:33 +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 3D62661466 for ; Mon, 21 Nov 2022 20:40:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3B68C433D6; Mon, 21 Nov 2022 20:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063233; bh=la40dExgi0dR4Z07BhXzPuvIKB5xFFiP17RRztKKQUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TyX2zeKA16o3rZNO7tGh5iPXXLcQrXsLMB28Mg9QBUXzticMjynPNWfW8XqChILik VaJ9WAcyodRkjYgb+RLnpNni90rzFczy49zzFauC9S5zSvLr4XgB6vjbzkq/E/a7wj GCHzmSFix1+J6AGAJ5E+Wz+Vd4HP/77hTY0YnfR5sptT+VNtemx2TJK7r38HoXeDxt 1H0gu3nFhvSgMmc4s7l82Ou7jomq7h23mumNc06v16BreBZ0aTHcWyyu67+mVkIovh m9yrwDC3HwiIs4vg2lXCmphbUOcSD5KkYRF6zRqIKE3S+1KFaTzf1uC9oLeXY+GTVM P4wCU5VplMNYw== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 04/11] memzone: check result of malloc_elem_from_data Date: Mon, 21 Nov 2022 15:40:10 -0500 Message-Id: <20221121204015.1135573-5-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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 0ed03ad337..74aa5ac114 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) { + rte_errno = ENOSPC; + return NULL; + } /* fill the zone in config */ mz_idx = rte_fbarray_find_next_free(arr, 0); From patchwork Mon Nov 21 20:40:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120008 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 E97A4A056B; Mon, 21 Nov 2022 21:40:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 533D542D49; Mon, 21 Nov 2022 21:40:37 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 1333542D34 for ; Mon, 21 Nov 2022 21:40:34 +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 D9A0AB81609 for ; Mon, 21 Nov 2022 20:40:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AB65C433B5; Mon, 21 Nov 2022 20:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063233; bh=oHaDV31fM9fCCpa5MAVlnIcPqzO80QaGThP4QaY/wWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzqLwd73viIZGuUKgCvHk7gguu/ZfeiGhv8mdByJTZIBnm3mevT8oeiqh9q94waRc dWp9Kko+gTmiAogTooXJDTMTFG5CdJm/7ZLvanOxxHZ+tw/Tx5IVseFZrL+DnLXBFw xxq3azGA/tQhvoExGMPWoFtTfMzhvTLp8kIIV0yMHJ9KE3Q7Erz7BbHesD6WIfRO69 r103wA8ASR0A56vgtKwQCalDvAE8v9o4XfiI73bihK0Kx+eDNXotF+WrKtnvxxSp7L 9T7niD+AMgIxAmN8YO3lYdaiba6KnYdDaDq0fbIaB0/YXUbU+mQ3vzLIhiCt+w2nyX rtFoOD9zmKJ+A== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 05/11] malloc: malloc_elem_join_adjacent_free can return null Date: Mon, 21 Nov 2022 15:40:11 -0500 Message-Id: <20221121204015.1135573-6-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index d7c410b786..d2ccc387bf 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -97,6 +97,9 @@ 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) { + return NULL; + } malloc_elem_free_list_insert(elem); From patchwork Mon Nov 21 20:40:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120010 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 92B8AA056B; Mon, 21 Nov 2022 21:41:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3AF0342D52; Mon, 21 Nov 2022 21:40:39 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 75C8B42D3C for ; Mon, 21 Nov 2022 21:40:35 +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 458B0B815D5 for ; Mon, 21 Nov 2022 20:40:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8945C433D7; Mon, 21 Nov 2022 20:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063234; bh=6/bKPh5HSS0Nc7nIWB6B6RJi6zcki6u9kGVTjBDPSNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ma+vnl6weQhhgaFgv7VGVmpMBkD1P2crHO0UN3GCotFdwG1cNpVIxjztArqzI+a4j 82PsAuJM2rEI8m9qcFlNgHfMA3PnZ7W5usaTUEOwo4ZvGR08AROs1kN3tj5jrPXgrp SWfF7hU+86RdgDZ15xyWGrU1K1FfVRO7D5nc3jcT4IutZxpAHTkPdv0IShtvuNFDX9 aK6nY+NegXBiwryM4vnmKN11IYN6ceiCocpxbMPIL8maFQHmSZyX+IoahAqJwP6cIg rMcYhGFtKE3G7UJwTKyBE1j5BEJOQf4cZ5z+ObnfuvFR/hJud9MMnBiAhP4XHXCZRz +se0KL/eE7FEw== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 06/11] malloc: check result of rte_mem_virt2memseg_list Date: Mon, 21 Nov 2022 15:40:12 -0500 Message-Id: <20221121204015.1135573-7-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index d2ccc387bf..438c0856e2 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -324,6 +324,9 @@ 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) { + 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 Mon Nov 21 20:40:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120012 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 267B6A056B; Mon, 21 Nov 2022 21:41:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E428542D50; Mon, 21 Nov 2022 21:40:40 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 131F342D43 for ; Mon, 21 Nov 2022 21:40:36 +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 D7878B815D5 for ; Mon, 21 Nov 2022 20:40:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D806C433B5; Mon, 21 Nov 2022 20:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063234; bh=BPYN3i4UD0HJpTXVhiBL3FIbmMerNwTvZ3DLcv1+SaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y0MhgmkeYcY5QLyKG2DpGUkXHBY6d7f9rkLZnQP2989A75IHtLNyOjzUYpS2oQFdx eWVGga1YeU6OeASKZtgxFguje1G2gu+1fWXlCm0v1KVoZQSivSbvIAyETcDBWRp7z6 P7angG+BPGvBt7h69dQQ8oDZ27vK50PblC++2U4Mxnnx387z2fE/R7FlzopB0ANbM9 H51Ay8Kipfe4dgHeKki5l2459yq09sZxJzkNSXd/5HsoJ7dGVfbfz/Rw2kVdi/DX0g sChym7Fe7Qu4TqTtzGn9eA4IqnafGLwjaCOi49F00Uuvodt3Rki48TOsauAHMVWv2O PcDthSNjGSEvQ== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 07/11] malloc: check result of rte_fbarray_get Date: Mon, 21 Nov 2022 15:40:13 -0500 Message-Id: <20221121204015.1135573-8-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_memalloc.c b/lib/eal/common/eal_common_memalloc.c index ab04479c1c..e7f4bede39 100644 --- a/lib/eal/common/eal_common_memalloc.c +++ b/lib/eal/common/eal_common_memalloc.c @@ -126,6 +126,8 @@ 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) + return false; cur = ms->iova; expected = cur + pgsz; @@ -137,7 +139,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 && (ms->iova != expected)) return false; } } From patchwork Mon Nov 21 20:40:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120011 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 57081A056B; Mon, 21 Nov 2022 21:41:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1C9D742D58; Mon, 21 Nov 2022 21:40:40 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 940F842D3D for ; Mon, 21 Nov 2022 21:40:35 +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 64998B815DE for ; Mon, 21 Nov 2022 20:40:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C998FC433D6; Mon, 21 Nov 2022 20:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063235; bh=AuYg0waQuxWd4B5EH2AbZ0Gkal/nrcpO9xrEg70Qxyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbjhVv9Zg5wG4eJBQWYEtKOi7l7ShW4p5gKmTcHRE3wVeQ+h4c78sDvx1vqfO8U8C t7Nw60kJ4NYzDnNEJAzZdPJwI5NOQDtJXFrHvA9bGlBuGq+QfwSsGyd4J/9RkrcWkZ 1/GtD2o+DK6zJ8Zdw/AT5GJ3PAUpcWNoDs5CqY+0cHC4Kgh/llycA3duAJH5KNVAw/ jLlnLDsp6hNuauRI7UmF6gDe0nEtquLTpU5Z7AybVukjLPdmrOFrv/5AoTzEtTSgMv It+McVNnxCJqJN/7bHGa1LSfG77D2Ml5onEQybW22aeefXi2iubURLEzTsBgBfZ+gv /Et8jm80IuC9Q== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 08/11] malloc: check result of rte_mem_virt2memseg Date: Mon, 21 Nov 2022 15:40:14 -0500 Message-Id: <20221121204015.1135573-9-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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..54d7b2f278 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) + 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) { + 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 438c0856e2..1bf2e94c83 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -932,7 +932,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 && (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 Mon Nov 21 20:40:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 120013 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 D1ECCA056B; Mon, 21 Nov 2022 21:41:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1AF442D5C; Mon, 21 Nov 2022 21:40:41 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mails.dpdk.org (Postfix) with ESMTP id 1CAEB42D44 for ; Mon, 21 Nov 2022 21:40:36 +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 E0485B815DE for ; Mon, 21 Nov 2022 20:40:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53519C4347C; Mon, 21 Nov 2022 20:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063235; bh=0bFP7XEYzr+JImfIgc2FYAsJZrmD4Erj3hJvsOVmuLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AU7gAb68lVgGPUJKd0VKfLAgJDan28n7oAKKRmG9RQgZXzU2B1uhnKmfUQuujYpBQ Ao8IW1glVAayPNRBEXMFkwkLY6RU8k92bgAy2kYuL087ifsnhIKhMr7g/UApwTUDvt KZ7YR3Tjk1XzjJsUQ98lLtIkXJLXVK/QbSHW7njxL2vW7vLfiArrXN5jsKVXPx7yd6 Xmo2SEDdZPGAxSoGKk59QF7e5fUPDA0cRfjhR8WZVKtZJ6sdYYMHp2r0Z95YX7g0Cm sGRcstwWqWi4UcMy7x/DBmNos3gb8NFVIIRUMVs91ep8M0Sldg8jnatyJ0nZEVtMnF 3okISkGNx2/FA== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 09/11] malloc: check result of malloc_elem_free Date: Mon, 21 Nov 2022 15:40:15 -0500 Message-Id: <20221121204015.1135573-10-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-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 1bf2e94c83..78a540c860 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -894,6 +894,9 @@ malloc_heap_free(struct malloc_elem *elem) /* anything after this is a bonus */ ret = 0; + if (!elem) + goto free_unlock; + /* ...of which we can't avail if we are in legacy mode, or if this is an * externally allocated segment. */