diff mbox series

[net] eth: gve: add missing netdev locks on reset and shutdown paths

Message ID 20250328164742.1268069-1-kuba@kernel.org (mailing list archive)
State Accepted
Commit 9e3267cf02c240065fddfbe1a58cdb99d0b00531
Delegated to: Netdev Maintainers
Headers show
Series [net] eth: gve: add missing netdev locks on reset and shutdown paths | 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: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-04-01--00-00 (tests: 902)

Commit Message

Jakub Kicinski March 28, 2025, 4:47 p.m. UTC
All the misc entry points end up calling into either gve_open()
or gve_close(), they take rtnl_lock today but since the recent
instance locking changes should also take the instance lock.

Found by code inspection and untested.

Fixes: cae03e5bdd9e ("net: hold netdev instance lock during queue operations")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jeroendb@google.com
CC: hramamurthy@google.com
CC: pkaligineedi@google.com
CC: willemb@google.com
CC: shailend@google.com
CC: joshwash@google.com
CC: sdf@fomichev.me
---
 drivers/net/ethernet/google/gve/gve_main.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stanislav Fomichev March 28, 2025, 4:59 p.m. UTC | #1
On 03/28, Jakub Kicinski wrote:
> All the misc entry points end up calling into either gve_open()
> or gve_close(), they take rtnl_lock today but since the recent
> instance locking changes should also take the instance lock.
> 
> Found by code inspection and untested.
> 
> Fixes: cae03e5bdd9e ("net: hold netdev instance lock during queue operations")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Harshitha Ramamurthy March 28, 2025, 9:55 p.m. UTC | #2
On Fri, Mar 28, 2025 at 9:47 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> All the misc entry points end up calling into either gve_open()
> or gve_close(), they take rtnl_lock today but since the recent
> instance locking changes should also take the instance lock.
>
> Found by code inspection and untested.
>
> Fixes: cae03e5bdd9e ("net: hold netdev instance lock during queue operations")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com>
> ---
> CC: jeroendb@google.com
> CC: hramamurthy@google.com
> CC: pkaligineedi@google.com
> CC: willemb@google.com
> CC: shailend@google.com
> CC: joshwash@google.com
> CC: sdf@fomichev.me
> ---
>  drivers/net/ethernet/google/gve/gve_main.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
> index cb2f9978f45e..f9a73c956861 100644
> --- a/drivers/net/ethernet/google/gve/gve_main.c
> +++ b/drivers/net/ethernet/google/gve/gve_main.c
> @@ -2077,7 +2077,9 @@ static void gve_handle_reset(struct gve_priv *priv)
>
>         if (gve_get_do_reset(priv)) {
>                 rtnl_lock();
> +               netdev_lock(priv->dev);
>                 gve_reset(priv, false);
> +               netdev_unlock(priv->dev);
>                 rtnl_unlock();
>         }
>  }
> @@ -2714,6 +2716,7 @@ static void gve_shutdown(struct pci_dev *pdev)
>         bool was_up = netif_running(priv->dev);
>
>         rtnl_lock();
> +       netdev_lock(netdev);
>         if (was_up && gve_close(priv->dev)) {
>                 /* If the dev was up, attempt to close, if close fails, reset */
>                 gve_reset_and_teardown(priv, was_up);
> @@ -2721,6 +2724,7 @@ static void gve_shutdown(struct pci_dev *pdev)
>                 /* If the dev wasn't up or close worked, finish tearing down */
>                 gve_teardown_priv_resources(priv);
>         }
> +       netdev_unlock(netdev);
>         rtnl_unlock();
>  }
>
> --
> 2.49.0
>
patchwork-bot+netdevbpf@kernel.org April 1, 2025, 12:10 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 28 Mar 2025 09:47:42 -0700 you wrote:
> All the misc entry points end up calling into either gve_open()
> or gve_close(), they take rtnl_lock today but since the recent
> instance locking changes should also take the instance lock.
> 
> Found by code inspection and untested.
> 
> Fixes: cae03e5bdd9e ("net: hold netdev instance lock during queue operations")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> 
> [...]

Here is the summary with links:
  - [net] eth: gve: add missing netdev locks on reset and shutdown paths
    https://git.kernel.org/netdev/net/c/9e3267cf02c2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index cb2f9978f45e..f9a73c956861 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -2077,7 +2077,9 @@  static void gve_handle_reset(struct gve_priv *priv)
 
 	if (gve_get_do_reset(priv)) {
 		rtnl_lock();
+		netdev_lock(priv->dev);
 		gve_reset(priv, false);
+		netdev_unlock(priv->dev);
 		rtnl_unlock();
 	}
 }
@@ -2714,6 +2716,7 @@  static void gve_shutdown(struct pci_dev *pdev)
 	bool was_up = netif_running(priv->dev);
 
 	rtnl_lock();
+	netdev_lock(netdev);
 	if (was_up && gve_close(priv->dev)) {
 		/* If the dev was up, attempt to close, if close fails, reset */
 		gve_reset_and_teardown(priv, was_up);
@@ -2721,6 +2724,7 @@  static void gve_shutdown(struct pci_dev *pdev)
 		/* If the dev wasn't up or close worked, finish tearing down */
 		gve_teardown_priv_resources(priv);
 	}
+	netdev_unlock(netdev);
 	rtnl_unlock();
 }