OSDN Git Service

netfilter: xt_RATEEST: acquire xt_rateest_mutex for hash insert
authorCong Wang <xiyou.wangcong@gmail.com>
Mon, 5 Feb 2018 22:41:45 +0000 (14:41 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Feb 2018 10:03:37 +0000 (11:03 +0100)
commit4b1932a19b9d2e09ee1a45c90fb43e1e72928032
treeec1d07a73cd897449424c5988e2049a6eeddcaec
parent622cdb9c9ec86aedc527f0c669884e223b7a3ef5
netfilter: xt_RATEEST: acquire xt_rateest_mutex for hash insert

commit 7dc68e98757a8eccf8ca7a53a29b896f1eef1f76 upstream.

rateest_hash is supposed to be protected by xt_rateest_mutex,
and, as suggested by Eric, lookup and insert should be atomic,
so we should acquire the xt_rateest_mutex once for both.

So introduce a non-locking helper for internal use and keep the
locking one for external.

Reported-by: <syzbot+5cb189720978275e4c75@syzkaller.appspotmail.com>
Fixes: 5859034d7eb8 ("[NETFILTER]: x_tables: add RATEEST target")
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/xt_RATEEST.c