net/fm10k: fix memory overflow in 32-bit SSE Rx
authorQi Zhang <qi.z.zhang@intel.com>
Sun, 30 Apr 2017 05:26:51 +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: a6ce64a97520 ("fm10k: introduce vector driver")
Cc: stable@dpdk.org
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/fm10k/fm10k_rxtx_vec.c

index 89cd958..411bc44 100644 (file)
@@ -467,9 +467,13 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                __m128i descs0[RTE_FM10K_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. */
+               __m128i mbp1;
+               /* 2 64 bit or 4 32 bit mbuf pointers in one XMM reg. */
+#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 *)&mbufp[pos]);
 
                /* Read desc statuses backwards to avoid race condition */
@@ -477,11 +481,13 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                descs0[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 poitns */
                mbp2 = _mm_loadu_si128((__m128i *)&mbufp[pos+2]);
+#endif
 
                descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
                rte_compiler_barrier();
@@ -490,8 +496,10 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                rte_compiler_barrier();
                descs0[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
 
                /* avoid compiler reorder optimization */
                rte_compiler_barrier();