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 2D9B1A051C for ; Tue, 11 Feb 2020 12:42:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 25FE11C0CF; Tue, 11 Feb 2020 12:42:53 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id ED6D31C0CF for ; Tue, 11 Feb 2020 12:42:51 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id u6so11998330wrt.0 for ; Tue, 11 Feb 2020 03:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gf8nk4M9BThKrl3OZKBBS6mm+6L62IQXlz3H1oEM5SU=; b=nuAkhQqnRG2e2X5oTZqzFEDcEl3e/nYpIgluLb2PMTx/W1eqAQVokQ/zX2/GqycKYP J3PL4dk2Q+txogdPvp4sqjh0IspsFV8Fytkav7dZZ0UhpbjvHMo8WyS2d2w8vQh1gmy5 AHmjDBjyhyme+reKlmSCd/+TBIBdbcL6V6KQEesW/5lGsOOH3YrebSxT1tX5sXPKXDmT HGFFCWD52vgTta9dP5MiuWIA0Wj10p8YhKrbXMELjqi78nyPCdHWc4+tKYoL+BZVCCp+ fxiwUyTNpYdLj/eM9ImyyFKWhQ4vRu6ipEAGWgvuWZFMoysEXykjL6aMQHvGrsydT0EB JBrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gf8nk4M9BThKrl3OZKBBS6mm+6L62IQXlz3H1oEM5SU=; b=tudakKhewYhl4rxVTaWrdDlHjK+xywzg4jkfOjxJsVbl58kYU+YAUhtSPvT0GgXRpM 2l5DlvfevQrkc/uwa+WgManP/FF9+pHXEM71kfARdPdgtR2lMZOqO1wCqGIFXWwyjJKs 5aoSLkkfpG5FUWx/LkEf7CUBOFPo8yKoB8b+tC3XC4u42xyMWgbX2bNj1lnAmcj9bp4Z CVTeOStoAqD63AKvgCPtXvsK3X8Yxl+BC5LTfDikd31PZsQ+QdVnvLNtCaNQAdeDxrWG Yj6c6AUyMXfeSNYUG69egYN8yMZBsEZVNW+Lx0oEnLON96HhSnS8oxq5cvwuX9F/Nc4G TSXw== X-Gm-Message-State: APjAAAW69Mvmpz7FJExB80IWdc3DZXG8DrN6YzLxfwZCkG3VSj6bJcQj 7nJLeKhd4sHDU5KXxIwXSeU= X-Google-Smtp-Source: APXvYqyMoBUDt4GP/sXkGPQz3jLWo4GfopekHEJ82E7Wy++5j3kKelKnbo/lzCGhMBmm1tMYHGzR5w== X-Received: by 2002:adf:ce86:: with SMTP id r6mr7698118wrn.327.1581421371621; Tue, 11 Feb 2020 03:42:51 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id k13sm4617248wrx.59.2020.02.11.03.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 03:42:50 -0800 (PST) From: luca.boccassi@gmail.com To: Stephen Hemminger Cc: Anatoly Burakov , dpdk stable Date: Tue, 11 Feb 2020 11:22:15 +0000 Message-Id: <20200211112216.3929-189-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200211112216.3929-1-luca.boccassi@gmail.com> References: <20200211112216.3929-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'mem: fix munmap in error unwind' has been queued to stable release 19.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/13/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 38d2c9ffdfa00563a6da266caba7ac0e55910260 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 22 Jan 2020 09:06:11 -0800 Subject: [PATCH] mem: fix munmap in error unwind [ upstream commit 292f02b58c26c3bad2327a52c49ec6eff580e124 ] The loop to unwind existing mmaps was only unmapping the first segment and the error paths after mmap() were not doing munmap of the current segment. Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Signed-off-by: Stephen Hemminger Acked-by: Anatoly Burakov --- lib/librte_eal/linux/eal/eal_memory.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c index 43e4ffc757..5604c2a7c0 100644 --- a/lib/librte_eal/linux/eal/eal_memory.c +++ b/lib/librte_eal/linux/eal/eal_memory.c @@ -1928,7 +1928,7 @@ eal_legacy_hugepage_attach(void) if (flock(fd, LOCK_SH) < 0) { RTE_LOG(DEBUG, EAL, "%s(): Locking file failed: %s\n", __func__, strerror(errno)); - goto fd_error; + goto mmap_error; } /* find segment data */ @@ -1936,13 +1936,13 @@ eal_legacy_hugepage_attach(void) if (msl == NULL) { RTE_LOG(DEBUG, EAL, "%s(): Cannot find memseg list\n", __func__); - goto fd_error; + goto mmap_error; } ms = rte_mem_virt2memseg(map_addr, msl); if (ms == NULL) { RTE_LOG(DEBUG, EAL, "%s(): Cannot find memseg\n", __func__); - goto fd_error; + goto mmap_error; } msl_idx = msl - mcfg->memsegs; @@ -1950,7 +1950,7 @@ eal_legacy_hugepage_attach(void) if (ms_idx < 0) { RTE_LOG(DEBUG, EAL, "%s(): Cannot find memseg idx\n", __func__); - goto fd_error; + goto mmap_error; } /* store segment fd internally */ @@ -1963,18 +1963,15 @@ eal_legacy_hugepage_attach(void) close(fd_hugepage); return 0; +mmap_error: + munmap(hp[i].final_va, hp[i].size); fd_error: close(fd); error: - /* map all segments into memory to make sure we get the addrs */ - cur_seg = 0; - for (cur_seg = 0; cur_seg < i; cur_seg++) { - struct hugepage_file *hf = &hp[i]; - size_t map_sz = hf->size; - void *map_addr = hf->final_va; + /* unwind mmap's done so far */ + for (cur_seg = 0; cur_seg < i; cur_seg++) + munmap(hp[cur_seg].final_va, hp[cur_seg].size); - munmap(map_addr, map_sz); - } if (hp != NULL && hp != MAP_FAILED) munmap(hp, size); if (fd_hugepage >= 0) -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-02-11 11:17:45.060093444 +0000 +++ 0189-mem-fix-munmap-in-error-unwind.patch 2020-02-11 11:17:38.840009574 +0000 @@ -1,14 +1,15 @@ -From 292f02b58c26c3bad2327a52c49ec6eff580e124 Mon Sep 17 00:00:00 2001 +From 38d2c9ffdfa00563a6da266caba7ac0e55910260 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 22 Jan 2020 09:06:11 -0800 Subject: [PATCH] mem: fix munmap in error unwind +[ upstream commit 292f02b58c26c3bad2327a52c49ec6eff580e124 ] + The loop to unwind existing mmaps was only unmapping the first segment and the error paths after mmap() were not doing munmap of the current segment. Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") -Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Anatoly Burakov