net/iavf: add segment-length check to Tx prep

Message ID 20241111164221.3031276-1-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers
Series net/iavf: add segment-length check to Tx prep |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing warning Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Bruce Richardson Nov. 11, 2024, 4:42 p.m. UTC
In the Tx prep function, the metadata checks were only checking the
packet length and ignoring the data length. For single-buffer packets we
can quickly check that the data length is the packet length.

Fixes: 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
Cc: stable@dpdk.org

Reported-by: Padraig Connolly <padraig.j.connolly@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Vladimir Medvedkin Nov. 11, 2024, 5:46 p.m. UTC | #1
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

On 11/11/2024 16:42, Bruce Richardson wrote:
> In the Tx prep function, the metadata checks were only checking the
> packet length and ignoring the data length. For single-buffer packets we
> can quickly check that the data length is the packet length.
>
> Fixes: 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
> Cc: stable@dpdk.org
>
> Reported-by: Padraig Connolly <padraig.j.connolly@intel.com>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>   drivers/net/iavf/iavf_rxtx.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
> index 4850b9e381..6a093c6746 100644
> --- a/drivers/net/iavf/iavf_rxtx.c
> +++ b/drivers/net/iavf/iavf_rxtx.c
> @@ -3677,7 +3677,11 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
>   			return i;
>   		}
>   
> -		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
> +		/* valid packets are greater than min size, and single-buffer pkts
> +		 * must have data_len == pkt_len
> +		 */
> +		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
> +				(m->nb_segs == 1 && m->data_len != m->pkt_len)) {
>   			rte_errno = EINVAL;
>   			return i;
>   		}
  
Connolly, Padraig J Nov. 19, 2024, 9:54 a.m. UTC | #2
Tested-by: Padraig Connolly <padraig.j.connolly@intel.com>
> Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

>On 11/11/2024 16:42, Bruce Richardson wrote:
> > In the Tx prep function, the metadata checks were only checking the
> > packet length and ignoring the data length. For single-buffer packets we
> > can quickly check that the data length is the packet length.
> >
> > Fixes: 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
> > Cc: stable@dpdk.org
> >
> > Reported-by: Padraig Connolly <padraig.j.connolly@intel.com>
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> >   drivers/net/iavf/iavf_rxtx.c | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
> > index 4850b9e381..6a093c6746 100644
> > --- a/drivers/net/iavf/iavf_rxtx.c
> > +++ b/drivers/net/iavf/iavf_rxtx.c
> > @@ -3677,7 +3677,11 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
> >                        return i;
> >                }
> >
> > -             if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
> > +             /* valid packets are greater than min size, and single-buffer pkts
> > +              * must have data_len == pkt_len
> > +              */
> > +             if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
> > +                             (m->nb_segs == 1 && m->data_len != m->pkt_len)) {
> >                        rte_errno = EINVAL;
> >                        return i;
> >                }

--
Regards,
Vladimir
Tested-by: Padraig Connolly <padraig.j.connolly@intel.com>
  
Bruce Richardson Nov. 19, 2024, 11:41 a.m. UTC | #3
On Tue, Nov 19, 2024 at 09:17:57AM +0000, Connolly, Padraig J wrote:
>      __________________________________________________________________
> 
>    From: Medvedkin, Vladimir <vladimir.medvedkin@intel.com>
>    Sent: Monday 11 November 2024 5:46 pm
>    To: Richardson, Bruce <bruce.richardson@intel.com>; dev@dpdk.org
>    <dev@dpdk.org>
>    Cc: stable@dpdk.org <stable@dpdk.org>; Connolly, Padraig J
>    <padraig.j.connolly@intel.com>; Stokes, Ian <ian.stokes@intel.com>;
>    Zhang, Qi Z <qi.z.zhang@intel.com>; Kevin Liu <kevinx.liu@intel.com>
>    Subject: Re: [PATCH] net/iavf: add segment-length check to Tx prep
> 
>    On 11/11/2024 16:42, Bruce Richardson wrote:
>    > In the Tx prep function, the metadata checks were only checking the
>    > packet length and ignoring the data length. For single-buffer packets
>    we
>    > can quickly check that the data length is the packet length.
>    >
>    > Fixes: 19ee91c6bd9a ("net/iavf: check illegal packet sizes")
>    > Cc: stable@dpdk.org
>    >
>    > Reported-by: Padraig Connolly <padraig.j.connolly@intel.com>
>    > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>    Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
>    Tested-by: Padraig Connolly <padraig.j.connolly@intel.com>

Applied to dpdk-next-net-intel

/Bruce
  

Patch

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 4850b9e381..6a093c6746 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -3677,7 +3677,11 @@  iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 			return i;
 		}
 
-		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) {
+		/* valid packets are greater than min size, and single-buffer pkts
+		 * must have data_len == pkt_len
+		 */
+		if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
+				(m->nb_segs == 1 && m->data_len != m->pkt_len)) {
 			rte_errno = EINVAL;
 			return i;
 		}