Skip to content

Commit 273fc96

Browse files
Phil Suttermehmetb0
authored andcommitted
netfilter: ipset: Hold module reference while requesting a module
BugLink: https://bugs.launchpad.net/bugs/2095283 [ Upstream commit 456f010bfaefde84d3390c755eedb1b0a5857c3c ] User space may unload ip_set.ko while it is itself requesting a set type backend module, leading to a kernel crash. The race condition may be provoked by inserting an mdelay() right after the nfnl_unlock() call. Fixes: a7b4f98 ("netfilter: ipset: IP set core support") Signed-off-by: Phil Sutter <phil@nwl.cc> Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org> CVE-2024-56637 Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
1 parent 73a5397 commit 273fc96

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/netfilter/ipset/ip_set_core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,19 @@ find_set_type(const char *name, u8 family, u8 revision)
104104
static bool
105105
load_settype(const char *name)
106106
{
107+
if (!try_module_get(THIS_MODULE))
108+
return false;
109+
107110
nfnl_unlock(NFNL_SUBSYS_IPSET);
108111
pr_debug("try to load ip_set_%s\n", name);
109112
if (request_module("ip_set_%s", name) < 0) {
110113
pr_warn("Can't find ip_set type %s\n", name);
111114
nfnl_lock(NFNL_SUBSYS_IPSET);
115+
module_put(THIS_MODULE);
112116
return false;
113117
}
114118
nfnl_lock(NFNL_SUBSYS_IPSET);
119+
module_put(THIS_MODULE);
115120
return true;
116121
}
117122

0 commit comments

Comments
 (0)