net/i40e: Populate error in flow_parse_fdir_pattern

Message ID 20220322031937.252037-1-mkp@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/i40e: Populate error in flow_parse_fdir_pattern |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional fail Functional Testing issues

Commit Message

Mike Pattrick March 22, 2022, 3:19 a.m. UTC
  Errors from i40e_flow_parse_fdir_pattern() can bubble up to
rte_flow_create. If rte_flow_error is not initialized a caller may
dereference error->message. This may be uninitialized memory, leading
to a segemntation fault.

Signed-off-by: Mike Pattrick <mkp@redhat.com>
Fixes: 4a072ad43442 ("net/i40e: fix flow director config after flow validate")
Cc: stable@dpdk.org
---
 drivers/net/i40e/i40e_flow.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

David Marchand March 22, 2022, 8:35 a.m. UTC | #1
Hello Mike,

On Tue, Mar 22, 2022 at 4:20 AM Mike Pattrick <mkp@redhat.com> wrote:
>
> Errors from i40e_flow_parse_fdir_pattern() can bubble up to
> rte_flow_create. If rte_flow_error is not initialized a caller may
> dereference error->message. This may be uninitialized memory, leading
> to a segemntation fault.
>
> Signed-off-by: Mike Pattrick <mkp@redhat.com>
> Fixes: 4a072ad43442 ("net/i40e: fix flow director config after flow validate")
> Cc: stable@dpdk.org

Nit: the convention in DPDK is to have a block with the Fixes: and Cc:
lines together first, then the rest of the tags in a second block.

Fixes: 4a072ad43442 ("net/i40e: fix flow director config after flow validate")
Cc: stable@dpdk.org
<empty line>
Signed-off-by: Mike Pattrick <mkp@redhat.com>


> ---
>  drivers/net/i40e/i40e_flow.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index e0cf996200..4f3808cb5f 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -3142,8 +3142,11 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
>                 /* Check if the input set is valid */
>                 if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
>                                                 input_set) != 0) {
> -                       PMD_DRV_LOG(ERR, "Invalid input set");
> -                       return -EINVAL;
> +                       rte_flow_error_set(error, EINVAL,
> +                                          RTE_FLOW_ERROR_TYPE_ITEM,
> +                                          item,
> +                                          "Invalid input set");
> +                       return -rte_errno;
>                 }
>
>                 filter->input.flow_ext.input_set = input_set;
> --
> 2.27.0
>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  
Qi Zhang March 24, 2022, 9:15 a.m. UTC | #2
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Tuesday, March 22, 2022 4:36 PM
> To: Mike Pattrick <mkp@redhat.com>
> Cc: Xing, Beilei <beilei.xing@intel.com>; murphyx.yang@intel.com; dev
> <dev@dpdk.org>; dpdk stable <stable@dpdk.org>
> Subject: Re: [PATCH] net/i40e: Populate error in flow_parse_fdir_pattern
> 

Renamed title to 

"net/i40e: populate error in FDIR flow pattern parser"

To fix check-git-log warning

> Hello Mike,
> 
> On Tue, Mar 22, 2022 at 4:20 AM Mike Pattrick <mkp@redhat.com> wrote:
> >
> > Errors from i40e_flow_parse_fdir_pattern() can bubble up to
> > rte_flow_create. If rte_flow_error is not initialized a caller may
> > dereference error->message. This may be uninitialized memory, leading
> > to a segemntation fault.
> >
> > Signed-off-by: Mike Pattrick <mkp@redhat.com>
> > Fixes: 4a072ad43442 ("net/i40e: fix flow director config after flow
> > validate")
> > Cc: stable@dpdk.org
> 
> Nit: the convention in DPDK is to have a block with the Fixes: and Cc:
> lines together first, then the rest of the tags in a second block.
> 
> Fixes: 4a072ad43442 ("net/i40e: fix flow director config after flow validate")
> Cc: stable@dpdk.org
> <empty line>
> Signed-off-by: Mike Pattrick <mkp@redhat.com>
> 
> 
> > ---
> >  drivers/net/i40e/i40e_flow.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_flow.c
> > b/drivers/net/i40e/i40e_flow.c index e0cf996200..4f3808cb5f 100644
> > --- a/drivers/net/i40e/i40e_flow.c
> > +++ b/drivers/net/i40e/i40e_flow.c
> > @@ -3142,8 +3142,11 @@ i40e_flow_parse_fdir_pattern(struct
> rte_eth_dev *dev,
> >                 /* Check if the input set is valid */
> >                 if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
> >                                                 input_set) != 0) {
> > -                       PMD_DRV_LOG(ERR, "Invalid input set");
> > -                       return -EINVAL;
> > +                       rte_flow_error_set(error, EINVAL,
> > +                                          RTE_FLOW_ERROR_TYPE_ITEM,
> > +                                          item,
> > +                                          "Invalid input set");
> > +                       return -rte_errno;
> >                 }
> >
> >                 filter->input.flow_ext.input_set = input_set;
> > --
> > 2.27.0
> >
> 
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
> 
> 
> --
> David Marchand
  

Patch

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index e0cf996200..4f3808cb5f 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -3142,8 +3142,11 @@  i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 		/* Check if the input set is valid */
 		if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
 						input_set) != 0) {
-			PMD_DRV_LOG(ERR, "Invalid input set");
-			return -EINVAL;
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ITEM,
+					   item,
+					   "Invalid input set");
+			return -rte_errno;
 		}
 
 		filter->input.flow_ext.input_set = input_set;