Patch "net: core: netlink: add helper refcount dec and lock function" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: core: netlink: add helper refcount dec and lock function

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-core-netlink-add-helper-refcount-dec-and-lock-function.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From foo@baz Fri Dec 10 12:36:13 PM CET 2021
From: Lee Jones <lee.jones@xxxxxxxxxx>
Date: Fri, 10 Dec 2021 10:47:25 +0000
Subject: net: core: netlink: add helper refcount dec and lock function
To: lee.jones@xxxxxxxxxx
Cc: stable@xxxxxxxxxxxxxxx, Vlad Buslov <vladbu@xxxxxxxxxxxx>, Jiri Pirko <jiri@xxxxxxxxxxxx>, "David S . Miller" <davem@xxxxxxxxxxxxx>, syzbot+5f229e48cccc804062c0@xxxxxxxxxxxxxxxxxxxxxxxxx
Message-ID: <20211210104729.582403-1-lee.jones@xxxxxxxxxx>

From: Vlad Buslov <vladbu@xxxxxxxxxxxx>

[ 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@xxxxxxxxxxxx>
Acked-by: Jiri Pirko <jiri@xxxxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
[Lee: Sent to Stable]
Link: https://syzkaller.appspot.com/bug?id=d7e411c5472dd5da33d8cc921ccadc747743a568
Reported-by: syzbot+5f229e48cccc804062c0@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee.jones@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 include/linux/rtnetlink.h |    2 ++
 net/core/rtnetlink.c      |    6 ++++++
 2 files changed, 8 insertions(+)

--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -6,6 +6,7 @@
 #include <linux/mutex.h>
 #include <linux/netdevice.h>
 #include <linux/wait.h>
+#include <linux/refcount.h>
 #include <uapi/linux/rtnetlink.h>
 
 extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
@@ -34,6 +35,7 @@ extern void rtnl_unlock(void);
 extern int rtnl_trylock(void);
 extern int rtnl_is_locked(void);
 extern int rtnl_lock_killable(void);
+extern bool refcount_dec_and_rtnl_lock(refcount_t *r);
 
 extern wait_queue_head_t netdev_unregistering_wq;
 extern struct rw_semaphore pernet_ops_rwsem;
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -130,6 +130,12 @@ int rtnl_is_locked(void)
 }
 EXPORT_SYMBOL(rtnl_is_locked);
 
+bool refcount_dec_and_rtnl_lock(refcount_t *r)
+{
+	return refcount_dec_and_mutex_lock(r, &rtnl_mutex);
+}
+EXPORT_SYMBOL(refcount_dec_and_rtnl_lock);
+
 #ifdef CONFIG_PROVE_LOCKING
 bool lockdep_rtnl_is_held(void)
 {


Patches currently in stable-queue which might be from lee.jones@xxxxxxxxxx are

queue-4.19/net-core-netlink-add-helper-refcount-dec-and-lock-function.patch
queue-4.19/net-sched-use-qdisc-rcu-api-instead-of-relying-on-rtnl-lock.patch
queue-4.19/net-sched-extend-qdisc-with-rcu.patch
queue-4.19/net-sched-rename-qdisc_destroy-to-qdisc_put.patch
queue-4.19/net-sched-add-helper-function-to-take-reference-to-qdisc.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux