WSL2-Linux-Kernel/net/netfilter/ipset
Jozsef Kadlecsik a1e1521b46 netfilter: ipset: Rework long task execution when adding/deleting entries
[ Upstream commit 5e29dc36bd ]

When adding/deleting large number of elements in one step in ipset, it can
take a reasonable amount of time and can result in soft lockup errors. The
patch 5f7b51bf09 ("netfilter: ipset: Limit the maximal range of
consecutive elements to add/delete") tried to fix it by limiting the max
elements to process at all. However it was not enough, it is still possible
that we get hung tasks. Lowering the limit is not reasonable, so the
approach in this patch is as follows: rely on the method used at resizing
sets and save the state when we reach a smaller internal batch limit,
unlock/lock and proceed from the saved state. Thus we can avoid long
continuous tasks and at the same time removed the limit to add/delete large
number of elements in one step.

The nfnl mutex is held during the whole operation which prevents one to
issue other ipset commands in parallel.

Fixes: 5f7b51bf09 ("netfilter: ipset: Limit the maximal range of consecutive elements to add/delete")
Reported-by: syzbot+9204e7399656300bf271@syzkaller.appspotmail.com
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-01-12 11:59:15 +01:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ip_set_bitmap_gen.h netfilter: ipset: use bitmap infrastructure completely 2020-01-20 17:41:45 +01:00
ip_set_bitmap_ip.c netfilter: ipset: call ip_set_free() instead of kfree() 2020-06-30 19:09:56 +02:00
ip_set_bitmap_ipmac.c netfilter: ipset: call ip_set_free() instead of kfree() 2020-06-30 19:09:56 +02:00
ip_set_bitmap_port.c netfilter: ipset: call ip_set_free() instead of kfree() 2020-06-30 19:09:56 +02:00
ip_set_core.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_getport.c netfilter: ipset: move ip_set_get_ip_port() to ip_set_bitmap_port.c. 2019-10-07 23:59:02 +02:00
ip_set_hash_gen.h netfilter: ipset: restore allowing 64 clashing elements in hash:net,iface 2022-12-02 17:41:06 +01:00
ip_set_hash_ip.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_ipmac.c netfilter: ipset: Expose the initval hash parameter to userspace 2020-10-31 11:55:38 +01:00
ip_set_hash_ipmark.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_ipport.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_ipportip.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_ipportnet.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_mac.c netfilter: ipset: Expose the initval hash parameter to userspace 2020-10-31 11:55:38 +01:00
ip_set_hash_net.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_netiface.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_netnet.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_netport.c netfilter: ipset: Rework long task execution when adding/deleting entries 2023-01-12 11:59:15 +01:00
ip_set_hash_netportnet.c netfilter: ipset: fix hash:net,port,net hang with /0 subnet 2023-01-12 11:59:15 +01:00
ip_set_list_set.c netfilter: ipset: Fix subcounter update skip 2020-05-25 20:39:14 +02:00
pfxlen.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00