]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nfnetlink: fix warn in nfnetlink_unbind
authorFlorian Westphal <fw@strlen.de>
Thu, 19 May 2022 22:02:03 +0000 (00:02 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 27 May 2022 09:16:33 +0000 (11:16 +0200)
commit3345c4ae77f87d7bc9351af98c9a2a25cc48e529
tree24deb559efab08e0288c735ac82d50435b6e69ca
parentf9ecb3fd134743f249d9155c7a9eb61f444cf295
netfilter: nfnetlink: fix warn in nfnetlink_unbind

syzbot reports following warn:
WARNING: CPU: 0 PID: 3600 at net/netfilter/nfnetlink.c:703 nfnetlink_unbind+0x357/0x3b0 net/netfilter/nfnetlink.c:694

The syzbot generated program does this:

socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER) = 3
setsockopt(3, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP, [1], 4) = 0

... which triggers 'WARN_ON_ONCE(nfnlnet->ctnetlink_listeners == 0)' check.

Instead of counting, just enable reporting for every bind request
and check if we still have listeners on unbind.

While at it, also add the needed bounds check on nfnl_group2type[]
access.

Reported-by: <syzbot+4903218f7fba0a2d6226@syzkaller.appspotmail.com>
Reported-by: <syzbot+afd2d80e495f96049571@syzkaller.appspotmail.com>
Fixes: 8ce46ceb3f06 ("netfilter: nfnetlink: allow to detect if ctnetlink listeners exist")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nfnetlink.c