drivers/infiniband/hw/mlx5/fs.c | 6 ++++++ 1 file changed, 6 insertions(+)
`_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)
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
© 2016 - 2026 Red Hat, Inc.