net/i40e: fix integer overflow

Message ID 1571041986-37562-1-git-send-email-xiao.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers
Series net/i40e: fix integer overflow |

Checks

Context Check Description
ci/iol-compilation success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Xiao Zhang Oct. 14, 2019, 8:33 a.m. UTC
  When configuring i40e rx queue, the temporary variable to store max packet
length is not big enough which leads to integer overflow issue. This
patch is to fix the issue by changing the variable type from uint16_t
to uint32_t.

Fixes: c511a96a34d7 ("mbuf: add accessors for data room and private
size")
Cc: stable@dpdk.org

Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
---
 drivers/net/i40e/i40e_rxtx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Kevin Traynor Oct. 14, 2019, 10:35 a.m. UTC | #1
On 14/10/2019 09:33, Xiao Zhang wrote:
> When configuring i40e rx queue, the temporary variable to store max packet
> length is not big enough which leads to integer overflow issue. This
> patch is to fix the issue by changing the variable type from uint16_t
> to uint32_t.
> 
> Fixes: c511a96a34d7 ("mbuf: add accessors for data room and private
> size")

It should be
Fixes: 4861cde46116 ("i40e: new poll mode driver")

> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
> ---
>  drivers/net/i40e/i40e_rxtx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> index bfe161f..ca15b12 100644
> --- a/drivers/net/i40e/i40e_rxtx.c
> +++ b/drivers/net/i40e/i40e_rxtx.c
> @@ -2596,7 +2596,8 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq)
>  	struct i40e_pf *pf = I40E_VSI_TO_PF(rxq->vsi);
>  	struct i40e_hw *hw = I40E_VSI_TO_HW(rxq->vsi);
>  	struct rte_eth_dev_data *data = pf->dev_data;
> -	uint16_t buf_size, len;
> +	uint16_t buf_size;
> +	uint32_t len;
>  

You can just remove the variable, it's only used once.

>  	buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
>  		RTE_PKTMBUF_HEADROOM);
>
  
Xiao Zhang Oct. 15, 2019, 1:10 a.m. UTC | #2
Hi Kevin,

Will update the patch according to your comments. Thanks.

Xiao

> -----Original Message-----
> From: Kevin Traynor [mailto:ktraynor@redhat.com]
> Sent: Monday, October 14, 2019 6:36 PM
> To: Zhang, Xiao <xiao.zhang@intel.com>; dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> stable@dpdk.org
> Subject: Re: [dpdk-dev] net/i40e: fix integer overflow
> 
> On 14/10/2019 09:33, Xiao Zhang wrote:
> > When configuring i40e rx queue, the temporary variable to store max
> > packet length is not big enough which leads to integer overflow issue.
> > This patch is to fix the issue by changing the variable type from
> > uint16_t to uint32_t.
> >
> > Fixes: c511a96a34d7 ("mbuf: add accessors for data room and private
> > size")
> 
> It should be
> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> 
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
> > ---
> >  drivers/net/i40e/i40e_rxtx.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/i40e/i40e_rxtx.c
> > b/drivers/net/i40e/i40e_rxtx.c index bfe161f..ca15b12 100644
> > --- a/drivers/net/i40e/i40e_rxtx.c
> > +++ b/drivers/net/i40e/i40e_rxtx.c
> > @@ -2596,7 +2596,8 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq)
> >  	struct i40e_pf *pf = I40E_VSI_TO_PF(rxq->vsi);
> >  	struct i40e_hw *hw = I40E_VSI_TO_HW(rxq->vsi);
> >  	struct rte_eth_dev_data *data = pf->dev_data;
> > -	uint16_t buf_size, len;
> > +	uint16_t buf_size;
> > +	uint32_t len;
> >
> 
> You can just remove the variable, it's only used once.
> 
> >  	buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
> >  		RTE_PKTMBUF_HEADROOM);
> >
  

Patch

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index bfe161f..ca15b12 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2596,7 +2596,8 @@  i40e_rx_queue_config(struct i40e_rx_queue *rxq)
 	struct i40e_pf *pf = I40E_VSI_TO_PF(rxq->vsi);
 	struct i40e_hw *hw = I40E_VSI_TO_HW(rxq->vsi);
 	struct rte_eth_dev_data *data = pf->dev_data;
-	uint16_t buf_size, len;
+	uint16_t buf_size;
+	uint32_t len;
 
 	buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
 		RTE_PKTMBUF_HEADROOM);