net/i40e: fix memory overflow in 32-bit SSE Rx
authorQi Zhang <qi.z.zhang@intel.com>
Sun, 30 Apr 2017 05:26:49 +0000 (01:26 -0400)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 5 May 2017 15:40:21 +0000 (17:40 +0200)
Return mbuf points of _recv_raw_pkts_vec are modified out of bound.

Fixes: 8e109464c022 ("i40e: allow vector Rx and Tx usage")
Cc: stable@dpdk.org
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/i40e/i40e_rxtx_vec_sse.c

index 8bc3399..3b4a352 100644 (file)
@@ -316,20 +316,26 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
                __m128i descs[RTE_I40E_DESCS_PER_LOOP];
                __m128i pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
                __m128i zero, staterr, sterr_tmp1, sterr_tmp2;
-               __m128i mbp1, mbp2; /* two mbuf pointer in one XMM reg. */
+               /* 2 64 bit or 4 32 bit mbuf pointers in one XMM reg. */
+               __m128i mbp1;
+#if defined(RTE_ARCH_X86_64)
+               __m128i mbp2;
+#endif
 
-               /* B.1 load 1 mbuf point */
+               /* B.1 load 2 (64 bit) or 4 (32 bit) mbuf points */
                mbp1 = _mm_loadu_si128((__m128i *)&sw_ring[pos]);
                /* Read desc statuses backwards to avoid race condition */
                /* A.1 load 4 pkts desc */
                descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
                rte_compiler_barrier();
 
-               /* B.2 copy 2 mbuf point into rx_pkts  */
+               /* B.2 copy 2 64 bit or 4 32 bit mbuf point into rx_pkts */
                _mm_storeu_si128((__m128i *)&rx_pkts[pos], mbp1);
 
-               /* B.1 load 1 mbuf point */
+#if defined(RTE_ARCH_X86_64)
+               /* B.1 load 2 64 bit mbuf points */
                mbp2 = _mm_loadu_si128((__m128i *)&sw_ring[pos+2]);
+#endif
 
                descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
                rte_compiler_barrier();
@@ -338,8 +344,10 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
                rte_compiler_barrier();
                descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
 
+#if defined(RTE_ARCH_X86_64)
                /* B.2 copy 2 mbuf point into rx_pkts  */
                _mm_storeu_si128((__m128i *)&rx_pkts[pos+2], mbp2);
+#endif
 
                if (split_packet) {
                        rte_mbuf_prefetch_part2(rx_pkts[pos]);