Skip to content
Commit 93e71edf authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

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: default avatar <syzbot+d94d214ea473e218fc89@syzkaller.appspotmail.com>
Reported-by: default avatar <syzbot+9f0dd863b87113935acf@syzkaller.appspotmail.com>
Fixes: 9053637e ("devlink: remove the registration guarantee of references")
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230111042908.988199-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 80c0576e
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment