net/mlx5: fix IPv6 next proto validation
PATCH 1/1 net/mlx5: fix IPv6 next proto validation
Previous patch added validation of the IPv6 next proto field, in order to overcome a known limitation.
One of the values checked is IPPROTO_HOPOPTS, which is currently defined as value 0.
The same value 0 is received when next proto field is not specified for matching, or has mask 0.
This patch updates the validation, to make sure next proto is not 0 before validating it.
--- drivers/net/mlx5/mlx5_flow.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_flow.c +7 -6
@@ -1987,12 +1987,13 @@ struct mlx5_flow_tunnel_info {"multiple tunnel " "not supported"); } -if (next_proto ==IPPROTO_HOPOPTS || - next_proto ==IPPROTO_ROUTING || - next_proto ==IPPROTO_FRAGMENT || - next_proto ==IPPROTO_ESP || - next_proto ==IPPROTO_AH || - next_proto ==IPPROTO_DSTOPTS ) +if (next_proto && + (next_proto ==IPPROTO_HOPOPTS || + next_proto ==IPPROTO_ROUTING || + next_proto ==IPPROTO_FRAGMENT || + next_proto ==IPPROTO_ESP || + next_proto ==IPPROTO_AH || + next_proto ==IPPROTO_DSTOPTS ))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM , item, "IPv6 proto (next header) should "
Signature · 1 line
1.8.3.1
PATCH v2 1/1 net/mlx5: fix IPv6 next proto validation
Previous patch added validation of the IPv6 next proto field, in order to overcome a known limitation.
One of the values checked is IPPROTO_HOPOPTS, which is defined as 0. If proto field is not specified for matching, or mask=0, as in the following, a wrong validation takes place.
flow create 0 ingress pattern eth / ipv6 has_frag_ext is 0 / end actions drop / end
Fix the validation only on proto asked by the user.
--- drivers/net/mlx5/mlx5_flow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow.c +1 -1
@@ -1977,7 +1977,7 @@ mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,RTE_FLOW_ERROR_TYPE_ITEM , item,"IPv6 cannot follow L2/VLAN layer " "which ether type is not IPv6"); -if (mask && spec) +if (mask && mask->hdr.proto && spec) next_proto = mask->hdr.proto & spec->hdr.proto;if (item_flags &MLX5_FLOW_LAYER_IPV6_ENCAP ) {if (next_proto ==IPPROTO_IPIP || next_proto ==IPPROTO_IPV6 )
Signature · 1 line
2.28.0.546.g385c171
++
Quoted 30 lines · Eli Britstein
Previous patch added validation of the IPv6 next proto field, in order to overcome a known limitation.
One of the values checked isIPPROTO_HOPOPTS, which is defined as 0. If proto field is not specified for matching, or mask=0, as in the following, a wrong validation takes place.
flow create 0 ingress pattern eth / ipv6has_frag_extis 0 / end actions drop / end
Fix the validation only on proto asked by the user.Fixes 55e4c1d1ba73 ("net/mlx5: enforce limitation on IPv6 next proto")Signed-off-by Eli Britstein <[email protected]>Acked-by Dekel Peled <[email protected]>--- drivers/net/mlx5/mlx5_flow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/mlx5/mlx5_flow.c +1
-1@@ -1977,7 +1977,7 @@ mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,RTE_FLOW_ERROR_TYPE_ITEM , item,"IPv6 cannot follow L2/VLAN layer " "which ether type is not IPv6"); -if (mask && spec) +if (mask && mask->hdr.proto && spec) next_proto = mask->hdr.proto & spec->hdr.proto;if (item_flags &MLX5_FLOW_LAYER_IPV6_ENCAP ) {if (next_proto ==IPPROTO_IPIP || next_proto ==IPPROTO_IPV6 )
From: Eli Britstein
Quoted 21 lines
Previous patch added validation of the IPv6 next proto field, in order to overcome a known limitation.
One of the values checked isIPPROTO_HOPOPTS, which is defined as 0. If proto field is not specified for matching, or mask=0, as in the following, a wrong validation takes place.
flow create 0 ingress pattern eth / ipv6has_frag_extis 0 / end actions drop / end Fix the validation only on proto asked by the user.Fixes 55e4c1d1ba73 ("net/mlx5: enforce limitation on IPv6 next proto")Signed-off-by Eli Britstein <[email protected]>Acked-by Dekel Peled <[email protected]>--- drivers/net/mlx5/mlx5_flow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/mlx5/mlx5_flow.c +0
-0
drivers/net/mlx5/mlx5_flow.c mlx5_flow_validate_item_ipv6(const struct · line 1982
Quoted 7 lines
drivers/net/mlx5/mlx5_flow.c +1
-1@@ -1977,7 +1977,7 @@ mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,RTE_FLOW_ERROR_TYPE_ITEM , item,"IPv6 cannot follow L2/VLAN layer " "which ether type is not IPv6"); -if (mask && spec) +if (mask && mask->hdr.proto && spec)
If you want to be sure os specific proto only you need to check mask->hdr.proto==0xFF, no?
Quoted 6 lines
drivers/net/mlx5/mlx5_flow.c +0
-0next_proto = mask->hdr.proto & spec->hdr.proto;drivers/net/mlx5/mlx5_flow.c +0
-0if (item_flags & MLX5_FLOW_LAYER_IPV6_ENCAP) { if (next_proto == IPPROTO_IPIP || next_proto ==
IPPROTO_IPV6)
--
2.28.0.546.g385c171
PATCH v3 1/1 net/mlx5: fix IPv6 next proto validation
Previous patch added validation of the IPv6 next proto field, in order to overcome a known limitation.
One of the values checked is IPPROTO_HOPOPTS, which is defined as 0. If proto field is not specified for matching, or mask=0, as in the following, a wrong validation takes place.
flow create 0 ingress pattern eth / ipv6 has_frag_ext is 0 / end actions drop / end
Fix the validation only on proto asked by the user.
--- drivers/net/mlx5/mlx5_flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow.c +2 -2
@@ -1979,8 +1979,8 @@ mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,RTE_FLOW_ERROR_TYPE_ITEM , item,"IPv6 cannot follow L2/VLAN layer " "which ether type is not IPv6"); -if (mask && spec) - next_proto = mask->hdr.proto & spec->hdr.proto; +if (mask && mask->hdr.proto ==UINT8_MAX && spec) + next_proto = spec->hdr.proto;if (item_flags &MLX5_FLOW_LAYER_IPV6_ENCAP ) {if (next_proto ==IPPROTO_IPIP || next_proto ==IPPROTO_IPV6 ) return rte_flow_error_set(error, EINVAL,
Signature · 1 line
2.28.0.546.g385c171
Hi,
Quoted 43 lines
-----Original Message-----
From: Eli Britstein <[email protected]>
Sent: Thursday, October 22, 2020 11:26 AM
To: [email protected]
Cc: Dekel Peled <[email protected]>; Ori Kam <[email protected]>; Matan Azrad <[email protected]>; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Shahaf Shuler <[email protected]>; Asaf Penso <[email protected]>; Eli Britstein <[email protected]>
Subject: [PATCH V3 1/1] net/mlx5: fix IPv6 next proto validationPrevious patch added validation of the IPv6 next proto field, in order to overcome a known limitation.
One of the values checked isIPPROTO_HOPOPTS, which is defined as 0. If proto field is not specified for matching, or mask=0, as in the following, a wrong validation takes place.
flow create 0 ingress pattern eth / ipv6has_frag_extis 0 / end actions drop / end
Fix the validation only on proto asked by the user.Fixes 92be60e1b541 ("net/mlx5: enforce limitation on IPv6 next proto")Signed-off-by Eli Britstein <[email protected]>Acked-by Dekel Peled <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/net/mlx5/mlx5_flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/mlx5/mlx5_flow.c +2
-2@@ -1979,8 +1979,8 @@ mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,RTE_FLOW_ERROR_TYPE_ITEM , item,"IPv6 cannot follow L2/VLAN layer " "which ether type is not IPv6"); -if (mask && spec) - next_proto = mask->hdr.proto & spec->hdr.proto; +if (mask && mask->hdr.proto ==UINT8_MAX && spec) + next_proto = spec->hdr.proto;if (item_flags &MLX5_FLOW_LAYER_IPV6_ENCAP ) {
Quoted 5 lines
if (
next_proto==IPPROTO_IPIP||next_proto==IPPROTO_IPV6)
return rte_flow_error_set(error, EINVAL,
--
2.28.0.546.g385c171
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Quoted 21 lines · Raslan Darawsheh
Hi,
Quoted 19 lines
-----Original Message-----
From: Eli Britstein <[email protected]>
Sent: Thursday, October 22, 2020 11:26 AM
To: [email protected]
Cc: Dekel Peled <[email protected]>; Ori Kam <[email protected]>; Matan Azrad <[email protected]>; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Shahaf Shuler <[email protected]>; Asaf Penso <[email protected]>; Eli Britstein <[email protected]>
Subject: [PATCH V3 1/1] net/mlx5: fix IPv6 next proto validationPrevious patch added validation of the IPv6 next proto field, in order to overcome a known limitation.
One of the values checked isIPPROTO_HOPOPTS, which is defined as 0. If proto field is not specified for matching, or mask=0, as in the following, a wrong validation takes place.
flow create 0 ingress pattern eth / ipv6has_frag_extis 0 / end actions drop / end
Fix the validation only on proto asked by the user.
Quoted 9 lines
Quoted 5 lines
Fixes 92be60e1b541 ("net/mlx5: enforce limitation on IPv6 next proto")Signed-off-by Eli Britstein <[email protected]>Acked-by Dekel Peled <[email protected]>Acked-by Matan Azrad <[email protected]>Patch applied to next-net-mlx,
Squashed into relevant commit in next-net, thanks.