Skip to content

Commit

Permalink
net/mlx5: DR, Fix check for unsupported fields in match param
Browse files Browse the repository at this point in the history
The existing loop doesn't cast the buffer while scanning it, which
results in out-of-bounds read and failure to create the matcher.

Fixes: 941f197 ("net/mlx5: DR, Add check for unsupported fields in match param")
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Yevgeny Kliteynik authored and Saeed Mahameed committed Nov 16, 2021
1 parent 9091b82 commit 455832d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,11 +924,12 @@ static int dr_matcher_init(struct mlx5dr_matcher *matcher,

/* Check that all mask data was consumed */
for (i = 0; i < consumed_mask.match_sz; i++) {
if (consumed_mask.match_buf[i]) {
mlx5dr_dbg(dmn, "Match param mask contains unsupported parameters\n");
ret = -EOPNOTSUPP;
goto free_consumed_mask;
}
if (!((u8 *)consumed_mask.match_buf)[i])
continue;

mlx5dr_dbg(dmn, "Match param mask contains unsupported parameters\n");
ret = -EOPNOTSUPP;
goto free_consumed_mask;
}

ret = 0;
Expand Down

0 comments on commit 455832d

Please sign in to comment.