Skip to content

Commit cbdebe4

Browse files
ffourcotJozsef Kadlecsik
authored andcommitted
netfilter: ipset: forbid family for hash:mac sets
Userspace `ipset` command forbids family option for hash:mac type: ipset create test hash:mac family inet4 ipset v6.30: Unknown argument: `family' However, this check is not done in kernel itself. When someone use external netlink applications (pyroute2 python library for example), one can create hash:mac with invalid family and inconsistant results from userspace (`ipset` command cannot read set content anymore). This patch enforce the logic in kernel, and forbids insertion of hash:mac with a family set. Since IP_SET_PROTO_UNDEF is defined only for hash:mac, this patch has no impact on other hash:* sets Signed-off-by: Florent Fourcot <[email protected]> Signed-off-by: Victorien Molle <[email protected]> Signed-off-by: Jozsef Kadlecsik <[email protected]>
1 parent 30a2e10 commit cbdebe4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/netfilter/ipset/ip_set_hash_gen.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,10 @@ IPSET_TOKEN(HTYPE, _create)(struct net *net, struct ip_set *set,
12341234
pr_debug("Create set %s with family %s\n",
12351235
set->name, set->family == NFPROTO_IPV4 ? "inet" : "inet6");
12361236

1237-
#ifndef IP_SET_PROTO_UNDEF
1237+
#ifdef IP_SET_PROTO_UNDEF
1238+
if (set->family != NFPROTO_UNSPEC)
1239+
return -IPSET_ERR_INVALID_FAMILY;
1240+
#else
12381241
if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6))
12391242
return -IPSET_ERR_INVALID_FAMILY;
12401243
#endif

0 commit comments

Comments
 (0)