Skip to content

Commit 2b02198

Browse files
dickmanmaorSaeed Mahameed
authored andcommitted
net/mlx5e: CT, Fix coverity issue
The cited commit introduced the following coverity issue at function mlx5_tc_ct_rule_to_tuple_nat: - Memory - corruptions (OVERRUN) Overrunning array "tuple->ip.src_v6.in6_u.u6_addr32" of 4 4-byte elements at element index 7 (byte offset 31) using index "ip6_offset" (which evaluates to 7). In case of IPv6 destination address rewrite, ip6_offset values are between 4 to 7, which will cause memory overrun of array "tuple->ip.src_v6.in6_u.u6_addr32" to array "tuple->ip.dst_v6.in6_u.u6_addr32". Fixed by writing the value directly to array "tuple->ip.dst_v6.in6_u.u6_addr32" in case ip6_offset values are between 4 to 7. Fixes: bc562be ("net/mlx5e: CT: Save ct entries tuples in hashtables") Signed-off-by: Maor Dickman <maord@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent c3c9402 commit 2b02198

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • drivers/net/ethernet/mellanox/mlx5/core/en

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ mlx5_tc_ct_rule_to_tuple_nat(struct mlx5_ct_tuple *tuple,
246246
case FLOW_ACT_MANGLE_HDR_TYPE_IP6:
247247
ip6_offset = (offset - offsetof(struct ipv6hdr, saddr));
248248
ip6_offset /= 4;
249-
if (ip6_offset < 8)
249+
if (ip6_offset < 4)
250250
tuple->ip.src_v6.s6_addr32[ip6_offset] = cpu_to_be32(val);
251+
else if (ip6_offset < 8)
252+
tuple->ip.dst_v6.s6_addr32[ip6_offset - 4] = cpu_to_be32(val);
251253
else
252254
return -EOPNOTSUPP;
253255
break;

0 commit comments

Comments
 (0)