🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19820

Re: [PATCH nf] netfilter: nfnetlink_queue: drain cleanup work on netns exit

#19820
From: Florian Westphal
Date: Fri, 20 Nov 2026 13:32
45 lines
8810 bytes
Junyoung Jang <graypanda.inzag@gmail.com> wrote:
> NETLINK_URELEASE unlinks an NFQUEUE instance and schedules its
> destruction through queue_rcu_work(). The RCU callback queues
> instance_destroy_work() on nfq_cleanup_wq. Queued entries retain
> entry->state.net, but nf_queue_entry_get_refs() pins only their
> sockets and network devices.
>
> A migratable device can return to init_net as the old namespace exits.
> cleanup_net() waits for the RCU callback but not the work it queued.
> It can free the namespace before instance_destroy_work() calls
> nfqnl_reinject(entry, NF_DROP), which dereferences the old state.net
> in nf_hook_entries_head().

A bit too verbose changelog for my taste but unfortunately with AI
it's becoming the new standard.

> A source review assisted by a coding agent identified this race. A
> 65,536-queue reproducer on unmodified mainline with
> KASAN and lockdep enabled reported:

The above is rendundant.

>   BUG: KASAN: slab-use-after-free in nfqnl_reinject
>   Workqueue: nfq_workqueue instance_destroy_work
>
> The free stack included cleanup_net(). The trigger used
> initial-namespace CAP_NET_ADMIN and a migratable virtio-net device;
> it required no kernel modification or fault injection.

This is useful, could also have added the trimmed backtrace
instead of the above.

> Drain NFQUEUE cleanup in the pernet exit batch. rcu_barrier() waits
> for pending RCU callbacks to enqueue their work; flush_workqueue()
> then completes that work before cleanup_net() frees the namespace.
> The batch hook avoids a barrier for each exiting namespace.
> 
> The same mainline revision with this patch built without warnings and
> completed two 90-second reproducer runs in KVM with no KASAN or
> lockdep reports. No netfilter selftests were run.

This is redundant: its obvious from looking at the diff.

Reviewed-by: Florian Westphal <fw@strlen.de>
Technical Details
Message-ID: <awBLxqCPTWlGBWFx@strlen.de>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367951-linux-kernel-netdev=dewy.ru
References: <20261120105718.866862-1-graypanda.inzag@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367951-linux-kernel-netdev=dewy.ru
From: fw@strlen.de (Florian Westphal)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH nf] netfilter: nfnetlink_queue: drain cleanup work on
 netns exit
Date: Fri, 20 Nov 2026 14:32:31 +0100
Organization: Usenet Network
Message-ID: <awBLxqCPTWlGBWFx@strlen.de>
References: <20261120105718.866862-1-graypanda.inzag@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="3169170"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xalSaQjtQXqmNwjosntDzzo24P8= sha256:iVquCahh3aNGVY/La8MensU9I7H1TgqmaNWECTidmhc=
	sha1:vuAtRyubmRAVK1bxlODreEvvKmA= sha256:dDEPsG6LBxDj/ORW/nESjr8ddhxvdh6yg5v33v+iT9w=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1BA701159AC; Fri, 20 Nov 2026 16:33:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id FhEETXUDlJAI;
	Fri, 20 Nov 2026 16:32:58 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-367951-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=strlen.de
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 626A3115998; Fri, 20 Nov 2026 16:32:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 3E812681365; Fri, 20 Nov 2026 13:32:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795181566;
	b=nGOEaM3st3XdDq6ch9VH3yW2+6N0iGrIoJvmAPinfw6szSwN0raLshgooHG0t5FvC0G/
	 yhHMs3+MvvBDW8KSLi9IA9rqZ/bc/bpzmcy0CbxacQBRa3JeBxLJ7g6KCFjNjPwaLxWyI
	 66Hdf1A8+RSrhL6G8XK6TR8of+3st1I7dJmmByKvl1F/tEdXyOcpSZo/XbyaFU15fPsDW
	 22grInMjC/0IVykwZ+3wzrpdIHt01ZJ31pemDQabgrsFtrMt2QB6xnq/Liai4wSPCXrdW
	 OTGxUEkySlNTHfjYwWon7SXnEraw8+PpkBM4UJ7PHsF627S4OFofMmY9x7fv+4DthlQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795181566;
	h=X-Original-To:Received:DMARC-Filter:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Type:Content-Disposition:In-Reply-To;
	bh=gnCz3ES8tm66iHipwmv17CLb12tKgEyO5B4jPSzg7NQ=;
	b=5bizG9Ol2VDalz1tLOIfzOK+a8vtjE5HMqI1e0MO7g6uxd1fbk5MafM+vJKc6MdjSspL
	 UCiCTNe34v2L0Qh3SVJmSkpbvQDPJfFY0n04Zljk7BR13n9GnHTSWSdg1OEB8BOg4m8bO
	 RgDgpeQVWr5oB6hhRUCUrYZ9JMbbgq0s6XcYHLsZkOf0VBGSHya1AsXMekMpDN0ytU+pd
	 jI96di5YDi0mmeig9ICNheJf0vNWs2b8XPv2xIfAnSy1lq5bGzT244ZlXYWLZYOE1wpQy
	 ga31pAD8G4i+S8GL8CJhtWUPV8QzF071Er4Jrul8dM5rh8navOKmWDjguILBQj4aMbw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=strlen.de;
	spf=pass smtp.mailfrom=strlen.de;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 75CE8606A335;
	Fri, 20 Nov 2026 13:32:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.216.245.30
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795181565;
	b=bvaPLpJgbe4iCEQjfH2rDZ2HUU5ernxFGks4/TYq3inV/kQLhAAYJVobrm2GHWK5QJiB
	 EPs9Ik8a2NWxgki+7AeVA3e+/47XH+MR9X4A+HyK/7Ch80lqzbNWbgY2kaiJd2BpnQeI6
	 k7Z4EYs5PL1akvRaJ2laSQXTu5glZR2psx6ry7eBstkCiMpYMe13miaBnQ1ryao936s55
	 3NyywHUYvNNL8GWdKSiXAiQqDk/CPsZuD4vAkxchzl/Wb8S6libXaxMYV71Qb8/MJOKyx
	 G13++dCGcU6rNYTgIbgaqTSExbNUiqHf2ondSkDqfovzcpmiBcziWIwllyOLcEi2s6A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795181565;
	h=DMARC-Filter:Received:Date:From:To:Cc:Subject:Message-ID:References:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=gnCz3ES8tm66iHipwmv17CLb12tKgEyO5B4jPSzg7NQ=;
	b=p1uA4FvYuz8UXILGmyhxOZTbEcaEkzshR4LZ6rh81Z903yxkoX7pi2ssOvqzl/9H2L0v
	 6Lscicyi0N1TuDxjZ3DVXiA3JCmEqEhn4E3WYV1ps+prjsVYkWTx+heBWLf6bf9YekrEG
	 DrgVat5AD+Oa3vfrwObQArIUZVqnE/IRM7bSAjnTHz1YVRunZQ1Gqq2IEQKC6QVEPKZXm
	 62yyPecOg8qmvRP8YQaPrgjb81CV2bx/wIHJB7i00wQPE/kD6Ctu2VOkuuioHQTVzt5LG
	 LIpD1JFRKFE/L77q0loGKMwLAsWHVkvj1B7i8IU9OvwG8O5kh98tUgtVjNUkdNjgdXg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=strlen.de;
	spf=pass smtp.mailfrom=strlen.de;
	arc=none smtp.remote-ip=91.216.245.30
X-Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4345E606A320;
	Fri, 20 Nov 2026 13:32:39 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4345E606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=strlen.de
X-Received: by Chamillionaire.breakpoint.cc (Postfix, from userid 1003)
	id 873D960D35; Fri, 20 Nov 2026 14:32:31 +0100 (CET)
X-Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Gwanhyun Lee <gwanhyunlee@gmail.com>, Phil Sutter <phil@nwl.cc>,
	netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261120105718.866862-1-graypanda.inzag@gmail.com>