* [dpdk-dev] [PATCH] net/igc: fix memory illegal accesses
@ 2020-05-07 2:01 alvinx.zhang
2020-05-07 6:30 ` Jeff Guo
2020-05-07 9:08 ` [dpdk-dev] [PATCH v2] " alvinx.zhang
0 siblings, 2 replies; 9+ messages in thread
From: alvinx.zhang @ 2020-05-07 2:01 UTC (permalink / raw)
To: dev; +Cc: wei.zhao1, jia.guo, xiaolong.ye
From: Alvin Zhang <alvinx.zhang@intel.com>
Add memory access out-of-bounds check.
Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
Cc: stable@dpdk.org
Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---
drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
index 16d98c6..ced8ffd 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* set redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta, reg;
@@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to update the register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* check mask whether need to read the register value first */
@@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
/* update the register */
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
if (mask & (1u << j))
reta.bytes[j] =
@@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* read redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta;
@@ -2330,12 +2336,14 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to read register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* read register and get the queue index */
reta.dword = IGC_READ_REG_LE_VALUE(hw,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
if (mask & (1u << j))
reta_conf[idx].reta[shift + j] = reta.bytes[j];
--
1.8.3.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH] net/igc: fix memory illegal accesses
2020-05-07 2:01 [dpdk-dev] [PATCH] net/igc: fix memory illegal accesses alvinx.zhang
@ 2020-05-07 6:30 ` Jeff Guo
2020-05-07 8:08 ` Zhang, AlvinX
2020-05-07 9:08 ` [dpdk-dev] [PATCH v2] " alvinx.zhang
1 sibling, 1 reply; 9+ messages in thread
From: Jeff Guo @ 2020-05-07 6:30 UTC (permalink / raw)
To: alvinx.zhang, dev; +Cc: wei.zhao1, xiaolong.ye
hi, alvin
On 5/7/2020 10:01 AM, alvinx.zhang@intel.com wrote:
> From: Alvin Zhang <alvinx.zhang@intel.com>
>
> Add memory access out-of-bounds check.
Could you explain why add ...? If not add, what issue?
>
> Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
> Cc: stable@dpdk.org
>
> Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> ---
> drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
> index 16d98c6..ced8ffd 100644
> --- a/drivers/net/igc/igc_ethdev.c
> +++ b/drivers/net/igc/igc_ethdev.c
> @@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
> + RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
> +
> /* set redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta, reg;
> @@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to update the register */
> - if (!mask)
> + if (!mask ||
> + shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
alignment should be match above parentheses.
> continue;
>
> /* check mask whether need to read the register value first */
> @@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
>
> /* update the register */
> + RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
> if (mask & (1u << j))
> reta.bytes[j] =
> @@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
> + RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
> +
> /* read redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta;
> @@ -2330,12 +2336,14 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to read register */
> - if (!mask)
> + if (!mask ||
> + shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
the same as above.
> continue;
>
> /* read register and get the queue index */
> reta.dword = IGC_READ_REG_LE_VALUE(hw,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
> + RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
need null line or no need, please check it at the place and before.
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
> if (mask & (1u << j))
> reta_conf[idx].reta[shift + j] = reta.bytes[j];
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH] net/igc: fix memory illegal accesses
2020-05-07 6:30 ` Jeff Guo
@ 2020-05-07 8:08 ` Zhang, AlvinX
0 siblings, 0 replies; 9+ messages in thread
From: Zhang, AlvinX @ 2020-05-07 8:08 UTC (permalink / raw)
To: Guo, Jia, dev; +Cc: Zhao1, Wei, Ye, Xiaolong
Hi Jia,
First of all, this is a coverity issue, and it's really a false positives. But do some macro checking will improve code robustness.
Thanks,
Alvin
> -----Original Message-----
> From: Guo, Jia
> Sent: Thursday, May 7, 2020 2:30 PM
> To: Zhang, AlvinX <alvinx.zhang@intel.com>; dev@dpdk.org
> Cc: Zhao1, Wei <wei.zhao1@intel.com>; Ye, Xiaolong
> <xiaolong.ye@intel.com>
> Subject: Re: [PATCH] net/igc: fix memory illegal accesses
>
> hi, alvin
>
>
> On 5/7/2020 10:01 AM, alvinx.zhang@intel.com wrote:
> > From: Alvin Zhang <alvinx.zhang@intel.com>
> >
> > Add memory access out-of-bounds check.
>
>
> Could you explain why add ...? If not add, what issue?
>
>
> >
> > Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> > ---
> > drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/igc/igc_ethdev.c
> > b/drivers/net/igc/igc_ethdev.c index 16d98c6..ced8ffd 100644
> > --- a/drivers/net/igc/igc_ethdev.c
> > +++ b/drivers/net/igc/igc_ethdev.c
> > @@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct
> rte_eth_dev *dev,
> > return -EINVAL;
> > }
> >
> > + RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 %
> IGC_RSS_RDT_REG_SIZE);
> > +
> > /* set redirection table */
> > for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE)
> {
> > union igc_rss_reta_reg reta, reg;
> > @@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct
> rte_eth_dev *dev,
> > IGC_RSS_RDT_REG_SIZE_MASK);
> >
> > /* if no need to update the register */
> > - if (!mask)
> > + if (!mask ||
> > + shift > (RTE_RETA_GROUP_SIZE -
> IGC_RSS_RDT_REG_SIZE))
>
>
> alignment should be match above parentheses.
>
>
> > continue;
> >
> > /* check mask whether need to read the register value first
> */ @@
> > -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev
> *dev,
> > IGC_RETA(i /
> IGC_RSS_RDT_REG_SIZE));
> >
> > /* update the register */
> > + RTE_BUILD_BUG_ON(sizeof(reta.bytes) !=
> IGC_RSS_RDT_REG_SIZE);
> > for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
> > if (mask & (1u << j))
> > reta.bytes[j] =
> > @@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct
> rte_eth_dev *dev,
> > return -EINVAL;
> > }
> >
> > + RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 %
> IGC_RSS_RDT_REG_SIZE);
> > +
> > /* read redirection table */
> > for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE)
> {
> > union igc_rss_reta_reg reta;
> > @@ -2330,12 +2336,14 @@ static int eth_igc_vlan_tpid_set(struct
> rte_eth_dev *dev,
> > IGC_RSS_RDT_REG_SIZE_MASK);
> >
> > /* if no need to read register */
> > - if (!mask)
> > + if (!mask ||
> > + shift > (RTE_RETA_GROUP_SIZE -
> IGC_RSS_RDT_REG_SIZE))
>
>
> the same as above.
>
>
> > continue;
> >
> > /* read register and get the queue index */
> > reta.dword = IGC_READ_REG_LE_VALUE(hw,
> > IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
> > + RTE_BUILD_BUG_ON(sizeof(reta.bytes) !=
> IGC_RSS_RDT_REG_SIZE);
>
>
> need null line or no need, please check it at the place and before.
>
>
> > for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
> > if (mask & (1u << j))
> > reta_conf[idx].reta[shift + j] = reta.bytes[j];
^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v2] net/igc: fix memory illegal accesses
2020-05-07 2:01 [dpdk-dev] [PATCH] net/igc: fix memory illegal accesses alvinx.zhang
2020-05-07 6:30 ` Jeff Guo
@ 2020-05-07 9:08 ` alvinx.zhang
2020-05-07 9:31 ` alvinx.zhang
1 sibling, 1 reply; 9+ messages in thread
From: alvinx.zhang @ 2020-05-07 9:08 UTC (permalink / raw)
To: dev; +Cc: wei.zhao1, jia.guo, xiaolong.ye
From: Alvin Zhang <alvinx.zhang@intel.com>
Fix some out-of-bounds memory issues, they may lead to wrong results
or affect application stability.
Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
Cc: stable@dpdk.org
Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
V2: update git log
---
drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
index 16d98c6..6ab3ee9 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* set redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta, reg;
@@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to update the register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* check mask whether need to read the register value first */
@@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
/* update the register */
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
if (mask & (1u << j))
reta.bytes[j] =
@@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* read redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta;
@@ -2330,10 +2336,12 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to read register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* read register and get the queue index */
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
reta.dword = IGC_READ_REG_LE_VALUE(hw,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
--
1.8.3.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v2] net/igc: fix memory illegal accesses
2020-05-07 9:08 ` [dpdk-dev] [PATCH v2] " alvinx.zhang
@ 2020-05-07 9:31 ` alvinx.zhang
2020-05-08 5:09 ` Jeff Guo
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: alvinx.zhang @ 2020-05-07 9:31 UTC (permalink / raw)
To: dev; +Cc: wei.zhao1, jia.guo, xiaolong.ye
From: Alvin Zhang <alvinx.zhang@intel.com>
Fix some out-of-bounds memory issues, they may lead to wrong results
or affect application stability.
Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
Cc: stable@dpdk.org
Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---
V2: update git log
drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
index 16d98c6..6ab3ee9 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* set redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta, reg;
@@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to update the register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* check mask whether need to read the register value first */
@@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
/* update the register */
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
if (mask & (1u << j))
reta.bytes[j] =
@@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* read redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta;
@@ -2330,10 +2336,12 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to read register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* read register and get the queue index */
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
reta.dword = IGC_READ_REG_LE_VALUE(hw,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
--
1.8.3.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/igc: fix memory illegal accesses
2020-05-07 9:31 ` alvinx.zhang
@ 2020-05-08 5:09 ` Jeff Guo
2020-05-08 8:27 ` Ye Xiaolong
2020-05-08 8:54 ` [dpdk-dev] [PATCH v3] " alvinx.zhang
2 siblings, 0 replies; 9+ messages in thread
From: Jeff Guo @ 2020-05-08 5:09 UTC (permalink / raw)
To: alvinx.zhang, dev; +Cc: wei.zhao1, xiaolong.ye
On 5/7/2020 5:31 PM, alvinx.zhang@intel.com wrote:
> From: Alvin Zhang <alvinx.zhang@intel.com>
>
> Fix some out-of-bounds memory issues, they may lead to wrong results
> or affect application stability.
>
> Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
> Cc: stable@dpdk.org
>
> Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> ---
>
> V2: update git log
>
> drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
> index 16d98c6..6ab3ee9 100644
> --- a/drivers/net/igc/igc_ethdev.c
> +++ b/drivers/net/igc/igc_ethdev.c
> @@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
> + RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
> +
> /* set redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta, reg;
> @@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to update the register */
> - if (!mask)
> + if (!mask ||
> + shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
> continue;
>
> /* check mask whether need to read the register value first */
> @@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
>
> /* update the register */
> + RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
> if (mask & (1u << j))
> reta.bytes[j] =
> @@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
> + RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
> +
> /* read redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta;
> @@ -2330,10 +2336,12 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to read register */
> - if (!mask)
> + if (!mask ||
> + shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
> continue;
>
> /* read register and get the queue index */
> + RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
> reta.dword = IGC_READ_REG_LE_VALUE(hw,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
Reviewed-by: Jeff Guo <jia.guo@intel.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/igc: fix memory illegal accesses
2020-05-07 9:31 ` alvinx.zhang
2020-05-08 5:09 ` Jeff Guo
@ 2020-05-08 8:27 ` Ye Xiaolong
2020-05-08 8:54 ` [dpdk-dev] [PATCH v3] " alvinx.zhang
2 siblings, 0 replies; 9+ messages in thread
From: Ye Xiaolong @ 2020-05-08 8:27 UTC (permalink / raw)
To: alvinx.zhang; +Cc: dev, wei.zhao1, jia.guo
On 05/07, alvinx.zhang@intel.com wrote:
>From: Alvin Zhang <alvinx.zhang@intel.com>
>
>Fix some out-of-bounds memory issues, they may lead to wrong results
>or affect application stability.
>
>Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
>Cc: stable@dpdk.org
Please append the coverity number, you can refer to other fixes in the commit
history.
Thanks,
Xiaolong
>
>Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
>---
>
>V2: update git log
>
> drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
>index 16d98c6..6ab3ee9 100644
>--- a/drivers/net/igc/igc_ethdev.c
>+++ b/drivers/net/igc/igc_ethdev.c
>@@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
>+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
>+
> /* set redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta, reg;
>@@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to update the register */
>- if (!mask)
>+ if (!mask ||
>+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
> continue;
>
> /* check mask whether need to read the register value first */
>@@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
>
> /* update the register */
>+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
> if (mask & (1u << j))
> reta.bytes[j] =
>@@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
>+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
>+
> /* read redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta;
>@@ -2330,10 +2336,12 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to read register */
>- if (!mask)
>+ if (!mask ||
>+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
> continue;
>
> /* read register and get the queue index */
>+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
> reta.dword = IGC_READ_REG_LE_VALUE(hw,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
>--
>1.8.3.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v3] net/igc: fix memory illegal accesses
2020-05-07 9:31 ` alvinx.zhang
2020-05-08 5:09 ` Jeff Guo
2020-05-08 8:27 ` Ye Xiaolong
@ 2020-05-08 8:54 ` alvinx.zhang
2020-05-12 5:23 ` Ye Xiaolong
2 siblings, 1 reply; 9+ messages in thread
From: alvinx.zhang @ 2020-05-08 8:54 UTC (permalink / raw)
To: dev; +Cc: wei.zhao1, jia.guo, xiaolong.ye
From: Alvin Zhang <alvinx.zhang@intel.com>
Fix some out-of-bounds memory issues, they may lead to wrong results
or affect application stability.
Coverity issue: 357759, 357713
Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
Cc: stable@dpdk.org
Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---
V2: update git log
V3: update git log
drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
index 16d98c6..6ab3ee9 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* set redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta, reg;
@@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to update the register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* check mask whether need to read the register value first */
@@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
/* update the register */
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
if (mask & (1u << j))
reta.bytes[j] =
@@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
return -EINVAL;
}
+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
+
/* read redirection table */
for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
union igc_rss_reta_reg reta;
@@ -2330,10 +2336,12 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
IGC_RSS_RDT_REG_SIZE_MASK);
/* if no need to read register */
- if (!mask)
+ if (!mask ||
+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
continue;
/* read register and get the queue index */
+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
reta.dword = IGC_READ_REG_LE_VALUE(hw,
IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
--
1.8.3.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v3] net/igc: fix memory illegal accesses
2020-05-08 8:54 ` [dpdk-dev] [PATCH v3] " alvinx.zhang
@ 2020-05-12 5:23 ` Ye Xiaolong
0 siblings, 0 replies; 9+ messages in thread
From: Ye Xiaolong @ 2020-05-12 5:23 UTC (permalink / raw)
To: alvinx.zhang; +Cc: dev, wei.zhao1, jia.guo
On 05/08, alvinx.zhang@intel.com wrote:
>From: Alvin Zhang <alvinx.zhang@intel.com>
>
>Fix some out-of-bounds memory issues, they may lead to wrong results
>or affect application stability.
>
>Coverity issue: 357759, 357713
>Fixes: bd3fcf0d0fa1 (net/igc: support RSS)
>Cc: stable@dpdk.org
>
>Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
>---
>
>V2: update git log
>V3: update git log
>
> drivers/net/igc/igc_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
>index 16d98c6..6ab3ee9 100644
>--- a/drivers/net/igc/igc_ethdev.c
>+++ b/drivers/net/igc/igc_ethdev.c
>@@ -2266,6 +2266,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
>+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
>+
> /* set redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta, reg;
>@@ -2278,7 +2280,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to update the register */
>- if (!mask)
>+ if (!mask ||
>+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
> continue;
>
> /* check mask whether need to read the register value first */
>@@ -2289,6 +2292,7 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
>
> /* update the register */
>+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
> if (mask & (1u << j))
> reta.bytes[j] =
>@@ -2318,6 +2322,8 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
>+ RTE_BUILD_BUG_ON(ETH_RSS_RETA_SIZE_128 % IGC_RSS_RDT_REG_SIZE);
>+
> /* read redirection table */
> for (i = 0; i < ETH_RSS_RETA_SIZE_128; i += IGC_RSS_RDT_REG_SIZE) {
> union igc_rss_reta_reg reta;
>@@ -2330,10 +2336,12 @@ static int eth_igc_vlan_tpid_set(struct rte_eth_dev *dev,
> IGC_RSS_RDT_REG_SIZE_MASK);
>
> /* if no need to read register */
>- if (!mask)
>+ if (!mask ||
>+ shift > (RTE_RETA_GROUP_SIZE - IGC_RSS_RDT_REG_SIZE))
> continue;
>
> /* read register and get the queue index */
>+ RTE_BUILD_BUG_ON(sizeof(reta.bytes) != IGC_RSS_RDT_REG_SIZE);
> reta.dword = IGC_READ_REG_LE_VALUE(hw,
> IGC_RETA(i / IGC_RSS_RDT_REG_SIZE));
> for (j = 0; j < IGC_RSS_RDT_REG_SIZE; j++) {
>--
>1.8.3.1
>
Applied to dpdk-next-net-intel, Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-05-12 5:31 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 2:01 [dpdk-dev] [PATCH] net/igc: fix memory illegal accesses alvinx.zhang
2020-05-07 6:30 ` Jeff Guo
2020-05-07 8:08 ` Zhang, AlvinX
2020-05-07 9:08 ` [dpdk-dev] [PATCH v2] " alvinx.zhang
2020-05-07 9:31 ` alvinx.zhang
2020-05-08 5:09 ` Jeff Guo
2020-05-08 8:27 ` Ye Xiaolong
2020-05-08 8:54 ` [dpdk-dev] [PATCH v3] " alvinx.zhang
2020-05-12 5:23 ` 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).