path: root/kernel/net/netfilter/ipset/ip_set_core.c
diff options
authorFlorian Westphal <>2020-01-09 00:17:13 +0100
committerJozsef Kadlecsik <>2020-01-09 20:16:50 +0100
commitc5a02e144277effbe22c321e1675cbb80a361745 (patch)
tree3a7d03ff999494c69737290df914f93d30a05916 /kernel/net/netfilter/ipset/ip_set_core.c
parent5743b3b545fc3b48c53fe3d763fa7ec738af27bf (diff)
netfilter: ipset: avoid null deref when IPSET_ATTR_LINENO is present
The set uadt functions assume lineno is never NULL, but it is in case of ip_set_utest(). syzkaller managed to generate a netlink message that calls this with LINENO attr present: general protection fault: 0000 [#1] PREEMPT SMP KASAN RIP: 0010:hash_mac4_uadt+0x1bc/0x470 net/netfilter/ipset/ip_set_hash_mac.c:104 Call Trace: ip_set_utest+0x55b/0x890 net/netfilter/ipset/ip_set_core.c:1867 nfnetlink_rcv_msg+0xcf2/0xfb0 net/netfilter/nfnetlink.c:229 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477 nfnetlink_rcv+0x1ba/0x460 net/netfilter/nfnetlink.c:563 pass a dummy lineno storage, its easier than patching all set implementations. This seems to be a day-0 bug. Cc: Jozsef Kadlecsik <> Reported-by: Fixes: a7b4f989a6294 ("netfilter: ipset: IP set core support") Signed-off-by: Florian Westphal <> Acked-by: Jozsef Kadlecsik <> Signed-off-by: Pablo Neira Ayuso <> Signed-off-by: Jozsef Kadlecsik <>
Diffstat (limited to 'kernel/net/netfilter/ipset/ip_set_core.c')
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/net/netfilter/ipset/ip_set_core.c b/kernel/net/netfilter/ipset/ip_set_core.c
index 4d8e8b1..e367f3b 100644
--- a/kernel/net/netfilter/ipset/ip_set_core.c
+++ b/kernel/net/netfilter/ipset/ip_set_core.c
@@ -1871,6 +1871,7 @@ IPSET_CBFN(ip_set_utest, struct net *net, struct sock *ctnl,
struct ip_set *set;
struct nlattr *tb[IPSET_ATTR_ADT_MAX + 1] = {};
int ret = 0;
+ u32 lineno;
if (unlikely(protocol_min_failed(attr) ||
@@ -1887,7 +1888,7 @@ IPSET_CBFN(ip_set_utest, struct net *net, struct sock *ctnl,
- ret = set->variant->uadt(set, tb, IPSET_TEST, NULL, 0, 0);
+ ret = set->variant->uadt(set, tb, IPSET_TEST, &lineno, 0, 0);
/* Userspace can't trigger element to be re-added */
if (ret == -EAGAIN)