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 BA3842BEFEF; Wed, 30 Sep 2026 19:10:47 +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=1790795448; cv=none; b=OsC4rfGLcA0jn31o/8rY/hRQKYFFi4RanFWnq/wvG+QZHzoQWyX5ZWl/8iOQ6+mmgTYVuP5bjKE7MtMKKpf1muKFQ9O91x5EfJzzGL7ytqGuAaUj+6f5jWkBPe18wggBe96jCH6RkgTihZwPFbpOCqueu2+Z+l1oJ6IoGhQ/HTU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790795448; c=relaxed/simple; bh=sueoKEafph527eBCr7o8SYBT60YSPXe1BccXT/58XHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aHCMRYpwmocNswBiz+l7wVPthwE+fB/1WS68Y+pjRUW/fMt9X8F7W8wBfGam9laCI6uBhDARPY21ZEIPujIlG1h/BChlHUmAuoh22Rxh5dCJ9yWX3doRVwTzlNjlXnnuZRwNaCAXdDa0dA8Kh53HjOatScsGdM+bC4gDA3hWptU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0etNwsJN; 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="0etNwsJN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 177BD1F000FF; Wed, 30 Sep 2026 19:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790795447; bh=C9Qjh+RDlH7tbBqJtUVZmGqFAmBzQ+ZrHlotZdObg8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0etNwsJNXgXw5YqGvmv7Qd/53Di/Eji5YZCTKV589SH6RHVERZH63WpQLNRWH0PLy 2P7UAZXSTAoQNSWWxTK6qgTSoA7ThDlajn7w9oMmacOzpiDBPa8WzIwAgqH+dpyVzn S/H6rG9xgNOv9H8q9rzF9C1+TEEoeCnnHn37CJeI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eulgyu Kim , Jaeyoung Chung , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.6 0520/1193] netfilter: nfnetlink_log: cope with concurrent instance destruction Date: Wed, 30 Sep 2026 17:20:04 +0200 Message-ID: <20260930152445.734098932@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit 387d744fa7e499d2c3748a4e60e02ebb24e7fb16 ] 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 Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- 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 5df1d197f07d2..1d86b81a11718 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.53.0