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 EF7B94F30C3; Wed, 30 Sep 2026 16:20:38 +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=1790785241; cv=none; b=gOR+fB5a2flzx8CoWrT5Fez6Js7GbZuN9Eyau+NJlFZJT2oU7LQB2Ov0i1I2ieOV5TKUS5XzCQhR9gHSvtrTcsRXdj9Y/+KtN3lI4y9cBEpIYfdMZmTUO4XSeL9adkyxiW99BLr/5bDmRpSG1I9qKDfWXmq8akYQlBqHNHL0OPA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790785241; c=relaxed/simple; bh=KDYcpYYBo7W6m43BjobCyST7pF6FUeSsnpaDlaShkhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pi6jAAo8t0mzYixhWVKoEXs9L6oNhw29iiftviriRRg/jqqF5jweCbJa2Pn2rMK5c1LQm4ZB0l+oNWLgVISQtxV4CGAZz4DxuvfcAKlINwRvV5iYSDZRANB19fBv01WRMYotvccIe6vXkLISgbxLg0nzhj+SNT4ZfELCGgxJXUk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iiAXq479; 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="iiAXq479" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE11C1F000FF; Wed, 30 Sep 2026 16:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790785237; bh=p2bX/0a7WT69hXHZHKr2cusN8kYGDgkIIZIR0PnoURM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iiAXq479hWNxk07QClBZZGOM9gL3BdFDmGpiTGWAY+cop4RM1++ewcIZpwfSeq4Gh N4kzs5rBuJpzoJUwT3x2dSVkqYpj0BQ0LkJJUBDInB8xbxe1GUIg6BrJUhipK4lUXV BI4+WWgcOKtf7UzlVfj5UeJ+0OX2E7Y5AXqppB1g= 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.1 436/982] netfilter: nfnetlink_log: cope with concurrent instance destruction Date: Wed, 30 Sep 2026 17:19:32 +0200 Message-ID: <20260930152426.159718414@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@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.1-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 d3c43897250a5..60c73d3188896 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -218,13 +218,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