summaryrefslogtreecommitdiff
path: root/drivers/net/af_packet
diff options
context:
space:
mode:
authorMichał Mirosław <michal.miroslaw@atendesoftware.pl>2016-12-13 02:28:34 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2017-01-17 19:40:51 +0100
commitb5a8868bde2f32ad0e7ee8fb0edcceea74690a2a (patch)
tree55edb6d03dd2706d159ae425a33e6c072b1e496a /drivers/net/af_packet
parentc4fdcb6aedfc73e8c5284d7f5e7af2e742f2c4e1 (diff)
downloaddpdk-next-eventdev-b5a8868bde2f32ad0e7ee8fb0edcceea74690a2a.zip
dpdk-next-eventdev-b5a8868bde2f32ad0e7ee8fb0edcceea74690a2a.tar.gz
dpdk-next-eventdev-b5a8868bde2f32ad0e7ee8fb0edcceea74690a2a.tar.xz
net/af_packet: guard against buffer overruns in Rx path
Signed-off-by: Michał Mirosław <michal.miroslaw@atendesoftware.pl> Acked-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/af_packet')
-rw-r--r--drivers/net/af_packet/rte_eth_af_packet.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index f670165..ac16f8c 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -366,18 +366,20 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
{
struct pmd_internals *internals = dev->data->dev_private;
struct pkt_rx_queue *pkt_q = &internals->rx_queue[rx_queue_id];
- uint16_t buf_size;
+ unsigned int buf_size, data_size;
pkt_q->mb_pool = mb_pool;
/* Now get the space available for data in the mbuf */
- buf_size = (uint16_t)(rte_pktmbuf_data_room_size(pkt_q->mb_pool) -
- RTE_PKTMBUF_HEADROOM);
+ buf_size = rte_pktmbuf_data_room_size(pkt_q->mb_pool) -
+ RTE_PKTMBUF_HEADROOM;
+ data_size = internals->req.tp_frame_size;
+ data_size -= TPACKET2_HDRLEN - sizeof(struct sockaddr_ll);
- if (ETH_FRAME_LEN > buf_size) {
+ if (data_size > buf_size) {
RTE_LOG(ERR, PMD,
"%s: %d bytes will not fit in mbuf (%d bytes)\n",
- dev->data->name, ETH_FRAME_LEN, buf_size);
+ dev->data->name, data_size, buf_size);
return -ENOMEM;
}