From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D8451A0582; Tue, 22 Nov 2022 16:52:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F03BE42D80; Tue, 22 Nov 2022 16:52:32 +0100 (CET) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by mails.dpdk.org (Postfix) with ESMTP id 07C2E42D80 for ; Tue, 22 Nov 2022 16:52:32 +0100 (CET) Received: by mail-lf1-f42.google.com with SMTP id a29so24126477lfj.9 for ; Tue, 22 Nov 2022 07:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=8TJMpAqtAmSSKukHGJzIFo4oIAb5I/wlBvXBG/E4kjU=; b=cjRapps2prMSmcsWaxmm+Rdix+gF6FXrhSaW/T9NzejXJku83Qw0tHx5Wj/xtCyUuh 9MOGFGrHz1TA582I+JKRIQN9Eblgzl/tttYXUvFCsQUb3EzFZwCrLaUNMpJLthU3wL6y AWVJIyUg0aA+tSBQu0cI0WqwfAI4CuEOzP1wl7AlaR1fZQaPNjPHjCH9T9U6mAh9uD73 iKX/6UXx8ucNNzxWkHMsZLk6HDyWSNH4fM/AChZs8+lkzV9jIXhyIfa0NwL/FxcS/3QA DKle7kl8PSL7F9D/jSeiAM6tn44mYSokBhucgq6P1OeEuPu8OSiWYEmNjffkfGeHtt5X tcfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8TJMpAqtAmSSKukHGJzIFo4oIAb5I/wlBvXBG/E4kjU=; b=aiRJP9jLURo31liKo5r0H5aTYYWq1taGaiOa0JN0OWEhnU3zjJdHme9ioRAeVcycYd myCjkDCflAqOzUYW86g7/roKLAPPJMtRNSCXq757X+9ZodoQcQF0Le8vqC4I6RxHaVn+ qvGgYFsOyVqGOJh0LhMR/LjioY6Shb3eDyd3HmAhnFzpfuHMXSCEc3JlCX89YyahCY0f UnOeISBeN9ulSR+wh9fNajrJ09s/NapV4TGOLMROUpem7cmCITjxhnG3T9IW6twpUCGQ xPMLLBN3H/CxSfJcN/pLcii7sgO9tAmLE7slic43IllosmJ/tR0mqf5RCzJ4YMeiYPXy 8qTQ== X-Gm-Message-State: ANoB5pkPjlYaiDtwBuR31MA02GTtsS0yYTLDM/dtQa6kqmLUNTovlgVT dLkZpTqB5/V+k0Bgat4DnZeP5dgTUNA= X-Google-Smtp-Source: AA0mqf6T2KHlDkm0I8e3duYVIL0YCyYUwZXnmXZNTWKqLY1NVOzOI33Sm6Rk0lRL8h5JRoddPQXDQw== X-Received: by 2002:a19:521a:0:b0:4aa:f410:2c47 with SMTP id m26-20020a19521a000000b004aaf4102c47mr7539225lfb.100.1669132351598; Tue, 22 Nov 2022 07:52:31 -0800 (PST) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id q29-20020ac25a1d000000b00497aa190523sm2565925lfn.248.2022.11.22.07.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 07:52:31 -0800 (PST) Date: Tue, 22 Nov 2022 18:52:30 +0300 From: Dmitry Kozlyuk To: okaya@kernel.org Cc: dev@dpdk.org Subject: Re: [PATCH v2 06/11] malloc: check result of rte_mem_virt2memseg_list Message-ID: <20221122185230.19424bd9@sovereign> In-Reply-To: <20221121223208.1147154-7-okaya@kernel.org> References: <20221121223208.1147154-1-okaya@kernel.org> <20221121223208.1147154-7-okaya@kernel.org> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 2022-11-21 17:32 (UTC-0500), okaya@kernel.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; It is not really possible, because the memory lock is held, so "map_addr" cannot be unmapped/remapped concurrently, and "ms" belongs to some MSL by definition of memseg. RTE_ASSERT() can be added for clarity.