diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-01-11 05:29:08 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-01-12 05:49:32 +0100 |
commit | 93e71edfd90ca7e07a3645167f1e8e4504d4e8ee (patch) | |
tree | 9f9a55a72e39a91dbafe626108d9055ba8f852e7 /net/devlink/devl_internal.h | |
parent | r8169: disable ASPM in case of tx timeout (diff) | |
download | linux-93e71edfd90ca7e07a3645167f1e8e4504d4e8ee.tar.xz linux-93e71edfd90ca7e07a3645167f1e8e4504d4e8ee.zip |
devlink: keep the instance mutex alive until references are gone
The reference needs to keep the instance memory around, but also
the instance lock must remain valid. Users will take the lock,
check registration status and release the lock. mutex_destroy()
etc. belong in the same place as the freeing of the memory.
Unfortunately lockdep_unregister_key() sleeps so we need
to switch the an rcu_work.
Note that the problem is a bit hard to repro, because
devlink_pernet_pre_exit() iterates over registered instances.
AFAIU the instances must get devlink_free()d concurrently with
the namespace getting deleted for the problem to occur.
Reported-by: syzbot+d94d214ea473e218fc89@syzkaller.appspotmail.com
Reported-by: syzbot+9f0dd863b87113935acf@syzkaller.appspotmail.com
Fixes: 9053637e0da7 ("devlink: remove the registration guarantee of references")
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230111042908.988199-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/devlink/devl_internal.h')
-rw-r--r-- | net/devlink/devl_internal.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 5d2bbe295659..e724e4c2a4ff 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -7,6 +7,7 @@ #include <linux/netdevice.h> #include <linux/notifier.h> #include <linux/types.h> +#include <linux/workqueue.h> #include <linux/xarray.h> #include <net/devlink.h> #include <net/net_namespace.h> @@ -51,7 +52,7 @@ struct devlink { struct lock_class_key lock_key; u8 reload_failed:1; refcount_t refcount; - struct rcu_head rcu; + struct rcu_work rwork; struct notifier_block netdevice_nb; char priv[] __aligned(NETDEV_ALIGN); }; |