Patch "net: net_enable_timestamp() can be called from irq contexts" has been added to the 4.10-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
net: net_enable_timestamp() can be called from irq contexts
to the 4.10-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-net_enable_timestamp-can-be-called-from-irq-contexts.patch
and it can be found in the queue-4.10 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 Sat Mar 18 22:03:53 CST 2017
From: Eric Dumazet <[email protected]>
Date: Wed, 1 Mar 2017 14:28:39 -0800
Subject: net: net_enable_timestamp() can be called from irq contexts
From: Eric Dumazet <[email protected]>
[ Upstream commit 13baa00ad01bb3a9f893e3a08cbc2d072fc0c15d ]
It is now very clear that silly TCP listeners might play with enabling/disabling timestamping while new children are added to their accept queue.
Meaning net_enable_timestamp() can be called from BH context while current state of the static key is not enabled.
Lets play safe and allow all contexts.
The work queue is scheduled only under the problematic cases, which are the static key enable/disable transition, to not slow down critical paths.
This extends and improves what we did in commit 5fa8bbda38c6 ("net: use a work queue to defer net_disable_timestamp() work")
--- net/core/dev.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-)
net/core/dev.c +31 -4
@@ -1696,27 +1696,54 @@ EXPORT_SYMBOL_GPL(net_dec_egress_queue);static struct static_key netstamp_needed__read_mostly ;#ifdef HAVE_JUMP_LABEL static atomic_t netstamp_needed_deferred; +static atomic_t netstamp_wanted;static void netstamp_clear (struct work_struct *work) {int deferred =atomic_xchg (&netstamp_needed_deferred,0 ); +int wanted; -while (deferred--) -static_key_slow_dec (&netstamp_needed); + wanted =atomic_add_return (deferred, &netstamp_wanted); +if (wanted >0 ) +static_key_enable (&netstamp_needed); +else +static_key_disable (&netstamp_needed); } static DECLARE_WORK(netstamp_work, netstamp_clear);#endif void net_enable_timestamp (void ) { +#ifdef HAVE_JUMP_LABEL +int wanted; + +while (1 ) { + wanted =atomic_read (&netstamp_wanted); +if (wanted <=0 ) +break ; +if (atomic_cmpxchg (&netstamp_wanted, wanted, wanted +1 ) == wanted) +return ; + } +atomic_inc (&netstamp_needed_deferred); +schedule_work (&netstamp_work); +#else static_key_slow_inc (&netstamp_needed); +#endif }EXPORT_SYMBOL (net_enable_timestamp);void net_disable_timestamp (void ) {#ifdef HAVE_JUMP_LABEL -/* net_disable_timestamp() can be called from non process context */ -atomic_inc (&netstamp_needed_deferred); +int wanted; + +while (1 ) { + wanted =atomic_read (&netstamp_wanted); +if (wanted <=1 ) +break ; +if (atomic_cmpxchg (&netstamp_wanted, wanted, wanted -1 ) == wanted) +return ; + } +atomic_dec (&netstamp_needed_deferred);schedule_work (&netstamp_work);#else static_key_slow_dec (&netstamp_needed);
Patches currently in stable-queue which might be from [email protected] are
queue-4.10/tcp-fix-various-issues-for-sockets-morphing-to-listen-state.patch queue-4.10/tcp-dccp-block-bh-for-syn-processing.patch queue-4.10/dccp-fix-use-after-free-in-dccp_feat_activate_values.patch queue-4.10/net-fix-socket-refcounting-in-skb_complete_tx_timestamp.patch queue-4.10/net-net_enable_timestamp-can-be-called-from-irq-contexts.patch queue-4.10/dccp-unlock-sock-before-calling-sk_free.patch queue-4.10/net-don-t-call-strlen-on-the-user-buffer-in-packet_bind_spkt.patch queue-4.10/net-fix-socket-refcounting-in-skb_complete_wifi_ack.patch queue-4.10/ipv6-orphan-skbs-in-reassembly-unit.patch