diff mbox series

[iwl-net,2/2] idpf: fix idpf_vc_core_init error path

Message ID 20241022173527.87972-3-pavan.kumar.linga@intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series fix reset issues | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 6 blamed authors not CCed: anthony.l.nguyen@intel.com alan.brady@intel.com madhu.chittim@intel.com joshua.a.hay@intel.com emil.s.tantilov@intel.com przemyslaw.kitszel@intel.com; 10 maintainers not CCed: anthony.l.nguyen@intel.com alan.brady@intel.com madhu.chittim@intel.com pabeni@redhat.com joshua.a.hay@intel.com emil.s.tantilov@intel.com kuba@kernel.org edumazet@google.com andrew+netdev@lunn.ch przemyslaw.kitszel@intel.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 89 this patch: 89
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-10-22--18-00 (tests: 412)

Commit Message

Pavan Kumar Linga Oct. 22, 2024, 5:35 p.m. UTC
In an event where the platform running the device control plane
is rebooted, reset is detected on the driver. It releases
all the resources and waits for the reset to complete. Once the
reset is done, it tries to build the resources back. At this
time if the device control plane is not yet started, then
the driver timeouts on the virtchnl message and retries to
establish the mailbox again.

In the retry flow, mailbox is deinitialized but the mailbox
workqueue is still alive and polling for the mailbox message.
This results in accessing the released control queue leading to
null-ptr-deref. Fix it by unrolling the work queue cancellation
and mailbox deinitialization in the order which they got
initialized.

Also remove the redundant scheduling of the mailbox task in
idpf_vc_core_init.

Fixes: 4930fbf419a7 ("idpf: add core init and interrupt request")
Fixes: 34c21fa894a1 ("idpf: implement virtchnl transaction manager")
Cc: stable@vger.kernel.org # 6.9+
Reviewed-by: Tarun K Singh <tarun.k.singh@intel.com>
Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c      | 1 +
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 7 -------
 2 files changed, 1 insertion(+), 7 deletions(-)

Comments

Simon Horman Oct. 24, 2024, 2:39 p.m. UTC | #1
On Tue, Oct 22, 2024 at 10:35:27AM -0700, Pavan Kumar Linga wrote:
> In an event where the platform running the device control plane
> is rebooted, reset is detected on the driver. It releases
> all the resources and waits for the reset to complete. Once the
> reset is done, it tries to build the resources back. At this
> time if the device control plane is not yet started, then
> the driver timeouts on the virtchnl message and retries to
> establish the mailbox again.
> 
> In the retry flow, mailbox is deinitialized but the mailbox
> workqueue is still alive and polling for the mailbox message.
> This results in accessing the released control queue leading to
> null-ptr-deref. Fix it by unrolling the work queue cancellation
> and mailbox deinitialization in the order which they got
> initialized.
> 
> Also remove the redundant scheduling of the mailbox task in
> idpf_vc_core_init.

I think it might be better to move this last change into a separate patch
targeted at iwl rather than iwl-net. It isn't a fix, right?

> 
> Fixes: 4930fbf419a7 ("idpf: add core init and interrupt request")
> Fixes: 34c21fa894a1 ("idpf: implement virtchnl transaction manager")
> Cc: stable@vger.kernel.org # 6.9+
> Reviewed-by: Tarun K Singh <tarun.k.singh@intel.com>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>

...
Pavan Kumar Linga Oct. 25, 2024, 5:11 p.m. UTC | #2
On 10/24/2024 7:39 AM, Simon Horman wrote:
> On Tue, Oct 22, 2024 at 10:35:27AM -0700, Pavan Kumar Linga wrote:
>> In an event where the platform running the device control plane
>> is rebooted, reset is detected on the driver. It releases
>> all the resources and waits for the reset to complete. Once the
>> reset is done, it tries to build the resources back. At this
>> time if the device control plane is not yet started, then
>> the driver timeouts on the virtchnl message and retries to
>> establish the mailbox again.
>>
>> In the retry flow, mailbox is deinitialized but the mailbox
>> workqueue is still alive and polling for the mailbox message.
>> This results in accessing the released control queue leading to
>> null-ptr-deref. Fix it by unrolling the work queue cancellation
>> and mailbox deinitialization in the order which they got
>> initialized.
>>
>> Also remove the redundant scheduling of the mailbox task in
>> idpf_vc_core_init.
> 
> I think it might be better to move this last change into a separate patch
> targeted at iwl rather than iwl-net. It isn't a fix, right?
> 

If we do not make that change in this patch, it results in calling 
cancel_delayed_work_sync twice in case of an error in idpf_vc_core_init 
(err_intr_req). Looks like there aren't any side effects of calling 
cancel_delayed_work_sync twice. I will remove the said changes from this 
patch.

Thanks,
Pavan

>>
>> Fixes: 4930fbf419a7 ("idpf: add core init and interrupt request")
>> Fixes: 34c21fa894a1 ("idpf: implement virtchnl transaction manager")
>> Cc: stable@vger.kernel.org # 6.9+
>> Reviewed-by: Tarun K Singh <tarun.k.singh@intel.com>
>> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> 
> ...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index c3848e10e7db..b4fbb99bfad2 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -1786,6 +1786,7 @@  static int idpf_init_hard_reset(struct idpf_adapter *adapter)
 	 */
 	err = idpf_vc_core_init(adapter);
 	if (err) {
+		cancel_delayed_work_sync(&adapter->mbx_task);
 		idpf_deinit_dflt_mbx(adapter);
 		goto unlock_mutex;
 	}
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index 3be883726b87..d77d6c3805e2 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -3017,11 +3017,6 @@  int idpf_vc_core_init(struct idpf_adapter *adapter)
 		goto err_netdev_alloc;
 	}
 
-	/* Start the mailbox task before requesting vectors. This will ensure
-	 * vector information response from mailbox is handled
-	 */
-	queue_delayed_work(adapter->mbx_wq, &adapter->mbx_task, 0);
-
 	queue_delayed_work(adapter->serv_wq, &adapter->serv_task,
 			   msecs_to_jiffies(5 * (adapter->pdev->devfn & 0x07)));
 
@@ -3046,7 +3041,6 @@  int idpf_vc_core_init(struct idpf_adapter *adapter)
 
 err_intr_req:
 	cancel_delayed_work_sync(&adapter->serv_task);
-	cancel_delayed_work_sync(&adapter->mbx_task);
 	idpf_vport_params_buf_rel(adapter);
 err_netdev_alloc:
 	kfree(adapter->vports);
@@ -3070,7 +3064,6 @@  int idpf_vc_core_init(struct idpf_adapter *adapter)
 	adapter->state = __IDPF_VER_CHECK;
 	if (adapter->vcxn_mngr)
 		idpf_vc_xn_shutdown(adapter->vcxn_mngr);
-	idpf_deinit_dflt_mbx(adapter);
 	set_bit(IDPF_HR_DRV_LOAD, adapter->flags);
 	queue_delayed_work(adapter->vc_event_wq, &adapter->vc_event_task,
 			   msecs_to_jiffies(task_delay));