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 41E43A0093 for ; Fri, 22 May 2020 11:42:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 337B01D974; Fri, 22 May 2020 11:42:26 +0200 (CEST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id B91881D973 for ; Fri, 22 May 2020 11:42:24 +0200 (CEST) Received: by mail-wr1-f65.google.com with SMTP id l11so9563371wru.0 for ; Fri, 22 May 2020 02:42:24 -0700 (PDT) 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=Iq6c1UF5p0F4OFfY3Ipvz44D90tL1vmIqE7rmNLdl4w=; b=IEwCG16vl3gJjNGCRqUNbyIxJtjqlp1UT/v3+1/Q6iJ185gDuqC/AhbTRFe08xrViz Pi6sVEWwHcpNcGsbEh+XCtAltMpegt2CQQ8B9+YvEkJDdfLzP6cDpwf48EWZng2aZZvq PTsJwMz1zsOOKegXPRYay+grgyJdvivD5bq2RlwigdijAYVB6CwDrK90eno4gfiulhCQ nsK8RaOxDBQOv4DN+e+OduZdepwyuhzOlsd9nQwJpKcTMUMpJc/omm5l+3NroHY3U14g VaXyV1ns+kxsPm7SJHgLni2FfKYj8kVP6YesMm5qePbTj0e6QmaHvEHFrDTPdGUThTkx x77w== 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=Iq6c1UF5p0F4OFfY3Ipvz44D90tL1vmIqE7rmNLdl4w=; b=ZKw9nBKjw5bCfTcHwDVWEYM5g3rG3aIneOWQuEvQ3HhthfvjwOHYmH7/uR81G1231i YkwcwBk82Chn5gqeYGFYFP/fCoo9IotfXhAP1BpNgeMVDZGNAf+Jx2nSe/pdyGgSxeeI teffWf6vFu60E97HMnyxwvPT2MfOsu299ZEki0ALg/4zRImui2AWk97ltV/wd0hyl9Rt nTfgCxjkxKzWOgR6h9PVOgL/mg6JbTvO+Ng3ihq1BWPa9ytmaQ0k1Z3i57Fq2vdDdx3I 8BqHI3TMdpitBXeKzqguGdIKGU83OMDqJtmbQaXp+PfrQ2EL9WEdyad0R9Iln18zT8nO XJDw== X-Gm-Message-State: AOAM532cy7GVJ2wH8JALbW9a0snVHV3qq3dZTUvOk71UAHBC/ZXofyj8 FuOHzFFcIRdYO+nTh34OYew= X-Google-Smtp-Source: ABdhPJyRrjk/N56AJSJHn3G3G9YVNs3EO6f2PXJ0bgpAc1FZ3upoj/N0xN4lT0UISMt743P2u5MejA== X-Received: by 2002:a05:6000:1048:: with SMTP id c8mr2678605wrx.1.1590140544437; Fri, 22 May 2020 02:42:24 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id v19sm8604531wml.43.2020.05.22.02.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 02:42:23 -0700 (PDT) From: luca.boccassi@gmail.com To: Wei Zhao Cc: Jeff Guo , Xiaolong Ye , dpdk stable Date: Fri, 22 May 2020 10:40:19 +0100 Message-Id: <20200522094022.1025696-40-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522094022.1025696-1-luca.boccassi@gmail.com> References: <20200519130549.112823-214-luca.boccassi@gmail.com> <20200522094022.1025696-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/i40e: fix wild pointer' has been queued to stable release 19.11.3 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.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/24/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 f956486556f0181bb3eb819f6afad42e08b9dcd7 Mon Sep 17 00:00:00 2001 From: Wei Zhao Date: Mon, 18 May 2020 16:00:51 +0800 Subject: [PATCH] net/i40e: fix wild pointer [ upstream commit b342fd9084cf99292f0077e16b0edb3b6b79f6e7 ] In i40e PMD code of function i40e_res_pool_free(), if valid_entry is freed by "rte_free(valid_entry);" in the code, then the following code for pool update may still use the wild pointer "valid_entry" for pool info update. It seems has the risk of core dump for using wild pointer operation, we should avoid this risk. Fixes: 4861cde46116 ("i40e: new poll mode driver") Signed-off-by: Wei Zhao Reviewed-by: Jeff Guo Reviewed-by: Xiaolong Ye --- drivers/net/i40e/i40e_ethdev.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 55ba606f85..430e347073 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -4927,6 +4927,7 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, { struct pool_entry *entry, *next, *prev, *valid_entry = NULL; uint32_t pool_offset; + uint16_t len; int insert; if (pool == NULL) { @@ -4965,12 +4966,13 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, } insert = 0; + len = valid_entry->len; /* Try to merge with next one*/ if (next != NULL) { /* Merge with next one */ - if (valid_entry->base + valid_entry->len == next->base) { + if (valid_entry->base + len == next->base) { next->base = valid_entry->base; - next->len += valid_entry->len; + next->len += len; rte_free(valid_entry); valid_entry = next; insert = 1; @@ -4980,13 +4982,15 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, if (prev != NULL) { /* Merge with previous one */ if (prev->base + prev->len == valid_entry->base) { - prev->len += valid_entry->len; + prev->len += len; /* If it merge with next one, remove next node */ if (insert == 1) { LIST_REMOVE(valid_entry, next); rte_free(valid_entry); + valid_entry = NULL; } else { rte_free(valid_entry); + valid_entry = NULL; insert = 1; } } @@ -5002,8 +5006,8 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, LIST_INSERT_HEAD(&pool->free_list, valid_entry, next); } - pool->num_free += valid_entry->len; - pool->num_alloc -= valid_entry->len; + pool->num_free += len; + pool->num_alloc -= len; return 0; } -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-22 10:37:40.776407803 +0100 +++ 0040-net-i40e-fix-wild-pointer.patch 2020-05-22 10:37:39.256415008 +0100 @@ -1,8 +1,10 @@ -From b342fd9084cf99292f0077e16b0edb3b6b79f6e7 Mon Sep 17 00:00:00 2001 +From f956486556f0181bb3eb819f6afad42e08b9dcd7 Mon Sep 17 00:00:00 2001 From: Wei Zhao Date: Mon, 18 May 2020 16:00:51 +0800 Subject: [PATCH] net/i40e: fix wild pointer +[ upstream commit b342fd9084cf99292f0077e16b0edb3b6b79f6e7 ] + In i40e PMD code of function i40e_res_pool_free(), if valid_entry is freed by "rte_free(valid_entry);" in the code, then the following code for pool update may still use the wild pointer "valid_entry" @@ -10,7 +12,6 @@ using wild pointer operation, we should avoid this risk. Fixes: 4861cde46116 ("i40e: new poll mode driver") -Cc: stable@dpdk.org Signed-off-by: Wei Zhao Reviewed-by: Jeff Guo @@ -20,10 +21,10 @@ 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c -index 91dcd0ebf0..c68fba125e 100644 +index 55ba606f85..430e347073 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c -@@ -4935,6 +4935,7 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, +@@ -4927,6 +4927,7 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, { struct pool_entry *entry, *next, *prev, *valid_entry = NULL; uint32_t pool_offset; @@ -31,7 +32,7 @@ int insert; if (pool == NULL) { -@@ -4973,12 +4974,13 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, +@@ -4965,12 +4966,13 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, } insert = 0; @@ -47,7 +48,7 @@ rte_free(valid_entry); valid_entry = next; insert = 1; -@@ -4988,13 +4990,15 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, +@@ -4980,13 +4982,15 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, if (prev != NULL) { /* Merge with previous one */ if (prev->base + prev->len == valid_entry->base) { @@ -64,7 +65,7 @@ insert = 1; } } -@@ -5010,8 +5014,8 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, +@@ -5002,8 +5006,8 @@ i40e_res_pool_free(struct i40e_res_pool_info *pool, LIST_INSERT_HEAD(&pool->free_list, valid_entry, next); }