From: Daniil Bobryshev <[email protected]>

With the enhanced CQE compression layout the vectorized Multi-Packet
RQ burst keeps a copy of the title packet in rxq->title_pkt, and
rxq_cq_decompress_v() stores its rearm data and offload flags (one
16-byte store) into every packet of the compressed session.

rxq_burst_mprq_v() takes that copy after rxq_copy_mprq_mbuf_v(). By
then mprq_buf_to_pkt() has attached a title packet longer than
mprq_max_memcpy_len to its stride, so the copy carries
RTE_MBUF_F_EXTERNAL (and nb_segs 2 if a headroom overlap was chained).
Every packet of the session inherits the flag. A packet that is
then attached gets a valid shinfo, but a packet that is copied into
its own buffer (short frames, out of MPRQ buffers, filler CQEs) keeps
RTE_MBUF_F_EXTERNAL with the shinfo of a fresh mbuf (NULL) or a stale
one. Freeing it crashes in rte_mbuf_ext_refcnt_update(), or decrements
the reference count of a stride that is still in use.

Seen on ConnectX-6 Dx with rxq_cqe_comp_en=129 and mprq_en=1: 1514-byte
traffic with occasional 60-byte ARP frames between the long ones
segfaults within a second in rte_pktmbuf_free() of a 60-byte mbuf whose
buf_addr is its own data room and whose ol_flags are
0x2000000000000182 with shinfo NULL. 64-byte traffic, which is always
copied, and the basic layout, where the title is taken before the
stride attach, do not hit it.

MPRQ is never enabled for pools with pinned external buffers, so in
this burst RTE_MBUF_F_EXTERNAL can only come from the stride attach.
Clear it and reset nb_segs in the title copy. Moving the copy before
rxq_copy_mprq_mbuf_v() is not simpler: the check that decides whether
to take it reads rxq->cq_ci, which rxq_copy_mprq_mbuf_v() advances.

Fixes: fc3e1798eba2 ("net/mlx5: support enhanced CQE zipping in vector Rx 
burst")
Cc: [email protected]

Signed-off-by: Daniil Bobryshev <[email protected]>
---
Depends-on: patch-173059 ("net/mlx5: fix Rx queue count with enhanced CQE 
compression")

 drivers/net/mlx5/mlx5_rxtx_vec.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c
index 228ff2bfc..a2c2db7ca 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec.c
@@ -553,9 +553,21 @@ rxq_burst_mprq_v(struct mlx5_rxq_data *rxq, struct 
rte_mbuf **pkts,
                        next = &(*rxq->cqes)[rxq->cq_ci & q_mask];
                        ret = check_cqe_iteration(next, rxq->cqe_n, rxq->cq_ci);
                        if (MLX5_CQE_FORMAT(next->op_own) == MLX5_COMPRESSED ||
-                           ret != MLX5_CQE_STATUS_SW_OWN)
+                           ret != MLX5_CQE_STATUS_SW_OWN) {
                                rte_memcpy(&rxq->title_pkt, elts[nocmp_n - 1],
                                           sizeof(struct rte_mbuf));
+                               /*
+                                * The title mbuf went through
+                                * rxq_copy_mprq_mbuf_v() above and may be
+                                * attached to its stride or chained. The
+                                * decompressed packets take rearm data and
+                                * flags from this copy, and the ones the PMD
+                                * then copies into their own buffer must not
+                                * be marked external or multi-segment.
+                                */
+                               rxq->title_pkt.ol_flags &= ~RTE_MBUF_F_EXTERNAL;
+                               rxq->title_pkt.nb_segs = 1;
+                       }
                }
        }
 decompress:
-- 
2.56.0

Reply via email to