patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/octeontx2: fix corruption in segments list
@ 2020-12-21 14:03 skori
  2020-12-28 12:17 ` [dpdk-stable] [dpdk-dev] " Nithin Dabilpuram
  0 siblings, 1 reply; 3+ messages in thread
From: skori @ 2020-12-21 14:03 UTC (permalink / raw)
  To: Jerin Jacob, Nithin Dabilpuram, Kiran Kumar K
  Cc: dev, Sunil Kumar Kori, stable

From: Sunil Kumar Kori <skori@marvell.com>

On Tx, lastseg->next is not being reset to null for multi segmented packet
and same mbuf can be used on Rx which has a stale mbuf entry into
mbuf->next.

On Rx, application receives mbuf with mbuf->next uninitialized though
mbuf->nb_segs is correct. Application iterates over all segments using
mbuf->next ignoring mbuf->nb_segs which leads to undefined behavior.

So earlier assumption of just having right value in mbuf->nb_segs is
enough, is incorrect. Mbuf must contain valid and synced value in
nb_segs and next pointer.

Fixes: 364eb0e46683 ("net/octeontx2: avoid per packet barrier with multi segment")
Cc: stable@dpdk.org

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
 drivers/net/octeontx2/otx2_rx.c | 6 ++++++
 drivers/net/octeontx2/otx2_rx.h | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/octeontx2/otx2_rx.c b/drivers/net/octeontx2/otx2_rx.c
index 2da8efe77..ffeade595 100644
--- a/drivers/net/octeontx2/otx2_rx.c
+++ b/drivers/net/octeontx2/otx2_rx.c
@@ -279,6 +279,12 @@ nix_recv_pkts_vector(void *rx_queue, struct rte_mbuf **rx_pkts,
 		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
 		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
 
+		/* Update that no more segments */
+		mbuf0->next = NULL;
+		mbuf1->next = NULL;
+		mbuf2->next = NULL;
+		mbuf3->next = NULL;
+
 		/* Store the mbufs to rx_pkts */
 		vst1q_u64((uint64_t *)&rx_pkts[packets], mbuf01);
 		vst1q_u64((uint64_t *)&rx_pkts[packets + 2], mbuf23);
diff --git a/drivers/net/octeontx2/otx2_rx.h b/drivers/net/octeontx2/otx2_rx.h
index 926f614a4..0ba3d3d96 100644
--- a/drivers/net/octeontx2/otx2_rx.h
+++ b/drivers/net/octeontx2/otx2_rx.h
@@ -215,6 +215,7 @@ nix_cqe_xtract_mseg(const struct nix_rx_parse_s *rx,
 			iova_list = (const rte_iova_t *)(iova_list + 1);
 		}
 	}
+	mbuf->next = NULL;
 }
 
 static __rte_always_inline uint16_t
@@ -330,10 +331,12 @@ otx2_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag,
 	*(uint64_t *)(&mbuf->rearm_data) = val;
 	mbuf->pkt_len = len;
 
-	if (flag & NIX_RX_MULTI_SEG_F)
+	if (flag & NIX_RX_MULTI_SEG_F) {
 		nix_cqe_xtract_mseg(rx, mbuf, val);
-	else
+	} else {
 		mbuf->data_len = len;
+		mbuf->next = NULL;
+	}
 }
 
 #define CKSUM_F NIX_RX_OFFLOAD_CHECKSUM_F
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/octeontx2: fix corruption in segments list
  2020-12-21 14:03 [dpdk-stable] [PATCH] net/octeontx2: fix corruption in segments list skori
@ 2020-12-28 12:17 ` Nithin Dabilpuram
  2021-01-12 18:13   ` Jerin Jacob
  0 siblings, 1 reply; 3+ messages in thread
From: Nithin Dabilpuram @ 2020-12-28 12:17 UTC (permalink / raw)
  To: skori; +Cc: Jerin Jacob, Kiran Kumar K, dev, stable

On Mon, Dec 21, 2020 at 07:33:08PM +0530, skori@marvell.com wrote:
> From: Sunil Kumar Kori <skori@marvell.com>
> 
> On Tx, lastseg->next is not being reset to null for multi segmented packet
> and same mbuf can be used on Rx which has a stale mbuf entry into
> mbuf->next.
> 
> On Rx, application receives mbuf with mbuf->next uninitialized though
> mbuf->nb_segs is correct. Application iterates over all segments using
> mbuf->next ignoring mbuf->nb_segs which leads to undefined behavior.
> 
> So earlier assumption of just having right value in mbuf->nb_segs is
> enough, is incorrect. Mbuf must contain valid and synced value in
> nb_segs and next pointer.
> 
> Fixes: 364eb0e46683 ("net/octeontx2: avoid per packet barrier with multi segment")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> ---
>  drivers/net/octeontx2/otx2_rx.c | 6 ++++++
>  drivers/net/octeontx2/otx2_rx.h | 7 +++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/octeontx2/otx2_rx.c b/drivers/net/octeontx2/otx2_rx.c
> index 2da8efe77..ffeade595 100644
> --- a/drivers/net/octeontx2/otx2_rx.c
> +++ b/drivers/net/octeontx2/otx2_rx.c
> @@ -279,6 +279,12 @@ nix_recv_pkts_vector(void *rx_queue, struct rte_mbuf **rx_pkts,
>  		vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
>  		vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
>  
> +		/* Update that no more segments */
> +		mbuf0->next = NULL;
> +		mbuf1->next = NULL;
> +		mbuf2->next = NULL;
> +		mbuf3->next = NULL;
> +
>  		/* Store the mbufs to rx_pkts */
>  		vst1q_u64((uint64_t *)&rx_pkts[packets], mbuf01);
>  		vst1q_u64((uint64_t *)&rx_pkts[packets + 2], mbuf23);
> diff --git a/drivers/net/octeontx2/otx2_rx.h b/drivers/net/octeontx2/otx2_rx.h
> index 926f614a4..0ba3d3d96 100644
> --- a/drivers/net/octeontx2/otx2_rx.h
> +++ b/drivers/net/octeontx2/otx2_rx.h
> @@ -215,6 +215,7 @@ nix_cqe_xtract_mseg(const struct nix_rx_parse_s *rx,
>  			iova_list = (const rte_iova_t *)(iova_list + 1);
>  		}
>  	}
> +	mbuf->next = NULL;
>  }
>  
>  static __rte_always_inline uint16_t
> @@ -330,10 +331,12 @@ otx2_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag,
>  	*(uint64_t *)(&mbuf->rearm_data) = val;
>  	mbuf->pkt_len = len;
>  
> -	if (flag & NIX_RX_MULTI_SEG_F)
> +	if (flag & NIX_RX_MULTI_SEG_F) {
>  		nix_cqe_xtract_mseg(rx, mbuf, val);
> -	else
> +	} else {
>  		mbuf->data_len = len;
> +		mbuf->next = NULL;
> +	}
>  }
>  
>  #define CKSUM_F NIX_RX_OFFLOAD_CHECKSUM_F
> -- 
> 2.25.1
> 

Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/octeontx2: fix corruption in segments list
  2020-12-28 12:17 ` [dpdk-stable] [dpdk-dev] " Nithin Dabilpuram
@ 2021-01-12 18:13   ` Jerin Jacob
  0 siblings, 0 replies; 3+ messages in thread
From: Jerin Jacob @ 2021-01-12 18:13 UTC (permalink / raw)
  To: Nithin Dabilpuram
  Cc: Sunil Kumar Kori, Jerin Jacob, Kiran Kumar K, dpdk-dev, dpdk stable

On Mon, Dec 28, 2020 at 5:48 PM Nithin Dabilpuram <nithind1988@gmail.com> wrote:
>
> On Mon, Dec 21, 2020 at 07:33:08PM +0530, skori@marvell.com wrote:
> > From: Sunil Kumar Kori <skori@marvell.com>
> >
> > On Tx, lastseg->next is not being reset to null for multi segmented packet
> > and same mbuf can be used on Rx which has a stale mbuf entry into
> > mbuf->next.
> >
> > On Rx, application receives mbuf with mbuf->next uninitialized though
> > mbuf->nb_segs is correct. Application iterates over all segments using
> > mbuf->next ignoring mbuf->nb_segs which leads to undefined behavior.
> >
> > So earlier assumption of just having right value in mbuf->nb_segs is
> > enough, is incorrect. Mbuf must contain valid and synced value in
> > nb_segs and next pointer.
> >
> > Fixes: 364eb0e46683 ("net/octeontx2: avoid per packet barrier with multi segment")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>

> >
>
> Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>

Applied to dpdk-next-net-mrvl/for-main. Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-12 18:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 14:03 [dpdk-stable] [PATCH] net/octeontx2: fix corruption in segments list skori
2020-12-28 12:17 ` [dpdk-stable] [dpdk-dev] " Nithin Dabilpuram
2021-01-12 18:13   ` Jerin Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).