iavf: check for null in iavf_fix_features
Subsystems (2)
Tony Nguyen
maintainerPATCH 1/8 iavf: check for null in iavf_fix_features
From: Nicholas Nunley <[email protected]>
If the driver has lost contact with the PF then it enters a disabled state and frees adapter->vf_res. However, ndo_fix_features can still be called on the interface, so we need to check for this condition first. Since we have no information on the features at this time simply leave them unmodified and return.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -1
@@ -3437,7 +3437,8 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev, {struct iavf_adapter *adapter =netdev_priv (netdev); -if (!(adapter->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_VLAN )) +if (adapter->vf_res && + !(adapter->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_VLAN )) features &= ~(NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_RX |NETIF_F_HW_VLAN_CTAG_FILTER );
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH 2/8 iavf: free q_vectors before queues in iavf_disable_vf
From: Nicholas Nunley <[email protected]>
iavf_free_queues() clears adapter->num_active_queues, which iavf_free_q_vectors() relies on, so swap the order of these two function calls in iavf_disable_vf(). This resolves a panic encountered when the interface is disabled and then later brought up again after PF communication is restored.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
@@ -2067,8 +2067,8 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)iavf_free_misc_irq (adapter);iavf_reset_interrupt_capability (adapter); -iavf_free_queues (adapter);iavf_free_q_vectors (adapter); +iavf_free_queues (adapter);memset (adapter->vf_res,0 ,IAVF_VIRTCHNL_VF_RESOURCE_SIZE );iavf_shutdown_adminq (&adapter->hw); adapter->netdev->flags &= ~IFF_UP ;
Signature · 1 line
2.20.1
Brelinski
PATCH 2/8 iavf: free q_vectors before queues in iavf_disable_vf
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 2/8] iavf: freeq_vectorsbefore queues iniavf_disable_vfFrom: Nicholas Nunley <[email protected]>
iavf_free_queues()clearsadapter->num_active_queues, whichiavf_free_q_vectors()relies on, so swap the order of these two function calls iniavf_disable_vf(). This resolves a panic encountered when the interface is disabled and then later brought up again after PF communication is restored.
Quoted 7 lines
Fixes 65c7006f234c ("i40evf: assign num_active_queues inside
i40evf_alloc_queues")Signed-off-by Nicholas Nunley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 3/8 iavf: don't clear a lock we don't hold
In reply to Tony NguyenFrom: Nicholas Nunley <[email protected]>
In iavf_configure_clsflower() the function will bail out if it is unable to obtain the crit_section lock in a reasonable time. However, it will clear the lock when exiting, so fix this.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +4 -2
@@ -3027,8 +3027,10 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,while (test_and_set_bit (__IAVF_IN_CRITICAL_TASK, &adapter->crit_section)) { -if (--count ==0 ) - goto err; +if (--count ==0 ) { +kfree (filter); +return err; + }udelay (1 ); }
Signature · 1 line
2.20.1
Brelinski
PATCH 3/8 iavf: don't clear a lock we don't hold
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 3/8] iavf: don't clear a lock we don't holdFrom: Nicholas Nunley <[email protected]>
In
iavf_configure_clsflower()the function will bail out if it is unable to obtain thecrit_sectionlock in a reasonable time. However, it will clear the lock when exiting, so fix this.
Quoted 7 lines
Fixes 640a8af5841f ("i40evf: Reorder configure_clsflower to avoid deadlockon error")
Signed-off-by Nicholas Nunley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Tony Nguyen
maintainerPATCH 4/8 iavf: Fix failure to exit out from last all-multicast mode
In reply to Tony NguyenFrom: Piotr Marczak <[email protected]>
The driver could only quit allmulti when allmulti and promisc modes are turn on at the same time. If promisc had been off there was no way to turn off allmulti mode.
The patch corrects this behavior. Switching allmulti does not depends on promisc state mode anymore
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -2
@@ -1613,8 +1613,7 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)iavf_set_promiscuous (adapter,FLAG_VF_MULTICAST_PROMISC );return 0 ; } - -if ((adapter->aq_required &IAVF_FLAG_AQ_RELEASE_PROMISC ) && +if ((adapter->aq_required &IAVF_FLAG_AQ_RELEASE_PROMISC ) || (adapter->aq_required &IAVF_FLAG_AQ_RELEASE_ALLMULTI )) {iavf_set_promiscuous (adapter,0 );return 0 ;
Signature · 1 line
2.20.1
Brelinski
PATCH 4/8 iavf: Fix failure to exit out from last all-multicast mode
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 4/8] iavf: Fix failure to exit out from last all-multicast modeFrom: Piotr Marczak <[email protected]>
The driver could only quit allmulti when allmulti and promisc modes are turn on at the same time. If promisc had been off there was no way to turn off allmulti mode.
The patch corrects this behavior. Switching allmulti does not depends on promisc state mode anymore
Quoted 6 lines
Fixes f42a5c74da99 ("i40e: Add allmulti support for the VF")Signed-off-by Piotr Marczak <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Tony Nguyen
maintainerPATCH 5/8 iavf: prevent accidental free of filter structure
In reply to Tony NguyenFrom: Jacob Keller <[email protected]>
In iavf_config_clsflower, the filter structure could be accidentally released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever return a non-zero but positive value.
In this case, the function continues through to the end, and will call kfree() on the filter structure even though it has been added to the linked list.
This can actually happen because iavf_parse_cls_flower will return a positive IAVF_ERR_CONFIG value instead of the traditional negative error codes.
Fix this by ensuring that the kfree() check and error checks are similar. Use the more idiomatic "if (err)" to catch all non-zero error codes.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
@@ -3040,11 +3040,11 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,/* start out with flow type and eth type IPv4 to begin with */ filter->f.flow_type =VIRTCHNL_TCP_V4_FLOW ; err =iavf_parse_cls_flower (adapter, cls_flower, filter); -if (err <0 ) +if (err) goto err; err =iavf_handle_tclass (adapter, tc, filter); -if (err <0 ) +if (err) goto err;/* add filter to the list */
Signature · 1 line
2.20.1
Brelinski
PATCH 5/8 iavf: prevent accidental free of filter structure
Quoted 24 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 5/8] iavf: prevent accidental free of filter structureFrom: Jacob Keller <[email protected]>
In
iavf_config_clsflower, the filter structure could be accidentally released at the end, ifiavf_parse_cls_floweroriavf_handle_tclassever return a non- zero but positive value.In this case, the function continues through to the end, and will call
kfree()on the filter structure even though it has been added to the linked list.This can actually happen because
iavf_parse_cls_flowerwill return a positiveIAVF_ERR_CONFIGvalue instead of the traditional negative error codes.Fix this by ensuring that the
kfree()check and error checks are similar. Use the more idiomatic "if (err)" to catch all non-zero error codes.
Quoted 6 lines
Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")Signed-off-by Jacob Keller <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Tony Nguyen
maintainerPATCH 6/8 iavf: validate pointers
In reply to Tony NguyenFrom: Mitch Williams <[email protected]>
In some cases, the ethtool get_rxfh handler may be called with a null key or indir parameter. So check these pointers, or you will have a very bad day.
--- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +6 -7
@@ -1853,14 +1853,13 @@ static int iavf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,if (hfunc) *hfunc =ETH_RSS_HASH_TOP ; -if (!indir) -return 0 ; - -memcpy (key, adapter->rss_key, adapter->rss_key_size); +if (key) +memcpy (key, adapter->rss_key, adapter->rss_key_size); -/* Each 32 bits pointed by 'indir' is stored with a lut entry */ -for (i =0 ; i < adapter->rss_lut_size; i++) - indir[i] = (u32 )adapter->rss_lut[i]; +if (indir) +/* Each 32 bits pointed by 'indir' is stored with a lut entry */ +for (i =0 ; i < adapter->rss_lut_size; i++) + indir[i] = (u32 )adapter->rss_lut[i];return 0 ; }
Signature · 1 line
2.20.1
Brelinski
PATCH 6/8 iavf: validate pointers
Quoted 12 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 6/8] iavf: validate pointersFrom: Mitch Williams <[email protected]>
In some cases, the ethtool
get_rxfhhandler may be called with a null key or indir parameter. So check these pointers, or you will have a very bad day.
Quoted 6 lines
Fixes 43a3d9ba34c9 ("i40evf: Allow PF driver to configure RSS")Signed-off-by Mitch Williams <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Tony Nguyen
maintainerPATCH 7/8 iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset
In reply to Tony NguyenFrom: Surabhi Boob <[email protected]>
While issuing VF Reset from the guest OS, the VF driver prints logs about critical / Overflow error detection. This is not an actual error since the VF_MBX_ARQLEN register is set to all FF's for a short period of time and the VF would catch the bits set if it was reading the register during that spike of time. This patch introduces an additional check to ignore this condition since the VF is in reset.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
@@ -2340,7 +2340,7 @@ static void iavf_adminq_task(struct work_struct *work)/* check for error indications */ val =rd32 (hw, hw->aq.arq.len); -if (val ==0xdeadbeef )/* indicates device in reset */ +if (val ==0xdeadbeef || val ==0xffffffff )/* device in reset */ goto freedom; oldval = val;if (val &IAVF_VF_ARQLEN1_ARQVFE_MASK ) {
Signature · 1 line
2.20.1
Brelinski
PATCH 7/8 iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 7/8] iavf: Fix for the false positive ASQ/ARQ errors while issuing VF resetFrom: Surabhi Boob <[email protected]>
While issuing VF Reset from the guest OS, the VF driver prints logs about critical / Overflow error detection. This is not an actual error since the
VF_MBX_ARQLENregister is set to all FF's for a short period of time and the VF would catch the bits set if it was reading the register during that spike of time.
This patch introduces an additional check to ignore this condition since the VF is in reset.
Quoted 6 lines
Fixes 19b73d8efaa4 ("i40evf: Add additional check for reset")Signed-off-by Surabhi Boob <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 8/8 iavf: Fix for setting queues to 0
In reply to Tony NguyenFrom: Grzegorz Szczurek <[email protected]>
Now setting combine to 0 will be rejected with the appropriate error code.
This has been implemented by adding a condition that checks the value of combine equal to zero.
Without this patch, when the user requested it, no error was returned and combine was set to the default value for VF.
--- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1 -1
@@ -1781,7 +1781,7 @@ static int iavf_set_channels(struct net_device *netdev,/* All of these should have already been checked by ethtool before this * even gets to us, but just to be sure. */ -if (num_req > adapter->vsi_res->num_queue_pairs) +if (num_req ==0 || num_req > adapter->vsi_res->num_queue_pairs)return -EINVAL ;if (num_req == adapter->num_active_queues)
Signature · 1 line
2.20.1
Brelinski
PATCH 8/8 iavf: Fix for setting queues to 0
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 8/8] iavf: Fix for setting queues to 0From: Grzegorz Szczurek <[email protected]>
Now setting combine to 0 will be rejected with the appropriate error code. This has been implemented by adding a condition that checks the value of combine equal to zero.
Without this patch, when the user requested it, no error was returned and combine was set to the default value for VF.
Quoted 6 lines
Fixes 5520deb15326 ("iavf: Enable support for up to 16 queues")Signed-off-by Grzegorz Szczurek <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Brelinski
PATCH 1/8 iavf: check for null in iavf_fix_features
In reply to Tony NguyenQuoted 16 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nguyen, Anthony L
Sent: Friday, June 4, 2021 9:49 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net 1/8] iavf: check for null iniavf_fix_featuresFrom: Nicholas Nunley <[email protected]>
If the driver has lost contact with the PF then it enters a disabled state and frees
adapter->vf_res. However,ndo_fix_featurescan still be called on the interface, so we need to check for this condition first. Since we have no information on the features at this time simply leave them unmodified and return.
Quoted 6 lines
Fixes c4445aedfe09 ("i40evf: Fix VLAN features")Signed-off-by Nicholas Nunley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)