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 6C2164F393A; Thu, 17 Sep 2026 15:43:13 +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=1789659802; cv=none; b=PfCexQxDB6I3Z8PJt4qumoozuyGj/7rcRLeUW7iSRu85B2Ga07TvBF7KNRw1oaELCkjlzSW+gcaFoDYDZip3/XfaYdnVtbCJiBgN+m1VIBa2Hd1+QX7rh9gqvT95XORY62YqF69PjiFWX+OeAEFw7xMXZqKoFBLmhGHA5st0vUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789659802; c=relaxed/simple; bh=ZMDHSDEt4pvQYfrjn8x2YYTNvfjDLyQ3Qp/uDQpRAQ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jk1eC+CT9OujGv/i4H2s9u440RkKeYj40xcdcg8xEtjlL+XAvrgNAKrCtlLYXW1sWUsVDDuXgA0z9CPkItGNhSA3Gr2xtzBuAyF8n9KZTfvFRb18JQI8kcOmaY/8Ynmon0TiLAIIsXXHrZ9fNDyBDwIWq6atRozopEjM1Qs4YZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X/vh3b8+; 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="X/vh3b8+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EDA91F00898; Thu, 17 Sep 2026 15:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789659788; bh=+8MEd583WSK1DnHEYrRoF+6B3mYxIhyUek/kRO35QsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X/vh3b8+irl8a+XC3xh6LG8oIWBFF3jduSAOWZOWb3/q7K5cC3NfeyqcaVGmh0UNW 79TipkjiNLnkDb0IHXa89sZPNPSVHSJpxG69N55wb6RZbvm2nHnLhuHgBumV2+/9ut yzMII02lsLehHgcE96xlyHRXKGM/SA/BENeiQyPU= 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 7.2 336/733] netfilter: nfnetlink_log: cope with concurrent instance destruction Date: Thu, 17 Sep 2026 16:10:44 +0100 Message-ID: <20260917151359.909259425@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151350.597953846@linuxfoundation.org> References: <20260917151350.597953846@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 7.2-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 6c7fa2ed34f5c..8fc002ae08bcd 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