RE: [Intel-wired-lan] [PATCH net v2] iavf: Detach device during reset task

From: Jankowski, Konrad0
Date: Fri Sep 02 2022 - 02:05:48 EST




> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf Of
> Ivan Vecera
> Sent: Tuesday, August 30, 2022 10:16 AM
> To: netdev@xxxxxxxxxxxxxxx
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>; Eric Dumazet
> <edumazet@xxxxxxxxxx>; moderated list:INTEL ETHERNET DRIVERS <intel-
> wired-lan@xxxxxxxxxxxxxxxx>; open list <linux-kernel@xxxxxxxxxxxxxxx>;
> Piotrowski, Patryk <patryk.piotrowski@xxxxxxxxx>; Jeff Kirsher
> <jeffrey.t.kirsher@xxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Vitaly
> Grinberg <vgrinber@xxxxxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>
> Subject: [Intel-wired-lan] [PATCH net v2] iavf: Detach device during reset
> task
>
> iavf_reset_task() takes crit_lock at the beginning and holds it during whole
> call. The function subsequently calls
> iavf_init_interrupt_scheme() that grabs RTNL. Problem occurs when
> userspace initiates during the reset task any ndo callback that runs under
> RTNL like iavf_open() because some of that functions tries to take crit_lock.
> This leads to classic A-B B-A deadlock scenario.
>
> To resolve this situation the device should be detached in
> iavf_reset_task() prior taking crit_lock to avoid subsequent ndos running
> under RTNL and reattach the device at the end.
>
> Fixes: 62fe2a865e6d ("i40evf: add missing rtnl_lock() around
> i40evf_set_interrupt_capability")
> Cc: Jacob Keller <jacob.e.keller@xxxxxxxxx>
> Cc: Patryk Piotrowski <patryk.piotrowski@xxxxxxxxx>
> Cc: SlawomirX Laba <slawomirx.laba@xxxxxxxxx>
> Tested-by: Vitaly Grinberg <vgrinber@xxxxxxxxxx>
> Signed-off-by: Ivan Vecera <ivecera@xxxxxxxxxx>
> ---
> drivers/net/ethernet/intel/iavf/iavf_main.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
> b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index f39440ad5c50..10aa99dfdcdb 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c

Tested-by: Konrad Jankowski <konrad0.jankowski@xxxxxxxxx>