Skip to content

Commit 456f010

Browse files
Phil Sutterummakynes
authored andcommitted
netfilter: ipset: Hold module reference while requesting a module
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 <[email protected]> Acked-by: Jozsef Kadlecsik <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 7b1d83d commit 456f010

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)