net/i40e: fix raw flow item validation
PATCH 1/1 net/i40e: fix raw flow item validation
Commit c138a6c3bd0a ("net/i40e: validate raw flow items before dereferencing") rejected raw flow items when spec and mask length fields differ, intending to prevent out-of-bounds pattern access.
This breaks flows using the default rte_flow_item_raw_mask, which sets mask.length to 0xffff regardless of the spec pattern size. Remove the erroneous check.
--- drivers/net/intel/i40e/i40e_flow.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/net/intel/i40e/i40e_flow.c +0 -7
@@ -2360,13 +2360,6 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "NULL RAW mask pattern");return -rte_errno; } -if (raw_spec->length != raw_mask->length) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item, -"RAW spec and mask length mismatch" ); -return -rte_errno; - } }for (i =0 ; i < raw_spec->length; i++) {
Signature · 1 line
2.43.0
Quoted 22 lines · Ciara Loftus
Commit
c138a6c3bd0a("net/i40e: validate raw flow items before dereferencing") rejected raw flow items when spec and mask length fields differ, intending to prevent out-of-bounds pattern access.This breaks flows using the default
rte_flow_item_raw_mask, which sets mask.length to0xffffregardless of the spec pattern size. Remove the erroneous check.Fixes c138a6c3bd0a ("net/i40e: validate raw flow items before dereferencing")Signed-off-by Ciara Loftus <[email protected]>--- drivers/net/intel/i40e/i40e_flow.c | 7 ------- 1 file changed, 7 deletions(-)drivers/net/intel/i40e/i40e_flow.c +0
-0@@ -2360,13 +2360,6 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, "NULL RAW mask pattern");
drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, · line 2363
Quoted 10 lines
drivers/net/intel/i40e/i40e_flow.c +0
-7return -rte_errno; } -if (raw_spec->length != raw_mask->length) { -rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ITEM , - item, -"RAW spec and mask length mismatch" ); -return -rte_errno; - } }
This looks a correct check to have. Maybe we need to check how the default mask is generated for this case and fix things there?
Quoted 5 lines
drivers/net/intel/i40e/i40e_flow.c +0
-0for (i =0 ; i < raw_spec->length; i++) {Signature · 1 line
2.43.0
Quoted 38 lines
Subject: Re: [PATCH] net/i40e: fix raw flow item validation
Quoted 9 lines · Ciara Loftus
Commit
c138a6c3bd0a("net/i40e: validate raw flow items before dereferencing") rejected raw flow items when spec and mask length fields differ, intending to prevent out-of-bounds pattern access.This breaks flows using the default
rte_flow_item_raw_mask, which sets mask.length to0xffffregardless of the spec pattern size. Remove the erroneous check.Fixes c138a6c3bd0a ("net/i40e: validate raw flow items beforedereferencing")
Review
Quoted 8 lines
Signed-off-by Ciara Loftus <[email protected]>--- drivers/net/intel/i40e/i40e_flow.c | 7 ------- 1 file changed, 7 deletions(-)(quoted diff) +0
-0
b/drivers/net/intel/i40e/i40e_flow.cdrivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct
Quoted 4 lines
index
84cfddb92d..78191a2d22100644drivers/net/intel/i40e/i40e_flow.c +0
-0@@ -2360,13 +2360,6 @@ i40e_flow_parse_fdir_pattern(struct
rte_eth_dev*dev,drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct · line 2360
Quoted 1 line
drivers/net/intel/i40e/i40e_flow.c +0
-0"NULL RAW maskpattern");
drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
Quoted 5 lines
drivers/net/intel/i40e/i40e_flow.c +0
-3return -rte_errno; } -if (raw_spec->length != raw_mask->length) { - rte_flow_error_set(error, EINVAL, -
RTE_FLOW_ERROR_TYPE_ITEM,drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct · line 2367
Quoted 2 lines
drivers/net/intel/i40e/i40e_flow.c +0
-2- item, - "RAW spec andmask length mismatch");
Quoted 6 lines
drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, · line 2363
Quoted 3 lines
drivers/net/intel/i40e/i40e_flow.c +0
-2-return -rte_errno; - } }This looks a correct check to have. Maybe we need to check how the default mask is generated for this case and fix things there?
It is unclear to me, whether the length field of the mask should hold a bytecount or a bitmask. For example in testpmd if a raw flow is created without an explicit mask, the length appears to hold a bitmask all set to 1s.
If a raw flow is created with an explicit mask, the length appears to hold the bytecount of the mask.
Modifying that behaviour so that it is consistent appears to be non-trivial, I would be reluctant to change it this late in the release. If we wish to continue to permit the ambiguity in the driver for now, this patch is needed. Otherwise, we are accepting that the field should always hold a bytecount.
Quoted 6 lines
Quoted 6 lines
drivers/net/intel/i40e/i40e_flow.c +0
-1for (i =0 ; i < raw_spec->length; i++) { --2.43.0
Quoted 45 lines · Ciara
Quoted 38 lines
Subject: Re: [PATCH] net/i40e: fix raw flow item validation
Quoted 9 lines · Ciara Loftus
Commit
c138a6c3bd0a("net/i40e: validate raw flow items before dereferencing") rejected raw flow items when spec and mask length fields differ, intending to prevent out-of-bounds pattern access.This breaks flows using the default
rte_flow_item_raw_mask, which sets mask.length to0xffffregardless of the spec pattern size. Remove the erroneous check.Fixes c138a6c3bd0a ("net/i40e: validate raw flow items beforedereferencing")
Review
Quoted 8 lines
Signed-off-by Ciara Loftus <[email protected]>--- drivers/net/intel/i40e/i40e_flow.c | 7 ------- 1 file changed, 7 deletions(-)(quoted diff) +0
-0
b/drivers/net/intel/i40e/i40e_flow.cdrivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct
Quoted 4 lines
index
84cfddb92d..78191a2d22100644drivers/net/intel/i40e/i40e_flow.c +0
-0@@ -2360,13 +2360,6 @@ i40e_flow_parse_fdir_pattern(struct
rte_eth_dev*dev,drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct · line 2360
Quoted 1 line
drivers/net/intel/i40e/i40e_flow.c +0
-0"NULL RAW maskpattern");
drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
Quoted 5 lines
drivers/net/intel/i40e/i40e_flow.c +0
-3return -rte_errno; } -if (raw_spec->length != raw_mask->length) { - rte_flow_error_set(error, EINVAL, -
RTE_FLOW_ERROR_TYPE_ITEM,drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct · line 2367
Quoted 2 lines
drivers/net/intel/i40e/i40e_flow.c +0
-2- item, - "RAW spec andmask length mismatch");
Quoted 6 lines
drivers/net/intel/i40e/i40e_flow.c i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev, · line 2363
Quoted 3 lines
drivers/net/intel/i40e/i40e_flow.c +0
-2-return -rte_errno; - } }This looks a correct check to have. Maybe we need to check how the default mask is generated for this case and fix things there?
Quoted 12 lines
It is unclear to me, whether the length field of the mask should hold a bytecount or a bitmask. For example in testpmd if a raw flow is created without an explicit mask, the length appears to hold a bitmask all set to 1s.
If a raw flow is created with an explicit mask, the length appears to hold the bytecount of the mask.
Modifying that behaviour so that it is consistent appears to be non-trivial, I would be reluctant to change it this late in the release. If we wish to continue to permit the ambiguity in the driver for now, this patch is needed. Otherwise, we are accepting that the field should always hold a bytecount.
Ok, so safest option for this release is to revert this part of the code.
Will take the original patch.
/Bruce
Quoted 8 lines · Ciara Loftus
Commit
c138a6c3bd0a("net/i40e: validate raw flow items before dereferencing") rejected raw flow items when spec and mask length fields differ, intending to prevent out-of-bounds pattern access.This breaks flows using the default
rte_flow_item_raw_mask, which sets mask.length to0xffffregardless of the spec pattern size. Remove the erroneous check.
Quoted 5 lines
Fixes c138a6c3bd0a ("net/i40e: validate raw flow items before dereferencing")Signed-off-by Ciara Loftus <[email protected]>---
Applied to dpdk-next-net-intel,
Thanks,
/Bruce