Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: ipset: add the missing IP_SET_HASH_WITH_NET0 macro for ip_set_hash_netportnet.c

The missing IP_SET_HASH_WITH_NET0 macro in ip_set_hash_netportnet can
lead to the use of wrong `CIDR_POS(c)` for calculating array offsets,
which can lead to integer underflow. As a result, it leads to slab
out-of-bound access.
This patch adds back the IP_SET_HASH_WITH_NET0 macro to
ip_set_hash_netportnet to address the issue.

Fixes: 886503f34d63 ("netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net")
Suggested-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Kyle Zeng <zengyhkyle@gmail.com>
Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>

authored by

Kyle Zeng and committed by
Florian Westphal
050d91c0 2ee52ae9

+1
+1
net/netfilter/ipset/ip_set_hash_netportnet.c
··· 36 36 #define IP_SET_HASH_WITH_PROTO 37 37 #define IP_SET_HASH_WITH_NETS 38 38 #define IPSET_NET_COUNT 2 39 + #define IP_SET_HASH_WITH_NET0 39 40 40 41 /* IPv4 variant */ 41 42