Skip to content

Commit 70b6f46

Browse files
Phil Sutterummakynes
authored andcommitted
netfilter: ipset: Fix for recursive locking warning
With CONFIG_PROVE_LOCKING, when creating a set of type bitmap:ip, adding it to a set of type list:set and populating it from iptables SET target triggers a kernel warning: | WARNING: possible recursive locking detected | 6.12.0-rc7-01692-g5e9a28f41134-dirty #594 Not tainted | -------------------------------------------- | ping/4018 is trying to acquire lock: | ffff8881094a6848 (&set->lock){+.-.}-{2:2}, at: ip_set_add+0x28c/0x360 [ip_set] | | but task is already holding lock: | ffff88811034c048 (&set->lock){+.-.}-{2:2}, at: ip_set_add+0x28c/0x360 [ip_set] This is a false alarm: ipset does not allow nested list:set type, so the loop in list_set_kadd() can never encounter the outer set itself. No other set type supports embedded sets, so this is the only case to consider. To avoid the false report, create a distinct lock class for list:set type ipset locks. Fixes: f830837 ("netfilter: ipset: list:set set type support") Signed-off-by: Phil Sutter <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent cf2c974 commit 70b6f46

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/netfilter/ipset/ip_set_list_set.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,8 @@ init_list_set(struct net *net, struct ip_set *set, u32 size)
611611
return true;
612612
}
613613

614+
static struct lock_class_key list_set_lockdep_key;
615+
614616
static int
615617
list_set_create(struct net *net, struct ip_set *set, struct nlattr *tb[],
616618
u32 flags)
@@ -627,6 +629,7 @@ list_set_create(struct net *net, struct ip_set *set, struct nlattr *tb[],
627629
if (size < IP_SET_LIST_MIN_SIZE)
628630
size = IP_SET_LIST_MIN_SIZE;
629631

632+
lockdep_set_class(&set->lock, &list_set_lockdep_key);
630633
set->variant = &set_variant;
631634
set->dsize = ip_set_elem_len(set, tb, sizeof(struct set_elem),
632635
__alignof__(struct set_elem));

0 commit comments

Comments
 (0)