Skip to contentSkip to conversation

net/ixgbe: fix calling null function of VF

PATCH Applied Wei Dai 6 participants 8 messages May 10, 2017 Network drivers

lore
Share & tools
lore

Wei Dai

author
#0 lore raw

PATCH 1/1 net/ixgbe: fix calling null function of VF

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
index ec667d8..ed2baec 100644
@@ -3799,7 +3799,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	hw->mac.get_link_status = true;
 
 	if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
-		hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+		ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
 		speed = hw->phy.autoneg_advertised;
 		if (!speed)
 			ixgbe_get_link_capabilities(hw, &speed, &autoneg);
Signature · 1 line
2.7.4
#1 lore raw

Hello,

The patch you proposed fixed a crash I experienced in IXGBE VF. However, there's still another crash possibility
if the code will proceed with speed == 0 condition to ixgbe_get_link_capabilities VF mac.ops.get_link_capabilities is also set to NULL;

Regards,
Gregory

Quoted 26 lines · On Wednesday, 10 May 2017 10:00:02 IDT Wei Dai wrote:

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
index ec667d8..ed2baec 100644
@@ -3799,7 +3799,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	hw->mac.get_link_status = true;
 
 	if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
-		hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+		ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
 		speed = hw->phy.autoneg_advertised;
 		if (!speed)
 			ixgbe_get_link_capabilities(hw, &speed, &autoneg);
#2 lore raw
Quoted 6 lines · Gregory Etelson

Hello,

The patch you proposed fixed a crash I experienced in IXGBE VF. However, there's still another crash possibility
if the code will proceed with speed == 0 condition to ixgbe_get_link_capabilities VF mac.ops.get_link_capabilities is also set to NULL;

There seems a NULL check in that path, so it should be OK, can you please check:

ixgbe_get_link_capabilities()

	return ixgbe_call_func(hw, hw->mac.ops.get_link_capabilities, .)

...

#define ixgbe_call_func(hw, func, params, error) \
	(func != NULL) ? func params : error

So, if hw->mac.ops.get_link_capabilities == NULL, this will return IXGBE_NOT_IMPLEMENTED

Quoted 33 lines

Regards,
Gregory

Quoted 26 lines · On Wednesday, 10 May 2017 10:00:02 IDT Wei Dai wrote:

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
index ec667d8..ed2baec 100644
@@ -3799,7 +3799,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	hw->mac.get_link_status = true;
 
 	if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
-		hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+		ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
 		speed = hw->phy.autoneg_advertised;
 		if (!speed)
 			ixgbe_get_link_capabilities(hw, &speed, &autoneg);
#3 lore raw
In reply to Wei Dai
Quoted 8 lines · Wei Dai

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")

Hi Roger and Laurent,

This is very close the release, can you please support verifying this defect?

An explicit Acked-by and/or Tested-by would help a lot.

Thanks,
ferruh

Quoted 18 lines
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
index ec667d8..ed2baec 100644
@@ -3799,7 +3799,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	hw->mac.get_link_status = true;
 
 	if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
-		hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+		ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
 		speed = hw->phy.autoneg_advertised;
 		if (!speed)
 			ixgbe_get_link_capabilities(hw, &speed, &autoneg);
#4 lore raw
Quoted 11 lines · Ferruh Yigit
Quoted 8 lines · Wei Dai

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")

Hi Roger and Laurent,

Quoted 7 lines

This is very close the release, can you please support verifying this defect?

An explicit Acked-by and/or Tested-by would help a lot.

Thanks,
ferruh

Hi Ferruh,

Happy to test it. I'll get back to you shortly.

Regards,
Roger

Quoted 22 lines
Quoted 12 lines

---
  drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +0 -0
index ec667d8..ed2baec 100644

drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) · line 3805

Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -3799,7 +3799,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
  	hw->mac.get_link_status = true;
 
  	if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
-		hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+		ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
  		speed = hw->phy.autoneg_advertised;
  		if (!speed)
  			ixgbe_get_link_capabilities(hw, &speed, &autoneg);

.

Acked-by
#5 lore raw

Hi Ferruh, Wei, Roger,
PSB
I also redo test plan provided through http://dpdk.org/dev/patchwork/patch/20502/

Thanks & regards,
Laurent

Quoted 4 lines · Roger B. Melton
Quoted 1 line · Ferruh Yigit

On 5/10/2017 8:00 AM, Wei Dai wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")
Quoted 40 lines
Quoted 9 lines

Hi Roger and Laurent,

This is very close the release, can you please support verifying this defect?

An explicit Acked-by and/or Tested-by would help a lot.

Thanks,
ferruh

Hi Ferruh,

Happy to test it. I'll get back to you shortly.

Regards,
Roger

Quoted 22 lines
Quoted 12 lines

---
  drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +0 -0
index ec667d8..ed2baec 100644

drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update(struct rte_eth_dev *dev, · line 3805

Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -3799,7 +3799,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, 
 int wait_to_complete)
      hw->mac.get_link_status = true;
        if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
-        hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+        ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
          speed = hw->phy.autoneg_advertised;
          if (!speed)
              ixgbe_get_link_capabilities(hw, &speed, &autoneg);

.

#6 lore raw

10/05/2017 14:33, Laurent Hardy:

Quoted 17 lines

Hi Ferruh, Wei, Roger,
PSB
I also redo test plan provided through
http://dpdk.org/dev/patchwork/patch/20502/

Thanks & regards,
Laurent

Quoted 8 lines · Roger B. Melton
Quoted 5 lines · Ferruh Yigit
Quoted 4 lines · Wei Dai

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")

Removing [email protected] as the bug was introduced in 17.05-rc3.

Applied, thanks

#7 lore raw
In reply to Wei Dai

[email protected] per Thomas

I know this patch has already been applied but to complete the loop, I have applied the patch to 17.05-rc4 and verified within my application that the NULL function pointer issue for ixgbe_vf has been resolved.

Regards,
Roger

Quoted 8 lines · Wei Dai

hw->mac.ops.get_media-type() of ixgbe VF is NULL and should not be called directly. It had better be replaced by calling ixgbe_get_media_type( ) to avoid crash.

Fixes c12d22f65b13 ("net/ixgbe: ensure link status is updated")

Tested-by Roger B Melton <[email protected]>

Quoted 17 lines
---
  drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
index ec667d8..ed2baec 100644
@@ -3799,7 +3799,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
  	hw->mac.get_link_status = true;
 
  	if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
-		hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+		ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
  		speed = hw->phy.autoneg_advertised;
  		if (!speed)
  			ixgbe_get_link_capabilities(hw, &speed, &autoneg);