* [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* Re: [PATCH] mlx5: bound raw flow rule match parameter copies
2026-03-22 3:19 [PATCH] mlx5: bound raw flow rule match parameter copies Pengpeng Hou
@ 2026-03-23 16:56 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-03-23 16:56 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: linux-rdma, Jason Gunthorpe, linux-kernel
On Sun, Mar 22, 2026 at 11:19:22AM +0800, Pengpeng Hou wrote:
> `_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(+)
I suggest you to simply change MLX5_IB_DW_MATCH_PARAM value from 0xA0 to
be 0x80.
Thanks
^ permalink raw reply [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