]> git.baikalelectronics.ru Git - kernel.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)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 26 Feb 2020 22:25:07 +0000 (23:25 +0100)
commitffbe8e450c61ad2340625c3d2be9caf078e6e68b
tree96bd29993af77183af6ccedc4df190ffc284c391
parentcad87e8da3af9a7d210cc00238f673feb2df1afb
netfilter: xt_hashlimit: unregister proc file before releasing mutex

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: a961f83e490a ("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>
net/netfilter/xt_hashlimit.c