From: Jiri Pirko <jiri@resnulli.us>
To: Ido Schimmel <idosch@nvidia.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, edumazet@google.com, horms@kernel.org,
mlxsw@nvidia.com
Subject: Re: [PATCH net-next] netdevsim: Block until all devices are released
Date: Thu, 26 Oct 2023 12:03:57 +0200 [thread overview]
Message-ID: <ZTo5jWlkYOE4nFBe@nanopsycho> (raw)
In-Reply-To: <20231026083343.890689-1-idosch@nvidia.com>
Thu, Oct 26, 2023 at 10:33:43AM CEST, idosch@nvidia.com wrote:
>Like other buses, devices on the netdevsim bus have a release callback
>that is invoked when the reference count of the device drops to zero.
>However, unlike other buses such as PCI, the release callback is not
>necessarily built into the kernel, as netdevsim can be built as a
>module.
>
>The above is problematic as nothing prevents the module from being
>unloaded before the release callback has been invoked, which can happen
>asynchronously. One such example can be found in commit a380687200e0
>("devlink: take device reference for devlink object") where devlink
>calls put_device() from an RCU callback.
>
>The issue is not theoretical and the reproducer in [1] can reliably
>crash the kernel. The conclusion of this discussion was that the issue
>should be solved in netdevsim, which is what this patch is trying to do.
>
>Add a reference count that is increased when a device is added to the
>bus and decreased when a device is released. Signal a completion when
>the reference count drops to zero and wait for the completion when
>unloading the module so that the module will not be unloaded before all
>the devices were released. The reference count is initialized to one so
>that completion is only signaled when unloading the module.
>
>With this patch, the reproducer in [1] no longer crashes the kernel.
>
>[1] https://lore.kernel.org/netdev/20230619125015.1541143-2-idosch@nvidia.com/
>
>Fixes: a380687200e0 ("devlink: take device reference for devlink object")
>Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Thanks!
next prev parent reply other threads:[~2023-10-26 10:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 8:33 [PATCH net-next] netdevsim: Block until all devices are released Ido Schimmel
2023-10-26 10:03 ` Jiri Pirko [this message]
2023-10-27 22:00 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZTo5jWlkYOE4nFBe@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.