John Lo | 84bde8d | 2016-07-20 16:14:57 -0400 | [diff] [blame] | 1 | From cee88bcfd49cbf142c13ee7b6d2e77166c80bb48 Mon Sep 17 00:00:00 2001 |
| 2 | From: John Daley <johndale@cisco.com> |
| 3 | Date: Tue, 19 Jul 2016 13:41:14 -0700 |
| 4 | Subject: [PATCH] net/enic: fix possible Rx corruption |
| 5 | |
| 6 | Initialize the mbuf data offset to RTE_PKTMBUF_HEADROOM as the |
| 7 | enic takes ownership of them. If allocated mbufs had some offset |
| 8 | other than RTE_PKTMBUF_HEADROOM, the application would read mbuf |
| 9 | data starting at the wrong place and misinterpret the packet. |
| 10 | |
| 11 | Fixes: 856d7ba7ed22 ("net/enic: support scattered Rx") |
| 12 | |
| 13 | Reviewed-by: Nelson Escobar <neescoba@cisco.com> |
| 14 | Signed-off-by: John Daley <johndale@cisco.com> |
| 15 | --- |
| 16 | drivers/net/enic/enic_main.c | 1 + |
| 17 | drivers/net/enic/enic_rxtx.c | 2 +- |
| 18 | 2 files changed, 2 insertions(+), 1 deletion(-) |
| 19 | |
| 20 | diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c |
| 21 | index 8cedebf..774fcb1 100644 |
| 22 | --- a/drivers/net/enic/enic_main.c |
| 23 | +++ b/drivers/net/enic/enic_main.c |
| 24 | @@ -328,6 +328,7 @@ enic_alloc_rx_queue_mbufs(struct enic *enic, struct vnic_rq *rq) |
| 25 | return -ENOMEM; |
| 26 | } |
| 27 | |
| 28 | + mb->data_off = RTE_PKTMBUF_HEADROOM; |
| 29 | dma_addr = (dma_addr_t)(mb->buf_physaddr + RTE_PKTMBUF_HEADROOM); |
| 30 | rq_enet_desc_enc(rqd, dma_addr, |
| 31 | (rq->is_sop ? RQ_ENET_TYPE_ONLY_SOP |
| 32 | diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c |
| 33 | index c68bbfb..60f5062 100644 |
| 34 | --- a/drivers/net/enic/enic_rxtx.c |
| 35 | +++ b/drivers/net/enic/enic_rxtx.c |
| 36 | @@ -317,7 +317,7 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, |
| 37 | ciflags = enic_cq_rx_desc_ciflags((struct cq_enet_rq_desc *) &cqd); |
| 38 | |
| 39 | /* Push descriptor for newly allocated mbuf */ |
| 40 | - |
| 41 | + nmb->data_off = RTE_PKTMBUF_HEADROOM; |
| 42 | dma_addr = (dma_addr_t)(nmb->buf_physaddr + RTE_PKTMBUF_HEADROOM); |
| 43 | rq_enet_desc_enc(rqd_ptr, dma_addr, |
| 44 | (rq->is_sop ? RQ_ENET_TYPE_ONLY_SOP |
| 45 | -- |
| 46 | 2.7.0 |
| 47 | |