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 231B82ED154; Thu, 17 Sep 2026 18:43:06 +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=1789670587; cv=none; b=g8bxchmy3zFnrmUvhykzmMq7ZRs2mgpxBJO0wWAbIDjVe2oYI9qhXAoLtX6jBqqZPozxsmo8VEC+NY0PCzdXw2+p82+QkbzyLyCj+USoJmsVSOctuCCzC2qkl0rlrIUGJdk7VQkvngrvrkW6DQwK4KD67gdkw1VIvlzaOyZ8SJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789670587; c=relaxed/simple; bh=sdiPyNaxcYyX6qvNmVYEy8nLG8d+NCwZ2YZbgDn+Cns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gTA568cx1bgCqi9jkvgoc+CRGYYMd89OYE6vCrX4OS9/OicDT2010Tx6tm65nM3kvVRgG325rjWVkWrOg5B7EXN/8MYRLqIBXV9WUGVdnwLQlZqpady3wMJZslta65ZvDUTpaS/SR6v0kS8+iUil4oHnRT1Mua8rBXKIMjkmVOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TncdZ20X; 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="TncdZ20X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62CBA1F000FF; Thu, 17 Sep 2026 18:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789670586; bh=8c4fJU5YSfm3T4zUfVk47/F09+AnSzMajBjmLnNF6wo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TncdZ20XzqayCCIDu2TaNjHnNGFC5Q1DRjLuDW9jw8Cl64uLprPOCvUkitTSgHeN6 yn5Ky3NW6vf0BG2QLYshSNCkjyUFKyF6L81PxrdUF2fmIzVfWf1xVypj99vcus82Id 26Xyk5+O/4/75TmatDbUgk/2aNZpGYdmvkrXMPpo= 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.12 0708/1102] netfilter: nfnetlink_log: cope with concurrent instance destruction Date: Thu, 17 Sep 2026 16:10:51 +0100 Message-ID: <20260917151558.096488390@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@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.12-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 14f723f3e0729..080cc30c7aba9 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