]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: core: netlink: add helper refcount dec and lock function
authorVlad Buslov <vladbu@mellanox.com>
Fri, 10 Dec 2021 10:47:25 +0000 (10:47 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 09:18:04 +0000 (10:18 +0100)
commitcd25f1099284a0cbe916344fc1e6c1ffed6c5306
tree5e63e083d34241114038a43b1f90f8334c9aa41d
parentccf070183e4655824936c0f96c4a2bcca93419aa
net: core: netlink: add helper refcount dec and lock function

[ Upstream commit 6f99528e9797794b91b43321fbbc93fe772b0803 ]

Rtnl lock is encapsulated in netlink and cannot be accessed by other
modules directly. This means that reference counted objects that rely on
rtnl lock cannot use it with refcounter helper function that atomically
releases decrements reference and obtains mutex.

This patch implements simple wrapper function around refcount_dec_and_lock
that obtains rtnl lock if reference counter value reached 0.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[Lee: Sent to Stable]
Link: https://syzkaller.appspot.com/bug?id=d7e411c5472dd5da33d8cc921ccadc747743a568
Reported-by: syzbot+5f229e48cccc804062c0@syzkaller.appspotmail.com
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/rtnetlink.h
net/core/rtnetlink.c