net/mlx5: fix heap-buffer-overflow in sample group match
PATCH 1/1 net/mlx5: fix heap-buffer-overflow in sample group match
The cached group match callback compares serialized actions using memcmp with the size of the new actions buffer. When the new actions serialize to a larger buffer than an existing cached entry, memcmp reads past the cached entry's heap allocation, causing a heap-buffer-overflow detected by AddressSanitizer.
Add a size comparison before the memcmp so that entries with different serialized sizes are rejected as non-matching immediately, avoiding the out-of-bounds read.
--- drivers/net/mlx5/mlx5_nta_sample.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/mlx5/mlx5_nta_sample.c +2 -0
@@ -293,6 +293,8 @@ mlx5_nta_sample_cached_group_match(void *cache_ctx __rte_unused, container_of(entry, struct mlx5_nta_sample_cached_group, entry);if (actions_size <0 )return ~0 ; +if ((size_t )actions_size != cached_obj->actions_size) +return ~0 ;return memcmp (cached_obj->actions, obj_ctx->actions, actions_size); }
Signature · 1 line
2.34.1
Hi,
Quoted 10 lines · Shani Peretz
The cached group match callback compares serialized actions using memcmp with the size of the new actions buffer. When the new actions serialize to a larger buffer than an existing cached entry, memcmp reads past the cached entry's heap allocation, causing a heap-buffer-overflow detected by AddressSanitizer.
Add a size comparison before the memcmp so that entries with different serialized sizes are rejected as non-matching immediately, avoiding the out-of-bounds read.
Quoted 5 lines
Fixes d986f04d6529 ("net/mlx5: add functions for non-template flow sample")Signed-off-by Shani Peretz <[email protected]>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh