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 D065AA0C4C for ; Mon, 12 Jul 2021 15:15:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C464D406B4; Mon, 12 Jul 2021 15:15:14 +0200 (CEST) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mails.dpdk.org (Postfix) with ESMTP id BC73340685 for ; Mon, 12 Jul 2021 15:15:12 +0200 (CEST) Received: by mail-wr1-f44.google.com with SMTP id p8so25576080wrr.1 for ; Mon, 12 Jul 2021 06:15:12 -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=06Mp79G1Ipl59B7zhXz53xQsvdx5fYjki9ry6vIrFe8=; b=T3451zzY9WP1TW4LZ37VoWv8UQZ/I5xKTZ0tTN6GU72WjijDL//wGGtoxiyKDNxtWt ob3n8uJlQ2qHpt6YmokM8mg9/IaYABl74IAm3SQCQ7sxZnMNi2DBD2LQV2epMoK+z1bg ISwaqLlWD81JEasIWHtRcYQ7QtGQCEvwWUvwE1aHsoxtBpxW7Ak3ARR5syUk+nDiaYBB h0qAuU/cbZejZCXv1iMr38bmaaqDy+m+e5Mo4z20bIxZHw1cpGS1jFXxEyA5ukIF4rEJ F9MqFZ/4lSfcMLSKCm3vrocPtbs0zedEQJzJpJrneOjJLYAdizcqIdRs9xOPFrzrjeZN P5iw== 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=06Mp79G1Ipl59B7zhXz53xQsvdx5fYjki9ry6vIrFe8=; b=j/VcW+Gedoy4pIupv9bgLIyP8KzR8yfh/9aZRdD/R10O+zurd3lBUgJqU6YdLLafX/ OpsW8d1sYcEm6+WuS5JXvFWJMrR2MfDB6pphsKdz89vcwWVrkxS6XhocE++e4KByCS/S TK7konEybdqAqLkOO52n35znK8k82tEsMwRPrXq14J2lCkTaeI3v8SBfC3GFIj9NqdM+ oYiynLRXVw53AJG0psKW/1FGMgLBtqbEiZtXPlB+Hrboh/KAtDafz+zN1jI3rtWvUNZh IslJ57FNkSa9A1rkJVTQCDI+BEp0/0oSknXbX8PyG4TXSZMbv8oOrl13lye+8IC9IQ+x taPQ== X-Gm-Message-State: AOAM530d3ZY3mVC50P6J1al2bT7fTyZUpcp2ft3RcCQSdOFlbuF8jyH7 PphzECyl2EAl2qvLeh1x33g= X-Google-Smtp-Source: ABdhPJz94jD/djRmPBRvLCPm1XIO4sqi7stC7amVs1n0ZQnjUQgKdou2gqoxH3oMWR2t3TXHQurUkw== X-Received: by 2002:a5d:5642:: with SMTP id j2mr58929321wrw.194.1626095712579; Mon, 12 Jul 2021 06:15:12 -0700 (PDT) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id p11sm9335328wrw.53.2021.07.12.06.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 06:15:12 -0700 (PDT) From: luca.boccassi@gmail.com To: Gregory Etelson Cc: Viacheslav Ovsiienko , dpdk stable Date: Mon, 12 Jul 2021 14:05:32 +0100 Message-Id: <20210712130551.2462159-97-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210712130551.2462159-1-luca.boccassi@gmail.com> References: <20210712130551.2462159-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/mlx5: fix pattern expansion in RSS flow rules' has been queued to stable release 20.11.3 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.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 07/14/21. 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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/2879a418b171a42d9e0b121a6d4fcadad4276a32 Thanks. Luca Boccassi --- >From 2879a418b171a42d9e0b121a6d4fcadad4276a32 Mon Sep 17 00:00:00 2001 From: Gregory Etelson Date: Wed, 30 Jun 2021 10:19:52 +0300 Subject: [PATCH] net/mlx5: fix pattern expansion in RSS flow rules [ upstream commit be548b9c9d40d33d88bb16641944be4cb2240eb1 ] Flow rule pattern may be implicitly expanded by the PMD if the rule has RSS flow action. The expansion adds network headers to the original pattern. The new pattern lists all network levels that participate in the rule RSS action. The patch validates that buffer for expanded pattern has enough bytes for new flow items. Fixes: c7870bfe09dc ("ethdev: move RSS expansion code to mlx5 driver") Signed-off-by: Gregory Etelson Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.c | 63 +++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 048823a50b..5e64a674d3 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -264,6 +264,7 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item) * set, the following errors are defined: * * -E2BIG: graph-depth @p graph is too deep. + * -EINVAL: @p size has not enough space for expanded pattern. */ static int mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, @@ -290,12 +291,12 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, memset(&missed_item, 0, sizeof(missed_item)); lsize = offsetof(struct mlx5_flow_expand_rss, entry) + MLX5_RSS_EXP_ELT_N * sizeof(buf->entry[0]); - if (lsize <= size) { - buf->entry[0].priority = 0; - buf->entry[0].pattern = (void *)&buf->entry[MLX5_RSS_EXP_ELT_N]; - buf->entries = 0; - addr = buf->entry[0].pattern; - } + if (lsize > size) + return -EINVAL; + buf->entry[0].priority = 0; + buf->entry[0].pattern = (void *)&buf->entry[MLX5_RSS_EXP_ELT_N]; + buf->entries = 0; + addr = buf->entry[0].pattern; for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { if (!mlx5_flow_is_rss_expandable_item(item)) { user_pattern_size += sizeof(*item); @@ -313,12 +314,12 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, } user_pattern_size += sizeof(*item); /* Handle END item. */ lsize += user_pattern_size; + if (lsize > size) + return -EINVAL; /* Copy the user pattern in the first entry of the buffer. */ - if (lsize <= size) { - rte_memcpy(addr, pattern, user_pattern_size); - addr = (void *)(((uintptr_t)addr) + user_pattern_size); - buf->entries = 1; - } + rte_memcpy(addr, pattern, user_pattern_size); + addr = (void *)(((uintptr_t)addr) + user_pattern_size); + buf->entries = 1; /* Start expanding. */ memset(flow_items, 0, sizeof(flow_items)); user_pattern_size -= sizeof(*item); @@ -348,7 +349,9 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, elt = 2; /* missed item + item end. */ node = next; lsize += elt * sizeof(*item) + user_pattern_size; - if ((node->rss_types & types) && lsize <= size) { + if (lsize > size) + return -EINVAL; + if (node->rss_types & types) { buf->entry[buf->entries].priority = 1; buf->entry[buf->entries].pattern = addr; buf->entries++; @@ -367,6 +370,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, while (node) { flow_items[stack_pos].type = node->type; if (node->rss_types & types) { + size_t n; /* * compute the number of items to copy from the * expansion and copy it. @@ -376,24 +380,23 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, elt = stack_pos + 2; flow_items[stack_pos + 1].type = RTE_FLOW_ITEM_TYPE_END; lsize += elt * sizeof(*item) + user_pattern_size; - if (lsize <= size) { - size_t n = elt * sizeof(*item); - - buf->entry[buf->entries].priority = - stack_pos + 1 + missed; - buf->entry[buf->entries].pattern = addr; - buf->entries++; - rte_memcpy(addr, buf->entry[0].pattern, - user_pattern_size); - addr = (void *)(((uintptr_t)addr) + - user_pattern_size); - rte_memcpy(addr, &missed_item, - missed * sizeof(*item)); - addr = (void *)(((uintptr_t)addr) + - missed * sizeof(*item)); - rte_memcpy(addr, flow_items, n); - addr = (void *)(((uintptr_t)addr) + n); - } + if (lsize > size) + return -EINVAL; + n = elt * sizeof(*item); + buf->entry[buf->entries].priority = + stack_pos + 1 + missed; + buf->entry[buf->entries].pattern = addr; + buf->entries++; + rte_memcpy(addr, buf->entry[0].pattern, + user_pattern_size); + addr = (void *)(((uintptr_t)addr) + + user_pattern_size); + rte_memcpy(addr, &missed_item, + missed * sizeof(*item)); + addr = (void *)(((uintptr_t)addr) + + missed * sizeof(*item)); + rte_memcpy(addr, flow_items, n); + addr = (void *)(((uintptr_t)addr) + n); } /* Go deeper. */ if (!node->optional && node->next) { -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-07-12 13:41:41.571403680 +0100 +++ 0097-net-mlx5-fix-pattern-expansion-in-RSS-flow-rules.patch 2021-07-12 13:41:36.806129193 +0100 @@ -1 +1 @@ -From be548b9c9d40d33d88bb16641944be4cb2240eb1 Mon Sep 17 00:00:00 2001 +From 2879a418b171a42d9e0b121a6d4fcadad4276a32 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit be548b9c9d40d33d88bb16641944be4cb2240eb1 ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -24 +25 @@ -index cac4e6aa7a..667ae3fd97 100644 +index 048823a50b..5e64a674d3 100644