Patch "netlink: Call cb->done from a worker thread" has been added to the 4.8-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
netlink: Call cb->done from a worker thread
to the 4.8-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:
netlink-call-cb-done-from-a-worker-thread.patch
and it can be found in the queue-4.8 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Thu Dec 8 07:19:12 CET 2016
From: Herbert Xu <[email protected]>
Date: Mon, 28 Nov 2016 19:22:12 +0800
Subject: netlink: Call cb->done from a worker thread
From: Herbert Xu <[email protected]>
[ Upstream commit 707693c8a498697aa8db240b93eb76ec62e30892 ]
The cb->done interface expects to be called in process context. This was broken by the netlink RCU conversion. This patch fixes it by adding a worker struct to make the cb->done call where necessary.
--- net/netlink/af_netlink.c | 27 +++++++++++++++++++++++---- net/netlink/af_netlink.h | 2 ++ 2 files changed, 25 insertions(+), 4 deletions(-)
net/netlink/af_netlink.c +23 -4
@@ -322,14 +322,11 @@ static void netlink_skb_set_owner_r(strusk_mem_charge (sk, skb->truesize); } -static void netlink_sock_destruct (struct sock *sk) +static void __netlink_sock_destruct (struct sock *sk) {struct netlink_sock *nlk =nlk_sk (sk);if (nlk->cb_running) { -if (nlk->cb.done) - nlk->cb.done (&nlk->cb); -module_put (nlk->cb.module);kfree_skb (nlk->cb.skb); }
@@ -346,6 +343,28 @@ static void netlink_sock_destruct(structWARN_ON (nlk_sk (sk)->groups); } +static void netlink_sock_destruct_work (struct work_struct *work) +{ + struct netlink_sock *nlk = container_of(work, struct netlink_sock, + work); + + nlk->cb.done (&nlk->cb); +__netlink_sock_destruct (&nlk->sk); +} + +static void netlink_sock_destruct (struct sock *sk) +{ +struct netlink_sock *nlk =nlk_sk (sk); + +if (nlk->cb_running && nlk->cb.done) { +INIT_WORK (&nlk->work, netlink_sock_destruct_work); +schedule_work (&nlk->work); +return ; + } + +__netlink_sock_destruct (sk); +} +/* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on * SMP. Look, when several writers sleep and reader wakes them up, all but one * immediately hit write lock and grab all the cpus. Exclusive sleep solves
net/netlink/af_netlink.h +2 -0
@@ -3,6 +3,7 @@#include <linux/rhashtable.h> #include <linux/atomic.h> +#include <linux/workqueue.h> #include <net/sock.h> #define NLGRPSZ (x) (ALIGN(x, sizeof(unsigned long) * 8) / 8)
@@ -33,6 +34,7 @@ struct netlink_sock {struct rhash_head node;struct rcu_head rcu; +struct work_struct work; };static inline struct netlink_sock *nlk_sk (struct sock *sk)
Patches currently in stable-queue which might be from [email protected] are
queue-4.8/udplite-call-proper-backlog-handlers.patch queue-4.8/netlink-do-not-schedule-work-from-sk_destruct.patch queue-4.8/netlink-call-cb-done-from-a-worker-thread.patch