Skip to content

Commit 22dad71

Browse files
Florian Westphalummakynes
authored andcommitted
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 [raspberrypi#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 <kadlec@blackhole.kfki.hu> Reported-by: syzbot+34bd2369d38707f3f4a7@syzkaller.appspotmail.com Fixes: a7b4f98 ("netfilter: ipset: IP set core support") Signed-off-by: Florian Westphal <fw@strlen.de> Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 1d9a7ac commit 22dad71

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎net/netfilter/ipset/ip_set_core.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,7 @@ static int ip_set_utest(struct net *net, struct sock *ctnl, struct sk_buff *skb,
18481848
struct ip_set *set;
18491849
struct nlattr *tb[IPSET_ATTR_ADT_MAX + 1] = {};
18501850
int ret = 0;
1851+
u32 lineno;
18511852

18521853
if (unlikely(protocol_min_failed(attr) ||
18531854
!attr[IPSET_ATTR_SETNAME] ||
@@ -1864,7 +1865,7 @@ static int ip_set_utest(struct net *net, struct sock *ctnl, struct sk_buff *skb,
18641865
return -IPSET_ERR_PROTOCOL;
18651866

18661867
rcu_read_lock_bh();
1867-
ret = set->variant->uadt(set, tb, IPSET_TEST, NULL, 0, 0);
1868+
ret = set->variant->uadt(set, tb, IPSET_TEST, &lineno, 0, 0);
18681869
rcu_read_unlock_bh();
18691870
/* Userspace can't trigger element to be re-added */
18701871
if (ret == -EAGAIN)

0 commit comments

Comments
 (0)