summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2024-01-29 11:09:43 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-05 20:17:09 +0000
commit1c856889fe5fa106f16385646360704a2b25415a (patch)
tree5f1cb9019f23d3969f28442a916e76ad5defcdea
parent83505390aa28482a0deebb5866596a133101279b (diff)
downloadlinux-stable-1c856889fe5fa106f16385646360704a2b25415a.tar.gz
linux-stable-1c856889fe5fa106f16385646360704a2b25415a.tar.bz2
linux-stable-1c856889fe5fa106f16385646360704a2b25415a.zip
netfilter: nf_log: replace BUG_ON by WARN_ON_ONCE when putting logger
[ Upstream commit 259eb32971e9eb24d1777a28d82730659f50fdcb ] Module reference is bumped for each user, this should not ever happen. But BUG_ON check should use rcu_access_pointer() instead. If this ever happens, do WARN_ON_ONCE() instead of BUG_ON() and consolidate pointer check under the rcu read side lock section. Fixes: fab4085f4e24 ("netfilter: log: nf_log_packet() as real unified interface") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/netfilter/nf_log.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index 8cc52d2bd31b..e16f158388bb 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -193,11 +193,12 @@ void nf_logger_put(int pf, enum nf_log_type type)
return;
}
- BUG_ON(loggers[pf][type] == NULL);
-
rcu_read_lock();
logger = rcu_dereference(loggers[pf][type]);
- module_put(logger->me);
+ if (!logger)
+ WARN_ON_ONCE(1);
+ else
+ module_put(logger->me);
rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(nf_logger_put);