Skip to content

Commit

Permalink
netfilter: connlabels: prefer static lock initialiser
Browse files Browse the repository at this point in the history
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: b57dc7c ("net/sched: Introduce action ct")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Aug 13, 2019
1 parent 0a30ba5 commit 1053334
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/netfilter/nf_conntrack_labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 1053334

Please sign in to comment.