From: Patrick McHardy <kaber@trash.net>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
netfilter-devel@vger.kernel.org
Subject: Re: [PATCH net-next-2.6] xt_hashlimit: fix locking
Date: Wed, 17 Feb 2010 21:08:49 +0100 [thread overview]
Message-ID: <4B7C4CD1.1070105@trash.net> (raw)
In-Reply-To: <1266425027.3075.66.camel@edumazet-laptop>
Eric Dumazet wrote:
> Patrick, David
>
> I believe this patch has a problem, since latest net-next-2.6 triggers :
>
> [ 240.682047] INFO: task iptables:4512 blocked for more than 120
> seconds.
> [ 240.682125] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
> disables this message.
> [ 240.682198] iptables D f7a69c48 0 4512 4436 0x00000000
> [ 240.682201] f7a69c5c 00000086 00000002 f7a69c48 c3603304 00000000
> c0379b0d 0000000e
> [ 240.682540] 00000138 f8c06504 fffbef49 d15abc2a 00000007 c0785000
> c0788304 00000000
> [ 240.682861] f81af0c0 c078d080 d157e120 00000007 f81aee40 c037a608
> 00000202 f9e38478
> [ 240.683191] Call Trace:
> [ 240.683247] [<c0379b0d>] ? get_from_free_list+0x3d/0x50
> [ 240.683303] [<c037a608>] ? ida_pre_get+0x18/0xe0
> [ 240.683359] [<c05503ed>] __mutex_lock_slowpath+0xed/0x230
> [ 240.683426] [<c0550540>] mutex_lock+0x10/0x20
> [ 240.683488] [<c04dee7e>] hashlimit_mt_check+0x29e/0x380
> [ 240.683544] [<c04de02c>] xt_check_match+0x9c/0x1b0
> [ 240.683599] [<c05509a7>] ? __mutex_lock_interruptible_slowpath
> +0x1a7/0x260
> [ 240.683657] [<c05509a7>] ? __mutex_lock_interruptible_slowpath
> +0x1a7/0x260
> [ 240.683716] [<c05502fd>] ? mutex_unlock+0xd/0x10
> [ 240.683770] [<c04ddb1f>] ? xt_find_match+0xdf/0x150
> [ 240.683831] [<c0521994>] translate_table+0x384/0x760
> [ 240.683886] [<c04dde02>] ? xt_alloc_table_info+0x52/0xc0
> [ 240.683942] [<c0522bef>] do_ipt_set_ctl+0x16f/0x440
> [ 240.683998] [<c04da2cb>] nf_sockopt+0x15b/0x1a0
> [ 240.684062] [<c0551ca0>] ? _raw_spin_lock_bh+0x10/0x30
> [ 240.684118] [<c04da369>] nf_setsockopt+0x29/0x30
> [ 240.684177] [<c04eb96e>] ip_setsockopt+0x8e/0xa0
> [ 240.684233] [<c02bd6ec>] ? page_add_new_anon_rmap+0x7c/0x90
> [ 240.684289] [<c0504df4>] raw_setsockopt+0x44/0x80
> [ 240.684345] [<c04aaf87>] sock_common_setsockopt+0x27/0x30
> [ 240.684411] [<c04a9569>] sys_setsockopt+0x59/0xb0
> [ 240.684472] [<c04aa90a>] sys_socketcall+0x12a/0x280
> [ 240.684528] [<c0202c50>] sysenter_do_call+0x12/0x26
>
>
> htable_create() is called with hashlimit_mutex already hold
Ah crap, I messed this up during the merge, sorry.
> Maybe original race could be solved using atomic_inc_not_zero() instead
> of atomic_inc() ?
That would have been a possibility, but just getting rid of
the unnecessary locking seems better to me.
> Or following quick & dirty patch just cures the problem.
Thanks, this looks fine.
> [PATCH net-next-2.6] xt_hashlimit: fix locking
>
> Commit 2eff25c18c3d332d3c4dd98f2ac9b7114e9771b0
> (netfilter: xt_hashlimit: fix race condition and simplify locking)
> added a mutex deadlock :
> htable_create() is called with hashlimit_mutex already locked
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
>
> diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
> index e47fb80..d952806 100644
> --- a/net/netfilter/xt_hashlimit.c
> +++ b/net/netfilter/xt_hashlimit.c
> @@ -262,9 +262,7 @@ static int htable_create_v0(struct net *net, struct xt_hashlimit_info *minfo, u_
> hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);
> add_timer(&hinfo->timer);
>
> - mutex_lock(&hashlimit_mutex);
> hlist_add_head(&hinfo->node, &hashlimit_net->htables);
> - mutex_unlock(&hashlimit_mutex);
>
> return 0;
> }
> @@ -327,9 +325,7 @@ static int htable_create(struct net *net, struct xt_hashlimit_mtinfo1 *minfo,
> hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);
> add_timer(&hinfo->timer);
>
> - mutex_lock(&hashlimit_mutex);
> hlist_add_head(&hinfo->node, &hashlimit_net->htables);
> - mutex_unlock(&hashlimit_mutex);
>
> return 0;
> }
>
>
next prev parent reply other threads:[~2010-02-17 20:08 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-16 14:55 netfilter 00/62: netfilter update Patrick McHardy
2010-02-16 14:55 ` netfilter 01/62: SNMP NAT: correct the size argument to kzalloc Patrick McHardy
2010-02-16 14:55 ` netfilter 02/62: xt_recent: save 8 bytes per htable Patrick McHardy
2010-02-16 14:55 ` netfilter 03/62: xtables: do not grab random bytes at __init Patrick McHardy
2010-02-16 14:55 ` netfilter 04/62: xtables: obtain random bytes earlier, in checkentry Patrick McHardy
2010-02-16 14:55 ` IPVS 05/62: Allow boot time change of hash size Patrick McHardy
2010-02-16 14:55 ` netfilter 06/62: nf_nat_ftp: remove (*mangle[]) array and functions, use %pI4 Patrick McHardy
2010-02-16 14:55 ` ipvs 07/62: use standardized format in sprintf Patrick McHardy
2010-02-16 14:55 ` netfilter 08/62: xt_osf: change %pi4 to %pI4 Patrick McHardy
2010-02-16 14:55 ` netfilter 09/62: nfnetlink: netns support Patrick McHardy
2010-02-16 14:55 ` netfilter 10/62: ctnetlink: " Patrick McHardy
2010-02-16 14:55 ` netfilter 11/62: xt_connlimit: " Patrick McHardy
2010-02-16 14:55 ` netfilter 12/62: netns: Patrick McHardy
2010-02-16 14:55 ` netfilter 13/62: xt_hashlimit: simplify seqfile code Patrick McHardy
2010-02-16 14:55 ` netfilter 14/62: xtables: add struct xt_mtchk_param::net Patrick McHardy
2010-02-16 14:55 ` netfilter 15/62: xtables: add struct xt_mtdtor_param::net Patrick McHardy
2010-02-16 14:55 ` netfilter 16/62: xt_recent: netns support Patrick McHardy
2010-02-16 14:55 ` netfilter 17/62: xt_hashlimit: " Patrick McHardy
2010-02-16 14:55 ` netfilter 18/62: nfnetlink_queue: simplify warning message Patrick McHardy
2010-02-16 14:55 ` netfilter 19/62: nf_conntrack_ipv6: delete the redundant macro definitions Patrick McHardy
2010-02-16 14:55 ` IPv6 20/62: reassembly: replace magic number with " Patrick McHardy
2010-02-16 15:43 ` Joe Perches
2010-02-16 15:47 ` Patrick McHardy
2010-02-17 4:40 ` [PATCH] ipv6.h: reassembly: replace calculated magic number with multiplication Joe Perches
2010-02-17 7:38 ` David Miller
2010-02-16 14:55 ` netfiltr 21/62: ipt_CLUSTERIP: simplify seq_file codeA Patrick McHardy
2010-02-16 14:55 ` netfilter 22/62: xtables: CONFIG_COMPAT redux Patrick McHardy
2010-02-16 14:55 ` netfilter 23/62: xt_TCPMSS: SYN packets are allowed to contain data Patrick McHardy
2010-02-16 14:55 ` netfilter 24/62: xt_hashlimit: fix race condition and simplify locking Patrick McHardy
2010-02-17 16:43 ` [PATCH net-next-2.6] xt_hashlimit: fix locking Eric Dumazet
2010-02-17 20:08 ` Patrick McHardy [this message]
2010-02-17 21:39 ` David Miller
2010-02-16 14:55 ` netfilter 25/62: ctnetlink: only assign helpers for matching protocols Patrick McHardy
2010-02-16 14:55 ` netfilter 26/62: add struct net * to target parameters Patrick McHardy
2010-02-16 14:55 ` netfilter 27/62: nf_conntrack: split up IPCT_STATUS event Patrick McHardy
2010-02-16 14:55 ` netfilter 28/62: ctnetlink: support selective event delivery Patrick McHardy
2010-02-16 14:55 ` netfilter 29/62: nf_conntrack: support conntrack templates Patrick McHardy
2010-02-16 14:56 ` netfilter 30/62: xtables: add CT target Patrick McHardy
2010-02-16 14:56 ` netfilter 31/62: fix build failure with CONNTRACK=y NAT=n Patrick McHardy
2010-02-16 14:56 ` netfilter 32/62: xtables: consistent struct compat_xt_counters definition Patrick McHardy
2010-02-16 14:56 ` netfilter 33/62: xtables: symmetric COMPAT_XT_ALIGN definition Patrick McHardy
2010-02-16 14:56 ` netfilter 34/62: ctnetlink: add missing netlink attribute policies Patrick McHardy
2010-02-16 14:56 ` netfilter 35/62: xtables: compact table hook functions (1/2) Patrick McHardy
2010-02-16 14:56 ` netfilter 36/62: xtables: compact table hook functions (2/2) Patrick McHardy
2010-02-16 14:56 ` netfilter 37/62: xtables: use xt_table for hook instantiation Patrick McHardy
2010-02-16 14:56 ` netfilter 38/62: xtables: generate initial table on-demand Patrick McHardy
2010-02-16 14:56 ` netfilter 39/62: ctnetlink: dump expectation helper name Patrick McHardy
2010-02-16 14:56 ` netfilter 40/62: nf_conntrack: show helper and class in /proc/net/nf_conntrack_expect Patrick McHardy
2010-02-16 14:56 ` netfilter 41/62: nf_conntrack_sip: fix ct_sip_parse_request() REGISTER request parsing Patrick McHardy
2010-02-16 14:56 ` netfilter 42/62: nf_conntrack_sip: pass data offset to NAT functions Patrick McHardy
2010-02-16 14:56 ` netfilter 43/62: nf_conntrack_sip: add TCP support Patrick McHardy
2010-02-16 14:56 ` netfilter 44/62: nf_nat: support mangling a single TCP packet multiple times Patrick McHardy
2010-02-16 14:56 ` netfilter 45/62: nf_nat_sip: add TCP support Patrick McHardy
2010-02-16 14:56 ` netfilter 46/62: nf_conntrack_sip: add T.38 FAX support Patrick McHardy
2010-02-16 14:56 ` netfilter 47/62: xtables: fix mangle tables Patrick McHardy
2010-02-16 14:56 ` netfilter 48/62: nf_conntrack: elegantly simplify nf_ct_exp_net() Patrick McHardy
2010-02-16 14:56 ` netfilter 49/62: don't use INIT_RCU_HEAD() Patrick McHardy
2010-02-16 14:56 ` netfilter 50/62: xt_recent: inform user when hitcount is too large Patrick McHardy
2010-02-16 14:56 ` netfilter 51/62: iptables: remove unused function arguments Patrick McHardy
2010-02-16 14:56 ` netfilter 52/62: reduce NF_HOOK by one argument Patrick McHardy
2010-02-16 14:56 ` netfilter 53/62: get rid of the grossness in netfilter.h Patrick McHardy
2010-02-16 14:56 ` netfilter 54/62: xtables: print details on size mismatch Patrick McHardy
2010-02-16 14:56 ` netfilter 55/62: xtables: constify args in compat copying functions Patrick McHardy
2010-02-16 14:56 ` netfilter 56/62: xtables: add const qualifiers Patrick McHardy
2010-02-16 14:56 ` netfilter 57/62: nf_conntrack: pass template to l4proto ->error() handler Patrick McHardy
2010-02-16 14:56 ` netfilter 58/62: nf_conntrack: add support for "conntrack zones" Patrick McHardy
2010-02-16 14:56 ` netfilter 59/62: ctnetlink: add zone support Patrick McHardy
2010-02-16 14:56 ` netfilter 60/62: ebtables: abort if next_offset is too small Patrick McHardy
2010-02-16 14:56 ` netfilter 61/62: ebtables: avoid explicit XT_ALIGN() in match/targets Patrick McHardy
2010-02-16 14:56 ` netfilter 62/62: CONFIG_COMPAT: allow delta to exceed 32767 Patrick McHardy
2010-02-16 19:21 ` netfilter 00/62: netfilter update David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B7C4CD1.1070105@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.