Re: net: suspicious RCU usage in nf_hook
From: Cong Wang <hidden>
Date: 2017-02-01 23:30:25
Also in:
lkml, netfilter-devel
On Wed, Feb 1, 2017 at 1:16 PM, Eric Dumazet [off-list ref] wrote:
On Wed, 2017-02-01 at 12:51 -0800, Cong Wang wrote:quoted
On Tue, Jan 31, 2017 at 7:44 AM, Eric Dumazet [off-list ref] wrote:quoted
On Mon, 2017-01-30 at 22:19 -0800, Cong Wang wrote:quoted
The context is process context (TX path before hitting qdisc), and BH is not disabled, so in_interrupt() doesn't catch it. Hmm, this makes me thinking maybe we really need to disable BH in this case for nf_hook()? But it is called in RX path too, and BH is already disabled there.ipt_do_table() and similar netfilter entry points disable BH. Maybe it is done too late.I think we need a fix like the following one for minimum impact.diff --git a/net/core/dev.c b/net/core/dev.c index 727b6fd..eee7d63 100644 --- a/net/core/dev.c +++ b/net/core/dev.c@@ -1720,12 +1720,10 @@ EXPORT_SYMBOL(net_enable_timestamp); void net_disable_timestamp(void) { #ifdef HAVE_JUMP_LABEL - if (in_interrupt()) { - atomic_inc(&netstamp_needed_deferred); - return; - } -#endif + atomic_inc(&netstamp_needed_deferred); +#else static_key_slow_dec(&netstamp_needed); +#endif } EXPORT_SYMBOL(net_disable_timestamp);This would permanently leave the kernel in the netstamp_needed state. I would prefer the patch using a process context to perform the cleanup ? Note there is a race window, but probably not a big deal.
Not sure if it is better. The difference is caught up in net_enable_timestamp(), which is called setsockopt() path and sk_clone() path, so we could be in netstamp_needed state for a long time too until user-space exercises these paths. I am feeling we probably need to get rid of netstamp_needed_deferred, and simply defer the whole static_key_slow_dec(), like the attached patch (compile only). What do you think?
Attachments
- net-timestamp.diff [text/plain] 1483 bytes · preview