public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mlx5: bound raw flow rule match parameter copies
@ 2026-03-22  3:19 Pengpeng Hou
  2026-03-23 16:56 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-03-22  3:19 UTC (permalink / raw)
  To: linux-rdma; +Cc: pengpeng, Leon Romanovsky, Jason Gunthorpe, linux-kernel

`_create_raw_flow_rule()` copies user-supplied match data and matcher
mask bytes directly into the fixed `mlx5_flow_spec` arrays. The UAPI
allows up to `MLX5_IB_DW_MATCH_PARAM` bytes for the input attributes,
but the kernel object only allocates
`MLX5_ST_SZ_DW(fte_match_param)` bytes for each buffer.

Validate the sizes before copying so oversized verbs requests cannot
corrupt the spec object.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/infiniband/hw/mlx5/fs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/infiniband/hw/mlx5/fs.c b/drivers/infiniband/hw/mlx5/fs.c
index cbccb0b9ac10..b5194f674c65 100644
--- a/drivers/infiniband/hw/mlx5/fs.c
+++ b/drivers/infiniband/hw/mlx5/fs.c
@@ -2069,6 +2069,12 @@ _create_raw_flow_rule(struct mlx5_ib_dev *dev,
 
 	INIT_LIST_HEAD(&handler->list);
 
+	if (inlen > sizeof(spec->match_value) ||
+	    fs_matcher->mask_len > sizeof(spec->match_criteria)) {
+		err = -EINVAL;
+		goto free;
+	}
+
 	memcpy(spec->match_value, cmd_in, inlen);
 	memcpy(spec->match_criteria, fs_matcher->matcher_mask.match_params,
 	       fs_matcher->mask_len);
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-23 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-22  3:19 [PATCH] mlx5: bound raw flow rule match parameter copies Pengpeng Hou
2026-03-23 16:56 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox