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 37746A0350 for ; Mon, 21 Feb 2022 16:43:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 32AAF40DF6; Mon, 21 Feb 2022 16:43:36 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 6FE18410F6 for ; Mon, 21 Feb 2022 16:43:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645458215; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mahl/EUuLteN40+Jagnk9BFcfyI3TK2N9UBotZBkDfQ=; b=YMEkU88jr7rMYaVY7uefI2v0G4TfS2s1MKhMJDGO6QUD4WJ7R3UggCEoJBEkXEkLe36ZDH GefLGnu0BLL7Zv5NNd51YY7J6f6f4d4d8k9AeMsvL58hEe/bOqPJ70cByjmZ4rf2pvk2eH at76ho+f1YcEzB8Zh+BIkOa90uTYi10= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-wFzDgOLCO8KiJ0sJgsRikA-1; Mon, 21 Feb 2022 10:43:30 -0500 X-MC-Unique: wFzDgOLCO8KiJ0sJgsRikA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 99908814246; Mon, 21 Feb 2022 15:43:29 +0000 (UTC) Received: from rh.Home (unknown [10.39.195.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A0A97E2E8; Mon, 21 Feb 2022 15:43:27 +0000 (UTC) From: Kevin Traynor To: Cristian Dumitrescu Cc: Harshad Narayane , Kamalakannan R , Venkata Suresh Kumar P , dpdk stable Subject: patch 'pipeline: fix table state memory allocation' has been queued to stable release 21.11.1 Date: Mon, 21 Feb 2022 15:36:24 +0000 Message-Id: <20220221153625.152324-195-ktraynor@redhat.com> In-Reply-To: <20220221153625.152324-1-ktraynor@redhat.com> References: <20220221153625.152324-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 Hi, FYI, your patch has been queued to stable release 21.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/26/22. 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. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/adfebc59b50ee65e2f0d4a75574ac3bc62e46317 Thanks. Kevin --- >From adfebc59b50ee65e2f0d4a75574ac3bc62e46317 Mon Sep 17 00:00:00 2001 From: Cristian Dumitrescu Date: Thu, 10 Feb 2022 19:45:08 +0000 Subject: [PATCH] pipeline: fix table state memory allocation [ upstream commit eb3e2c11830e4d75ff5dff20cfa70599a1613f71 ] The regular tables, selector tables and learner tables are all sharing the table state array. The locations in this array were computed incorrectly, leading to memory corruption issues. Fixes: 4f59d3726147 ("pipeline: support learner tables") Signed-off-by: Cristian Dumitrescu Signed-off-by: Harshad Narayane Signed-off-by: Kamalakannan R Signed-off-by: Venkata Suresh Kumar P --- lib/pipeline/rte_swx_ctl.c | 28 +++++++++++++++++----------- lib/pipeline/rte_swx_pipeline.c | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c index 8e29d58cec..f52ccffd75 100644 --- a/lib/pipeline/rte_swx_ctl.c +++ b/lib/pipeline/rte_swx_ctl.c @@ -1022,5 +1022,5 @@ static void table_state_free(struct rte_swx_ctl_pipeline *ctl) { - uint32_t i; + uint32_t table_base_index, selector_base_index, learner_base_index, i; if (!ctl->ts_next) @@ -1028,7 +1028,8 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl) /* For each table, free its table state. */ + table_base_index = 0; for (i = 0; i < ctl->info.n_tables; i++) { struct table *table = &ctl->tables[i]; - struct rte_swx_table_state *ts = &ctl->ts_next[i]; + struct rte_swx_table_state *ts = &ctl->ts_next[table_base_index + i]; /* Default action data. */ @@ -1041,6 +1042,7 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl) /* For each selector table, free its table state. */ + selector_base_index = ctl->info.n_tables; for (i = 0; i < ctl->info.n_selectors; i++) { - struct rte_swx_table_state *ts = &ctl->ts_next[i]; + struct rte_swx_table_state *ts = &ctl->ts_next[selector_base_index + i]; /* Table object. */ @@ -1050,6 +1052,7 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl) /* For each learner table, free its table state. */ + learner_base_index = ctl->info.n_tables + ctl->info.n_selectors; for (i = 0; i < ctl->info.n_learners; i++) { - struct rte_swx_table_state *ts = &ctl->ts_next[i]; + struct rte_swx_table_state *ts = &ctl->ts_next[learner_base_index + i]; /* Default action data. */ @@ -1064,8 +1067,8 @@ static int table_state_create(struct rte_swx_ctl_pipeline *ctl) { + uint32_t table_base_index, selector_base_index, learner_base_index, i; int status = 0; - uint32_t i; - ctl->ts_next = calloc(ctl->info.n_tables + ctl->info.n_selectors, + ctl->ts_next = calloc(ctl->info.n_tables + ctl->info.n_selectors + ctl->info.n_learners, sizeof(struct rte_swx_table_state)); if (!ctl->ts_next) { @@ -1075,8 +1078,9 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl) /* Tables. */ + table_base_index = 0; for (i = 0; i < ctl->info.n_tables; i++) { struct table *table = &ctl->tables[i]; - struct rte_swx_table_state *ts = &ctl->ts[i]; - struct rte_swx_table_state *ts_next = &ctl->ts_next[i]; + struct rte_swx_table_state *ts = &ctl->ts[table_base_index + i]; + struct rte_swx_table_state *ts_next = &ctl->ts_next[table_base_index + i]; /* Table object. */ @@ -1111,7 +1115,8 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl) /* Selector tables. */ + selector_base_index = ctl->info.n_tables; for (i = 0; i < ctl->info.n_selectors; i++) { struct selector *s = &ctl->selectors[i]; - struct rte_swx_table_state *ts_next = &ctl->ts_next[ctl->info.n_tables + i]; + struct rte_swx_table_state *ts_next = &ctl->ts_next[selector_base_index + i]; /* Table object. */ @@ -1124,8 +1129,9 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl) /* Learner tables. */ + learner_base_index = ctl->info.n_tables + ctl->info.n_selectors; for (i = 0; i < ctl->info.n_learners; i++) { struct learner *l = &ctl->learners[i]; - struct rte_swx_table_state *ts = &ctl->ts[i]; - struct rte_swx_table_state *ts_next = &ctl->ts_next[i]; + struct rte_swx_table_state *ts = &ctl->ts[learner_base_index + i]; + struct rte_swx_table_state *ts_next = &ctl->ts_next[learner_base_index + i]; /* Table object: duplicate from the current table state. */ diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index 2145ca0a42..8d5073cf19 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -8532,5 +8532,5 @@ table_state_build(struct rte_swx_pipeline *p) struct learner *l; - p->table_state = calloc(p->n_tables + p->n_selectors, + p->table_state = calloc(p->n_tables + p->n_selectors + p->n_learners, sizeof(struct rte_swx_table_state)); CHECK(p->table_state, ENOMEM); -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-02-21 15:22:48.884407351 +0000 +++ 0195-pipeline-fix-table-state-memory-allocation.patch 2022-02-21 15:22:44.391704802 +0000 @@ -1 +1 @@ -From eb3e2c11830e4d75ff5dff20cfa70599a1613f71 Mon Sep 17 00:00:00 2001 +From adfebc59b50ee65e2f0d4a75574ac3bc62e46317 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit eb3e2c11830e4d75ff5dff20cfa70599a1613f71 ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -107 +108 @@ -index 1a50c4bb72..f404ff1596 100644 +index 2145ca0a42..8d5073cf19 100644 @@ -110 +111 @@ -@@ -8568,5 +8568,5 @@ table_state_build(struct rte_swx_pipeline *p) +@@ -8532,5 +8532,5 @@ table_state_build(struct rte_swx_pipeline *p)