DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dekel Peled <dekelp@nvidia.com>
To: viacheslavo@nvidia.com, shahafs@nvidia.com, matan@nvidia.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] net/mlx5: fix use of local array for global error
Date: Wed,  4 Nov 2020 16:25:19 +0200
Message-ID: <b29c6bf5012d9b84abfdcb5e198a1fc4da3f2f84.1604499811.git.dekelp@nvidia.com> (raw)

Recent patch uses a local string array as input for function
rte_flow_error_set().
This stack memory may be later used by other code sections,
overwriting the desired error string.

This patch impelemnets an error string for the specific case
requested, of ICMP item not supported in Verbs flow engine.

Fixes: cb6a02dcea9d ("net/mlx5: support item type error message in flow Verbs")

Signed-off-by: Dekel Peled <dekelp@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_verbs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 28fd120..04f6b40 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -1247,7 +1247,6 @@
 	uint64_t last_item = 0;
 	uint8_t next_protocol = 0xff;
 	uint16_t ether_type = 0;
-	char errstr[32];
 
 	if (items == NULL)
 		return -1;
@@ -1398,12 +1397,16 @@
 				return ret;
 			last_item = MLX5_FLOW_LAYER_MPLS;
 			break;
+		case RTE_FLOW_ITEM_TYPE_ICMP:
+		case RTE_FLOW_ITEM_TYPE_ICMP6:
+			return rte_flow_error_set(error, ENOTSUP,
+						  RTE_FLOW_ERROR_TYPE_ITEM,
+						  NULL, "ICMP/ICMP6 "
+						  "item not supported");
 		default:
-			snprintf(errstr, sizeof(errstr), "item type %d not supported",
-				 items->type);
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ITEM,
-						  NULL, errstr);
+						  NULL, "item not supported");
 		}
 		item_flags |= last_item;
 	}
@@ -1698,7 +1701,6 @@
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace();
 	struct mlx5_flow_rss_desc *rss_desc;
-	char errstr[32];
 
 	MLX5_ASSERT(wks);
 	rss_desc = &wks->rss_desc[!!wks->flow_nested_idx];
@@ -1846,11 +1848,9 @@
 			item_flags |= MLX5_FLOW_LAYER_MPLS;
 			break;
 		default:
-			snprintf(errstr, sizeof(errstr), "item type %d not supported",
-				 items->type);
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ITEM,
-						  NULL, errstr);
+						  NULL, "item not supported");
 		}
 	}
 	dev_flow->handle->layers = item_flags;
-- 
1.8.3.1


             reply	other threads:[~2020-11-04 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 14:25 Dekel Peled [this message]
2020-11-09  8:20 ` Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b29c6bf5012d9b84abfdcb5e198a1fc4da3f2f84.1604499811.git.dekelp@nvidia.com \
    --to=dekelp@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=shahafs@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git