Netfilter/IPVS fixes for net
Subsystems (4)
Pablo Neira Ayuso
maintainercover Netfilter/IPVS fixes for net
Hi,
The following series contains two fixes for Netfilter/IPVS:
1) Possible build failure in IPVS on systems with less than 512MB memory due to incorrect use of clamp(), from David Laight.
2) Fix bogus lockdep nesting splat with ipset list:set type, from Phil Sutter.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-24-12-19
Thanks.
----------------------------------------------------------------
The following changes since commit 954a2b40719a21e763a1bba2f0da92347e058fce:
rtnetlink: Try the outer netns attribute in rtnl_get_peer_net(). (2024-12-17 17:54:18 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-24-12-19
for you to fetch changes up to 70b6f46a4ed8bd56c85ffff22df91e20e8c85e33:
netfilter: ipset: Fix for recursive locking warning (2024-12-19 00:28:47 +0100)
----------------------------------------------------------------
netfilter pull request 24-12-19
----------------------------------------------------------------
David Laight (1):
ipvs: Fix clamp() of ip_vs_conn_tab on small memory systems
Phil Sutter (1):
netfilter: ipset: Fix for recursive locking warning
net/netfilter/ipset/ip_set_list_set.c | 3 +++ net/netfilter/ipvs/ip_vs_conn.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/2 ipvs: Fix clamp() of ip_vs_conn_tab on small memory systems
From: David Laight <[email protected]>
The 'max_avail' value is calculated from the system memory size using order_base_2().order_base_2(x) is defined as '(x) ? fn(x) : 0'.
The compiler generates two copies of the code that follows and then expands clamp(max, min, PAGE_SHIFT - 12) (11 on 32bit). This triggers a compile-time assert since min is 5.
In reality a system would have to have less than 512MB memory for the bounds passed to clamp to be reversed.
Swap the order of the arguments to clamp() to avoid the warning.
Replace the clamp_val() on the line below with clamp(). clamp_val() is just 'an accident waiting to happen' and not needed here.
Detected by compile time checks added to clamp(), specifically:minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()
--- net/netfilter/ipvs/ip_vs_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/ipvs/ip_vs_conn.c +2 -2
@@ -1495,8 +1495,8 @@ int __init ip_vs_conn_init(void) max_avail -=2 ;/* ~4 in hash row */ max_avail -=1 ;/* IPVS up to 1/2 of mem */ max_avail -=order_base_2 (sizeof (struct ip_vs_conn )); - max =clamp (max, min, max_avail); - ip_vs_conn_tab_bits =clamp_val (ip_vs_conn_tab_bits, min, max); + max =clamp (max_avail, min, max); + ip_vs_conn_tab_bits =clamp (ip_vs_conn_tab_bits, min, max); ip_vs_conn_tab_size =1 << ip_vs_conn_tab_bits; ip_vs_conn_tab_mask = ip_vs_conn_tab_size -1 ;
Signature · 1 line
2.30.2
Re: [PATCH net 1/2] ipvs: Fix clamp() of ip_vs_conn_tab on small memory systems
This series was applied to netdev/net.git (main) by Pablo Neira Ayuso <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Pablo Neira Ayuso <[email protected]>:
Quoted 10 lines · On Thu, 19 Dec 2024 00:41:36 +0100 you wrote:
From: David Laight <[email protected]>
The '
max_avail' value is calculated from the system memory size usingorder_base_2().order_base_2(x)is defined as '(x) ? fn(x) : 0'.
The compiler generates two copies of the code that follows and then expandsclamp(max, min, PAGE_SHIFT - 12)(11 on 32bit). This triggers a compile-time assert since min is 5.[...]
Here is the summary with links:
- [net,1/2] ipvs: Fix clamp() of ip_vs_conn_tab on small memory systems
https://git.kernel.org/netdev/net/c/cf2c97423a4f - [net,2/2] netfilter: ipset: Fix for recursive locking warning https://git.kernel.org/netdev/net/c/70b6f46a4ed8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: ipset: Fix for recursive locking warning
In reply to Pablo Neira AyusoFrom: Phil Sutter <[email protected]>
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.
--- net/netfilter/ipset/ip_set_list_set.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/ipset/ip_set_list_set.c +3 -0
@@ -611,6 +611,8 @@ init_list_set(struct net *net, struct ip_set *set, u32 size)return true; } +static struct lock_class_key list_set_lockdep_key; +static int list_set_create (struct net *net,struct ip_set *set,struct nlattr *tb[],u32 flags)
@@ -627,6 +629,7 @@ list_set_create(struct net *net, struct ip_set *set, struct nlattr *tb[],if (size <IP_SET_LIST_MIN_SIZE ) size =IP_SET_LIST_MIN_SIZE ; +lockdep_set_class (&set->lock, &list_set_lockdep_key); set->variant = &set_variant; set->dsize =ip_set_elem_len (set, tb,sizeof (struct set_elem ), __alignof__(struct set_elem ));
Signature · 1 line
2.30.2