From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 27B44106A; Tue, 13 Dec 2016 17:15:14 +0100 (CET) Received: from uucp by smtp.tuxdriver.com with local-rmail (Exim 4.63) (envelope-from ) id 1cGpjT-0007kA-VM; Tue, 13 Dec 2016 11:15:12 -0500 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.15.2/8.14.6) with ESMTP id uBDG5qxE031617; Tue, 13 Dec 2016 11:05:52 -0500 Received: (from linville@localhost) by localhost.localdomain (8.15.2/8.15.2/Submit) id uBDG5p5B031616; Tue, 13 Dec 2016 11:05:51 -0500 Date: Tue, 13 Dec 2016 11:05:51 -0500 From: "John W. Linville" To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: dev@dpdk.org, test-report@dpdk.org Message-ID: <20161213160550.GA27914@tuxdriver.com> References: <20161213010918.F1B095684@dpdk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Subject: Re: [dpdk-dev] [PATCH v2 08/13] PMD/af_packet: guard against buffer overruns in RX path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Dec 2016 16:15:14 -0000 On Tue, Dec 13, 2016 at 02:28:34AM +0100, Michał Mirosław wrote: > > Signed-off-by: Michał Mirosław Acked-by: John W. Linville > --- > drivers/net/af_packet/rte_eth_af_packet.c | 11 ++++++----- > 1 file changed, 6 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 ff45068..5599e02 100644 > --- a/drivers/net/af_packet/rte_eth_af_packet.c > +++ b/drivers/net/af_packet/rte_eth_af_packet.c > @@ -370,18 +370,19 @@ 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; > } > > -- > 2.10.2 > > -- John W. Linville Someday the world will need a hero, and you linville@tuxdriver.com might be all we have. Be ready.