Skip to content

Commit fd462b6

Browse files
committed
netfilter: ipset: Hold module reference while requesting a module
JIRA: https://issues.redhat.com/browse/RHEL-35819 Upstream Status: net.git commit 456f010 commit 456f010 Author: Phil Sutter <[email protected]> Date: Fri Nov 29 16:30:38 2024 +0100 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]> Signed-off-by: Phil Sutter <[email protected]>
1 parent 6c0c626 commit fd462b6

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
@@ -106,14 +106,19 @@ find_set_type(const char *name, u8 family, u8 revision)
106106
static bool
107107
load_settype(const char *name)
108108
{
109+
if (!try_module_get(THIS_MODULE))
110+
return false;
111+
109112
nfnl_unlock(NFNL_SUBSYS_IPSET);
110113
pr_debug("try to load ip_set_%s\n", name);
111114
if (request_module("ip_set_%s", name) < 0) {
112115
pr_warn("Can't find ip_set type %s\n", name);
113116
nfnl_lock(NFNL_SUBSYS_IPSET);
117+
module_put(THIS_MODULE);
114118
return false;
115119
}
116120
nfnl_lock(NFNL_SUBSYS_IPSET);
121+
module_put(THIS_MODULE);
117122
return true;
118123
}
119124

0 commit comments

Comments
 (0)