From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (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 54AC82DCF67 for ; Tue, 25 Aug 2026 01:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.245.30 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787621808; cv=none; b=dSWblXV6nX8K0EPXbajWrhoObwbpcpG8CtqPA/FaYl7DOJUCHxnspOfJ9vmuww6G0tHW+ZK5RLLwgyXCGpY8OiFM/Ut/BJo/tnMLRFDkdEdMscGRJFx+6AxM713uPfqGdqTAvwOEKAyqTo/GkkASBlUh8YCYv5KEY0BFV7fRqMM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787621808; c=relaxed/simple; bh=Uayx5aSvmzZM3zqdIM4n7rFN6HQFvKKYYsVSUhx0fPg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pEqmOuYIIzHMxqT8u2dsYnw7eZXw2V4KGQfOzQ+mZXR14YwgSG0IB2jDXwx4DfbiAtMv4hGgIJNwjG7LHhJj0+9+FO84qk+2lvNWsjoRW65siSlNESkmy0B5j5aaoDwjbghtpU+RvVyW+caePsRUSw4UYv0w/YdNWyy6pdzr3g8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de; spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc; arc=none smtp.client-ip=91.216.245.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc Received: by Chamillionaire.breakpoint.cc (Postfix, from userid 1003) id F02E060065; Tue, 25 Aug 2026 03:36:43 +0200 (CEST) From: Florian Westphal To: Cc: Florian Westphal , Eulgyu Kim , Jaeyoung Chung Subject: [PATCH nf] netfilter: nfnetlink_log: cope with concurrent instance destruction Date: Tue, 25 Aug 2026 03:36:03 +0200 Message-ID: <20260825013603.27438-1-fw@strlen.de> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Instances are refcounted. However, only memory release happens on the 1 -> 0 transition; the unlink from hashes can occur with any refcount. Uncooperative userspace can force a situation where a queue is pending for destruction from netlink event while a different socket with same portid processes an UNBIND request. With right timing, this will unhash the instance again: Oops: general protection fault, [..] Call Trace: nfulnl_recv_config+0x31a/0xd50 nfnetlink_rcv_msg+0x7c2/0xeb0 Fixes: 0597f2680d66 ("[NETFILTER]: Add new "nfnetlink_log" userspace packet logging facility") Reported-by: Eulgyu Kim Reported-by: Jaeyoung Chung Signed-off-by: Florian Westphal --- net/netfilter/nfnetlink_log.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index 6c7fa2ed34f5..8fc002ae08bc 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -228,13 +228,18 @@ static void __nfulnl_flush(struct nfulnl_instance *inst); static void __instance_destroy(struct nfulnl_instance *inst) { + spin_lock(&inst->lock); + if (inst->copy_mode == NFULNL_COPY_DISABLED) { + /* attempt to UNBIND a queue already pending + * destruction via netlink close event. Ignore. + */ + spin_unlock(&inst->lock); + return; + } + /* first pull it out of the global list */ hlist_del_rcu(&inst->hlist); - /* then flush all pending packets from skb */ - - spin_lock(&inst->lock); - /* lockless readers wont be able to use us */ inst->copy_mode = NFULNL_COPY_DISABLED; -- 2.54.0