* [dpdk-dev] net/i40e: fix integer overflow
@ 2019-10-14 8:33 Xiao Zhang
2019-10-14 10:35 ` Kevin Traynor
2019-10-15 5:29 ` [dpdk-dev] [v2] " Xiao Zhang
0 siblings, 2 replies; 5+ messages in thread
From: Xiao Zhang @ 2019-10-14 8:33 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, qi.z.zhang, Xiao Zhang, stable
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(-)
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);
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] net/i40e: fix integer overflow
2019-10-14 8:33 [dpdk-dev] net/i40e: fix integer overflow Xiao Zhang
@ 2019-10-14 10:35 ` Kevin Traynor
2019-10-15 1:10 ` Zhang, Xiao
2019-10-15 5:29 ` [dpdk-dev] [v2] " Xiao Zhang
1 sibling, 1 reply; 5+ messages in thread
From: Kevin Traynor @ 2019-10-14 10:35 UTC (permalink / raw)
To: Xiao Zhang, dev; +Cc: beilei.xing, qi.z.zhang, stable
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);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] net/i40e: fix integer overflow
2019-10-14 10:35 ` Kevin Traynor
@ 2019-10-15 1:10 ` Zhang, Xiao
0 siblings, 0 replies; 5+ messages in thread
From: Zhang, Xiao @ 2019-10-15 1:10 UTC (permalink / raw)
To: Kevin Traynor, dev; +Cc: Xing, Beilei, Zhang, Qi Z, stable
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);
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [v2] net/i40e: fix integer overflow
2019-10-14 8:33 [dpdk-dev] net/i40e: fix integer overflow Xiao Zhang
2019-10-14 10:35 ` Kevin Traynor
@ 2019-10-15 5:29 ` Xiao Zhang
2019-10-16 3:21 ` Ye Xiaolong
1 sibling, 1 reply; 5+ messages in thread
From: Xiao Zhang @ 2019-10-15 5:29 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, qi.z.zhang, ktraynor, Xiao Zhang, stable
When config 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 removing the variable and using the
expression directly since the variable only used once.
Fixes: 4861cde46116 ("i40e: new poll mode driver")
Cc: stable@dpdk.org
Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
---
v2
Correct the fixline and remove temporary variable.
---
drivers/net/i40e/i40e_rxtx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index bfe161f..ff6eb4a 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2596,7 +2596,7 @@ 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;
buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
RTE_PKTMBUF_HEADROOM);
@@ -2619,8 +2619,9 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq)
break;
}
- len = hw->func_caps.rx_buf_chain_len * rxq->rx_buf_len;
- rxq->max_pkt_len = RTE_MIN(len, data->dev_conf.rxmode.max_rx_pkt_len);
+ rxq->max_pkt_len =
+ RTE_MIN((uint32_t)(hw->func_caps.rx_buf_chain_len *
+ rxq->rx_buf_len), data->dev_conf.rxmode.max_rx_pkt_len);
if (data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN ||
rxq->max_pkt_len > I40E_FRAME_SIZE_MAX) {
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [v2] net/i40e: fix integer overflow
2019-10-15 5:29 ` [dpdk-dev] [v2] " Xiao Zhang
@ 2019-10-16 3:21 ` Ye Xiaolong
0 siblings, 0 replies; 5+ messages in thread
From: Ye Xiaolong @ 2019-10-16 3:21 UTC (permalink / raw)
To: Xiao Zhang; +Cc: dev, beilei.xing, qi.z.zhang, ktraynor, stable
On 10/15, Xiao Zhang wrote:
>When config 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 removing the variable and using the
>expression directly since the variable only used once.
>
>Fixes: 4861cde46116 ("i40e: new poll mode driver")
>Cc: stable@dpdk.org
>
>Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
>---
>v2
>Correct the fixline and remove temporary variable.
>---
> drivers/net/i40e/i40e_rxtx.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
>index bfe161f..ff6eb4a 100644
>--- a/drivers/net/i40e/i40e_rxtx.c
>+++ b/drivers/net/i40e/i40e_rxtx.c
>@@ -2596,7 +2596,7 @@ 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;
>
> buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
> RTE_PKTMBUF_HEADROOM);
>@@ -2619,8 +2619,9 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq)
> break;
> }
>
>- len = hw->func_caps.rx_buf_chain_len * rxq->rx_buf_len;
>- rxq->max_pkt_len = RTE_MIN(len, data->dev_conf.rxmode.max_rx_pkt_len);
>+ rxq->max_pkt_len =
>+ RTE_MIN((uint32_t)(hw->func_caps.rx_buf_chain_len *
>+ rxq->rx_buf_len), data->dev_conf.rxmode.max_rx_pkt_len);
> if (data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
> if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN ||
> rxq->max_pkt_len > I40E_FRAME_SIZE_MAX) {
>--
>2.7.4
>
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
Applied to dpdk-next-net-intel.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-16 3:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 8:33 [dpdk-dev] net/i40e: fix integer overflow Xiao Zhang
2019-10-14 10:35 ` Kevin Traynor
2019-10-15 1:10 ` Zhang, Xiao
2019-10-15 5:29 ` [dpdk-dev] [v2] " Xiao Zhang
2019-10-16 3:21 ` Ye Xiaolong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).