Bug 199107 - Massive use of "ipset" utility: NULL pointer dereference in kernel (ip_set_hash_netiface, hash_netiface4_resize)
Summary: Massive use of "ipset" utility: NULL pointer dereference in kernel (ip_set_ha...
Status: NEW
Alias: None
Product: Networking
Classification: Unclassified
Component: Netfilter/Iptables (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: networking_netfilter-iptables@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-14 05:51 UTC by Dmitry Yu Okunev
Modified: 2022-08-25 18:09 UTC (History)
2 users (show)

See Also:
Kernel Version: 4.14.13
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Logs of dmesg and "strace -f ipset list" (8.30 KB, text/plain)
2018-03-14 05:51 UTC, Dmitry Yu Okunev
Details

Description Dmitry Yu Okunev 2018-03-14 05:51:21 UTC
Created attachment 274713 [details]
Logs of dmesg and "strace -f ipset list"

If I massively work with "ipset" utility then I get a NULL pointer dereference and netfilter hangs after that. The logs are attached.
Comment 1 Dmitry Yu Okunev 2018-03-14 08:42:10 UTC
The command causes the bug (I mean the last command before the bug) in my case is:

/sbin/ipset add ACL.IN.ALL_PERMIT 0.0.0.0/0,kaf_54 timeout 0 -exist
Comment 2 Dmitry Yu Okunev 2018-03-14 08:53:46 UTC
To repeat the bug on my machine it's enough just to copy this into the root terminal:

ipset create ACL.IN.ALL_PERMIT hash:net,iface hashsize 1048576 timeout 0
for i in $(seq 0 100); do
    /sbin/ipset add ACL.IN.ALL_PERMIT 0.0.0.0/0,kaf_$i timeout 0 -exist
done
Comment 3 Dmitry Yu Okunev 2018-03-14 09:17:16 UTC
It seems problems appears when I add the 65th such row into a set.
Comment 4 Dmitry Yu Okunev 2018-03-14 12:50:35 UTC
I've tuned some constants in the code and it helped:

linux-4.14.26/net/netfilter/ipset/ip_set_core.c:
#define IP_SET_INC        2048

linux-4.14.26/net/netfilter/ipset/ip_set_hash_gen.h:
#define AHASH_MAX_TUNED                       2048
Comment 5 Dmitry Yu Okunev 2018-03-14 12:54:25 UTC
However it works quite strange. It claims that there're 101 entry, however doesn't display any member:

# ipset list ACL.IN.ALL_PERMIT
Name: ACL.IN.ALL_PERMIT
Type: hash:net,iface
Revision: 6
Header: family inet hashsize 2097152 maxelem 65536 timeout 0
Size in memory: 10984
References: 0
Number of entries: 101
Members:
#
Comment 6 Daniel Xu 2022-08-25 18:09:08 UTC
Hit same issue as well. Testing / analysis points to https://github.com/torvalds/linux/commit/2b33d6ffa9e38f344418976b06 as the fix.

Note You need to log in before you can comment on or make changes to this bug.