This is a note to let you know that I've just added the patch titled net: sched: add helper function to take reference to Qdisc 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-sched-add-helper-function-to-take-reference-to-qdisc.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:28 +0000 Subject: net: sched: add helper function to take reference to Qdisc 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-4-lee.jones@xxxxxxxxxx> From: Vlad Buslov <vladbu@xxxxxxxxxxxx> [ Upstream commit 9d7e82cec35c027756ec97e274f878251f271181 ] Implement function to take reference to Qdisc that relies on rcu read lock instead of rtnl mutex. Function only takes reference to Qdisc if reference counter isn't zero. Intended to be used by unlocked cls API. 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/net/sch_generic.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -118,6 +118,19 @@ static inline void qdisc_refcount_inc(st refcount_inc(&qdisc->refcnt); } +/* Intended to be used by unlocked users, when concurrent qdisc release is + * possible. + */ + +static inline struct Qdisc *qdisc_refcount_inc_nz(struct Qdisc *qdisc) +{ + if (qdisc->flags & TCQ_F_BUILTIN) + return qdisc; + if (refcount_inc_not_zero(&qdisc->refcnt)) + return qdisc; + return NULL; +} + static inline bool qdisc_is_running(struct Qdisc *qdisc) { if (qdisc->flags & TCQ_F_NOLOCK) 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