* [PATCH nf-next] netfilter: connlabels: prefer static lock initialiser
@ 2019-08-12 11:40 Florian Westphal
2019-08-13 10:04 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2019-08-12 11:40 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
seen during boot:
BUG: spinlock bad magic on CPU#2, swapper/0/1
lock: nf_connlabels_lock+0x0/0x60, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
Call Trace:
do_raw_spin_lock+0x14e/0x1b0
nf_connlabels_get+0x15/0x40
ct_init_net+0xc4/0x270
ops_init+0x56/0x1c0
register_pernet_operations+0x1c8/0x350
register_pernet_subsys+0x1f/0x40
tcf_register_action+0x7c/0x1a0
do_one_initcall+0x13d/0x2d9
Problem is that ct action init function can run before
connlabels_init(). Lock has not been initialised yet.
Fix it by using a static initialiser.
Fixes: b57dc7c13ea90e09ae15f821d2583fa0231b4935 ("net/sched: Introduce action ct")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nf_conntrack_labels.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/netfilter/nf_conntrack_labels.c b/net/netfilter/nf_conntrack_labels.c
index 74b8113f7aeb..d1c6b2a2e7bd 100644
--- a/net/netfilter/nf_conntrack_labels.c
+++ b/net/netfilter/nf_conntrack_labels.c
@@ -11,7 +11,7 @@
#include <net/netfilter/nf_conntrack_ecache.h>
#include <net/netfilter/nf_conntrack_labels.h>
-static spinlock_t nf_connlabels_lock;
+static __read_mostly DEFINE_SPINLOCK(nf_connlabels_lock);
static int replace_u32(u32 *address, u32 mask, u32 new)
{
@@ -89,7 +89,6 @@ int nf_conntrack_labels_init(void)
{
BUILD_BUG_ON(NF_CT_LABELS_MAX_SIZE / sizeof(long) >= U8_MAX);
- spin_lock_init(&nf_connlabels_lock);
return nf_ct_extend_register(&labels_extend);
}
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf-next] netfilter: connlabels: prefer static lock initialiser
2019-08-12 11:40 [PATCH nf-next] netfilter: connlabels: prefer static lock initialiser Florian Westphal
@ 2019-08-13 10:04 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-08-13 10:04 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Mon, Aug 12, 2019 at 01:40:04PM +0200, Florian Westphal wrote:
> seen during boot:
> BUG: spinlock bad magic on CPU#2, swapper/0/1
> lock: nf_connlabels_lock+0x0/0x60, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
> Call Trace:
> do_raw_spin_lock+0x14e/0x1b0
> nf_connlabels_get+0x15/0x40
> ct_init_net+0xc4/0x270
> ops_init+0x56/0x1c0
> register_pernet_operations+0x1c8/0x350
> register_pernet_subsys+0x1f/0x40
> tcf_register_action+0x7c/0x1a0
> do_one_initcall+0x13d/0x2d9
>
> Problem is that ct action init function can run before
> connlabels_init(). Lock has not been initialised yet.
>
> Fix it by using a static initialiser.
Applied, thanks Florian.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-13 10:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 11:40 [PATCH nf-next] netfilter: connlabels: prefer static lock initialiser Florian Westphal
2019-08-13 10:04 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).