]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: xt_hashlimit: unregister proc file before releasing mutex
authorCong Wang <xiyou.wangcong@gmail.com>
Thu, 13 Feb 2020 06:53:52 +0000 (22:53 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Mar 2020 06:18:23 +0000 (07:18 +0100)
commit1e797d59105ca00d31f63b88d6e3e93ccd39013e
treec39633e797ad83b0f8b5814ac8d2d334edd06562
parent19cbd20c651363aa4c321d4571e0ea9cdff1548e
netfilter: xt_hashlimit: unregister proc file before releasing mutex

[ Upstream commit 99b79c3900d4627672c85d9f344b5b0f06bc2a4d ]

Before releasing the global mutex, we only unlink the hashtable
from the hash list, its proc file is still not unregistered at
this point. So syzbot could trigger a race condition where a
parallel htable_create() could register the same file immediately
after the mutex is released.

Move htable_remove_proc_entry() back to mutex protection to
fix this. And, fold htable_destroy() into htable_put() to make
the code slightly easier to understand.

Reported-and-tested-by: syzbot+d195fd3b9a364ddd6731@syzkaller.appspotmail.com
Fixes: c4a3922d2d20 ("netfilter: xt_hashlimit: reduce hashlimit_mutex scope for htable_put()")
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/xt_hashlimit.c