{"id":2219560,"url":"http://patchwork.ozlabs.org/api/patches/2219560/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/ac-w6e33txkgTRJj@strlen.de/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/projects/26/?format=json","name":"Netfilter Development","link_name":"netfilter-devel","list_id":"netfilter-devel.vger.kernel.org","list_email":"netfilter-devel@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<ac-w6e33txkgTRJj@strlen.de>","list_archive_url":null,"date":"2026-04-03T12:22:01","name":"nfnetlink_queue crashes kernel","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4f639ecd03d1ed947db431b44444285916b68b18","submitter":{"id":1025,"url":"http://patchwork.ozlabs.org/api/people/1025/?format=json","name":"Florian Westphal","email":"fw@strlen.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/ac-w6e33txkgTRJj@strlen.de/mbox/","series":[{"id":498622,"url":"http://patchwork.ozlabs.org/api/series/498622/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=498622","date":"2026-04-03T12:22:01","name":"nfnetlink_queue crashes kernel","version":1,"mbox":"http://patchwork.ozlabs.org/series/498622/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219560/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219560/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <netfilter-devel+bounces-11600-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11600-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=91.216.245.30","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=strlen.de","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=strlen.de"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fnHsh5LdGz1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 23:22:16 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 03B78301AB9D\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  3 Apr 2026 12:22:13 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 1C0122F5485;\n\tFri,  3 Apr 2026 12:22:12 +0000 (UTC)","from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc\n [91.216.245.30])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id C508D1DF254\n\tfor <netfilter-devel@vger.kernel.org>; Fri,  3 Apr 2026 12:22:09 +0000 (UTC)","by Chamillionaire.breakpoint.cc (Postfix, from userid 1003)\n\tid F396B60913; Fri, 03 Apr 2026 14:22:01 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775218931; cv=none;\n b=h8T3d2sZA7IIMwrG4yHbrpXffkS4wuWToPIXy2bJt7dGX4ors8xQVsYBuJUmblIdR9PlTMNWflY3WqCC8OzZNC6npUevLygk0DARXbCLoPLG3sJIoKjaE5qv2X15GAI8Kjq4UwPy6NjnF7q0D2nEu6bh+c7mJygdJIH7mzzx2DE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775218931; c=relaxed/simple;\n\tbh=EUBtIWsN+iC/3KXf8rU44ziWp48iFUK+cv9y3wIISmw=;\n\th=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:\n\t Content-Disposition;\n b=sWOYcJWWmZDCXHlJIf1gWjscP17HQPIYC2EL2ZfIU+yIq07Vs+PYwEis1F8WYl1Q0Xh9nuTtBHuLP9HCl7vyolMBm55TohG31Q9T5jnsVqVd3upiJBf2JA1Jji8L7WuQqzeWqrRLaws0mYNyZ6KqwMADhgETMAdhger7vRMrSRU=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=strlen.de;\n spf=pass smtp.mailfrom=strlen.de; arc=none smtp.client-ip=91.216.245.30","Date":"Fri, 3 Apr 2026 14:22:01 +0200","From":"Florian Westphal <fw@strlen.de>","To":"Scott Mitchell <scott.k.mitch1@gmail.com>","Cc":"netfilter-devel@vger.kernel.org","Subject":"nfnetlink_queue crashes kernel","Message-ID":"<ac-w6e33txkgTRJj@strlen.de>","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","Content-Transfer-Encoding":"quoted-printable"},"content":"Hello,\n\nnfnetlink_queue is currently broken in at least two ways.\n1). kernel will crash under pressure because\n    struct nf_queue_entry is freed via kfree, but parallel\n    cpu can still observe this while walking the (global) rhashtable.\n\n2) a4400a5b343d (\"netfilter: nfnetlink_queue: nfqnl_instance GFP_ATOMIC -> GFP_KERNEL_ACCOUNT allocation\") should have updated the spinlock to use the _bh variant, if the queue exists we risk deadlock via softirq recursion.\n\nMinimal fix, that I am not a fan of:\n\n\n\n\nA probably better fix is to make the rhashtable perqueue, which is\nmuch more intrusive at this late stage.\n\nI prefer to revert both changes and not accept a reworked hashtable\nuntil we have an extension to nft_queue.sh selftest.\n\nAnything using queue balancing (pacing packets to n queues) with\nenough streams to have parallel invocation of the rhashtable should\ndemonstrate the crash.\n\nThoughts?","diff":"diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h\n--- a/include/net/netfilter/nf_queue.h\n+++ b/include/net/netfilter/nf_queue.h\n@@ -24,6 +24,7 @@ struct nf_queue_entry {\n \tbool\t\t\tnf_ct_is_unconfirmed;\n \tu16\t\t\tsize; /* sizeof(entry) + saved route keys */\n \tu16\t\t\tqueue_num;\n+\tstruct rcu_head\t\thead;\n \n \t/* extra space to store route keys */\n };\ndiff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c\nindex 7f12e56e6e52..385d1fe704ae 100644\n--- a/net/netfilter/nf_queue.c\n+++ b/net/netfilter/nf_queue.c\n@@ -74,7 +74,7 @@ static void nf_queue_entry_release_refs(struct nf_queue_entry *entry)\n void nf_queue_entry_free(struct nf_queue_entry *entry)\n {\n \tnf_queue_entry_release_refs(entry);\n-\tkfree(entry);\n+\tkfree_rcu(entry, head);\n }\n EXPORT_SYMBOL_GPL(nf_queue_entry_free);\n \ndiff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c\nindex 47f7f62906e2..fc44ea4e5128 100644\n--- a/net/netfilter/nfnetlink_queue.c\n+++ b/net/netfilter/nfnetlink_queue.c\n@@ -190,7 +190,7 @@ instance_create(struct nfnl_queue_net *q, u_int16_t queue_num, u32 portid)\n \tspin_lock_init(&inst->lock);\n \tINIT_LIST_HEAD(&inst->queue_list);\n \n-\tspin_lock(&q->instances_lock);\n+\tspin_lock_bh(&q->instances_lock);\n \tif (instance_lookup(q, queue_num)) {\n \t\terr = -EEXIST;\n \t\tgoto out_unlock;\n@@ -204,7 +204,7 @@ instance_create(struct nfnl_queue_net *q, u_int16_t queue_num, u32 portid)\n \th = instance_hashfn(queue_num);\n \thlist_add_head_rcu(&inst->hlist, &q->instance_table[h]);\n \n-\tspin_unlock(&q->instances_lock);\n+\tspin_unlock_bh(&q->instances_lock);\n \n \treturn inst;\n \n","prefixes":[]}