From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8632B2C21FD; Wed, 30 Sep 2026 18:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790791685; cv=none; b=ae92fk0Uet3IVLefLXwS5OWXGsMHIJsspIkXCXWsUN0QnQuDhLwP4N7I+1ZwwfW6lXMZfDUB+Pe7ChGNAo4t037BL24I1j3+Kvx2Q/HgpQOlOg68mWduts8XnCFwB5INUPDAr+ZHJdcPu7BYXTZ+hfvzKURQj4MWA/foX8zsOEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790791685; c=relaxed/simple; bh=1a8sta7Q5mdAa3AZiF8xdvy/Y0vm+NEKBpmMalxfftc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JeUvLizww0tSy9Yw+DvIZ3/C0ndnpLBNPaiQ5CD3SicYAbNTf6vrZWBWg5yki+Ke/eJJN1jP5UbnaDizSIRXb6zO694jIOtcqrhIrn6b+2wYRObev6lIX/rbvoSV8KhPOJ77TLo7K9aUle/aRrIdVADWR7cY2xLxe2Zr7NKUeGk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vm0VFeiE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vm0VFeiE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5C8D1F000FF; Wed, 30 Sep 2026 18:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790791684; bh=oiF3PZ/ElZTjyUy3bddkCfUSWJ9NaaUHXbTNkpDqSxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vm0VFeiEprT51YYImdNsnIIG7yQuhNnDvuF/VQMPnzVyE7RXN/fQz6Aj1+lJnwVg3 BunL5qF7nSEOLwOOcSCWD3lVvyQ+YIKgqdJ6pXCZf8Of/Ceh6FiY31/yWD9EMrYQZQ aLkDletKEF/HpIsWVQYBJ0S8JmDZnfZzmAR/hO3g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chengfeng Ye , Pablo Neira Ayuso Subject: [PATCH 5.15 389/752] netfilter: nf_log: unregister loggers before per-net teardown Date: Wed, 30 Sep 2026 17:24:19 +0200 Message-ID: <20260930152406.694456593@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152358.131179731@linuxfoundation.org> References: <20260930152358.131179731@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chengfeng Ye commit 2c018cc4842c33f0c732962e2ab58635e8ae5823 upstream. nf_log_syslog and nfnetlink_log unregister their per-network namespace operations before unregistering their global logger backends. This leaves a window where a sysctl or netlink writer can rebind the still- registered logger after the per-net pre-exit callback cleared the old selection. The race looks like this: CPU 0 CPU 1 ---- ---- unregister_pernet_subsys() nf_log_unset(net, logger) net->nf.nf_loggers[pf] = NULL lock nf_log_mutex find logger in loggers[][] net->nf.nf_loggers[pf] = logger unlock nf_log_mutex nf_log_unregister(logger) lock nf_log_mutex loggers[pf][type] = NULL unlock nf_log_mutex synchronize_rcu() module exit returns module core frees backend memory Later, a sysctl read or packet logging operation can dereference the stale per-net logger pointer. Fix this by unregistering the global logger backends before tearing down per-net state. Once the global registrations are gone, later writers can no longer rebind the logger. unregister_pernet_subsys() already waits for an RCU grace period after the pre-exit callback clears the per-net selection, while nf_log_unregister() continues to cover readers of the global logger table. Apply this ordering fix to both nf_log backends that combine per-net teardown with global logger registration. Fixes: 5b023fc8d8e0 ("netfilter: enable per netns support for nf_loggers") Cc: stable@vger.kernel.org Signed-off-by: Chengfeng Ye Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_log_syslog.c | 2 +- net/netfilter/nfnetlink_log.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/net/netfilter/nf_log_syslog.c +++ b/net/netfilter/nf_log_syslog.c @@ -1070,12 +1070,12 @@ err1: static void __exit nf_log_syslog_exit(void) { - unregister_pernet_subsys(&nf_log_syslog_net_ops); nf_log_unregister(&nf_ip_logger); nf_log_unregister(&nf_arp_logger); nf_log_unregister(&nf_ip6_logger); nf_log_unregister(&nf_netdev_logger); nf_log_unregister(&nf_bridge_logger); + unregister_pernet_subsys(&nf_log_syslog_net_ops); } module_init(nf_log_syslog_init); --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -1194,8 +1194,8 @@ static void __exit nfnetlink_log_fini(vo { nfnetlink_subsys_unregister(&nfulnl_subsys); netlink_unregister_notifier(&nfulnl_rtnl_notifier); - unregister_pernet_subsys(&nfnl_log_net_ops); nf_log_unregister(&nfulnl_logger); + unregister_pernet_subsys(&nfnl_log_net_ops); } MODULE_DESCRIPTION("netfilter userspace logging");