🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25250

[PATCH 13/22] xfrm: iptfs: force a dst reference before queueing an skb

#25250
From: Steffen Klassert
Date: Tue, 01 Dec 2026 12:41
58 lines
11418 bytes
From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>

iptfs_output_collect() is the dst->output hook and runs under the
caller's RCU read lock. It queues the skb and sends it later from the
iptfs hrtimer. The skb may still carry a noref dst, e.g. one set by
__ip_queue_xmit() via skb_dst_set_noref(). Once the RCU section ends,
nothing keeps that dst alive.

When the timer fires, xfrm_output_one() calls skb_dst_force() outside
any RCU section:

  WARNING: include/net/dst.h:326 at xfrm_output_resume+0x41d9/0x64e0
  Call Trace:
   xfrm_output_one net/xfrm/xfrm_output.c:549 [inline]
   xfrm_output_resume+0x41d9/0x64e0 net/xfrm/xfrm_output.c:597
   iptfs_output_queued net/xfrm/xfrm_iptfs.c:2325 [inline]
   iptfs_delay_timer+0x3803/0x4310 net/xfrm/xfrm_iptfs.c:2362
   __run_hrtimer kernel/time/hrtimer.c [inline]
   __hrtimer_run_queues+0x3bc/0xa10 kernel/time/hrtimer.c
   hrtimer_run_softirq+0x1e3/0x2e0 kernel/time/hrtimer.c:2153
   handle_softirqs+0x265/0x8d0 kernel/softirq.c:669

The warning also means the queued skb may point to a dst that has
already been freed.

Take a reference with skb_dst_force() while still under RCU, as other
deferred xmit paths do, and drop the skb if its dst is already gone.

Fixes: 0e4fbf013fa5 ("xfrm: iptfs: add user packet (tunnel ingress) handling")
Reported-by: syzbot+622de7e1f18a30fc404a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=622de7e1f18a30fc404a
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_iptfs.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 0313a43aa8a9..3fff835497b9 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -1914,6 +1914,13 @@ static int iptfs_output_collect(struct net *net, struct sock *sk, struct sk_buff
 			continue;
 		}
 
+		/* The queued skb outlives our RCU section, so pin its dst. */
+		if (!skb_dst_force(skb)) {
+			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
+			kfree_skb(skb);
+			continue;
+		}
+
 		/* Enqueue to send in tunnel */
 		ok = iptfs_enqueue(xtfs, skb);
 		if (!ok)
-- 
2.53.0
Technical Details
Message-ID: <20261201124252.1163254-14-steffen.klassert@secunet.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375040-linux-kernel-netdev=dewy.ru
References: <20261201124252.1163254-1-steffen.klassert@secunet.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375040-linux-kernel-netdev=dewy.ru
From: steffen.klassert@secunet.com (Steffen Klassert)
Newsgroups: linux.kernel.netdev
Subject: [PATCH 13/22] xfrm: iptfs: force a dst reference before queueing an skb
Date: Tue, 1 Dec 2026 13:41:39 +0100
Organization: Usenet Network
Message-ID: <20261201124252.1163254-14-steffen.klassert@secunet.com>
References: <20261201124252.1163254-1-steffen.klassert@secunet.com>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1711778"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Jlm2raQd7qsoDJrL6EW2sWRqS7E= sha256:+A8zZ15T8MPSjcFqWBVc6RXsvw0j8GSa/I2Hf475HDY=
	sha1:qBetUsah5F57RBHOs8ouKEM4t4c= sha256:XgGWhRafLgsvZ7twVoosPO8M1fROIHvSKVN54brafh8=
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 DFE76117378; Tue,  1 Dec 2026 15:44:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	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-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=secunet.com
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 c3B0nMoTbgDF;
	Tue,  1 Dec 2026 15:44:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-375040-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=secunet.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 0DCEB117383; Tue,  1 Dec 2026 15:44:17 +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 E72C8602252; Tue,  1 Dec 2026 12:44:16 +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=1796129049;
	b=TQY+/7+8fZYNdCFbIi9hxQ+AyJLaPkyB0X9B3eZA28uS+LIJjC1umQqzcmZKP0d1McXT
	 4TXvqS0o/GTpXHuPZic85ygK9m0NFCP14dFsYAAR1RuPkdXLAmnGoOt8qIpGM6QhC9yxx
	 u1AJ3+/1Hl9+IqM0VzkNDkCVMADsVsarBWnDL08jZGOvjfE9FLejfdAZq0PmFy9Sl4b/o
	 XffOhpPMdLFKBU7Y12zUC0ajiWEskc0V1QuaVlzD1Mj5n8sflg6YZhFKIQE6XLdX3adba
	 FDUgT+KEhzVKKNQNSafn7xdawxg22Mbq4fnt2TJYMHGRzNEW48DcogNb8+zaTKRb45g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796129049;
	h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned:
	 Received:Received:DKIM-Filter:DKIM-Signature:Received:Received:From:
	 To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy;
	bh=ghTBPr6KAR++h8XkmhxStVjzFmJ8e6YTFMBn4ML3CEs=;
	b=fhiNcEixV5xrt63MZPaM/BlVabCS45oIR5fFTvlspHUFZ4j8uBZjpz0IOInwmNk1MGdD
	 Aj936vR+OJDEKLrfoVmFmDFiGvCo013QRVdgphkxFdBn0yXtuuocA38PIl9uOvqFlnFV5
	 lC7EfmWJzkw1RgcnMjWKlJgRx3re9WgLqjj/NGqQzG3KYba/5np8v1x9HcFKAlfVq0xi6
	 G7ptB8HO0kNedQOn+/PfI/rQo9GOtRVFdAQsOzjLAffCFQlQQhcsbR+rAff/Y0AuODEKK
	 ieFwpBaWr9c7M0IDf9SKXFdkLyahigOIRUFXqVe8D91XnU0JRDl0eDrf/WdgUBgYbCQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b="j//wziOP";
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	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 8F69A606A689;
	Tue,  1 Dec 2026 12:44:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=j//wziOP
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.96.220.36
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796129048;
	b=b7N4bDSyqjH4g2hM4hLGsP06aFP7eDTs7DxgDPQWp9WjYv1dPleGvmcJwawf6tU4mdh0
	 DK2DjDdE3thmRuQ9m9ZBe8Ih1/I9x5qykfRfmeALmpcZ3sFhP/by1vJbJrp61SAjtBT0r
	 MXScdgg7vRMM/UvcIbN/sBFH7X9M5fPXQS2yLqtpWfElx0vr0ZyoTARHZJQBMDdOyn7LZ
	 8SgkDmL4A+vwhdCrJ2fqZ+rCA2e1YR1aLUQKv9hzx42oWZ7naOL4yVJ37ejsin7WIu0cQ
	 lZyST1gA39qGHKlOqwrBae/K50dtatIPmmgsy5hSKEO+B25O/ms+wztdCJ5CIjFLvDQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796129048;
	h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter:
	 DKIM-Signature:Received:Received:From:To:CC:Subject:Date:Message-ID:
	 X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy;
	bh=ghTBPr6KAR++h8XkmhxStVjzFmJ8e6YTFMBn4ML3CEs=;
	b=qmKIZ37Rl8ZNSXkZsNx0gdnDZ101w0OtJifZWUlms9iB3SL4wTTghh3h/muM0tMZdM3k
	 byL5JAryf6WDyfShlpOHM1n6fxucF4BcSpLKtuzlZmbagD3KyJlrH+9RoBNtJfcUx2Zvz
	 5xcgnhTsL8v7707z1t8wDuJRKPXWdDUaNC6qSyFnKIin+Bauh8rrruSblkARHVURendKD
	 5WpXjWRMmzrVLkz/Ku3ju/TsiHtGc7A++njlWP9XaCBFrwnGLdB0vWhKd3qj9jbCrRYar
	 tf8PGIXd/jj7o68VKkAqLi9awOHvqfwtbnKElSslF2WzzoK9ZfxyrvefX15eQEW3EAw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	dkim=pass header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b="j//wziOP";
	arc=none smtp.remote-ip=62.96.220.36
X-Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CA9A606A696
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 12:44:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1CA9A606A696
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com
X-Received: from localhost (localhost [127.0.0.1])
	by mx1.secunet.com (Postfix) with ESMTP id BC8B8207FC;
	Tue,  1 Dec 2026 13:44:06 +0100 (CET)
X-Virus-Scanned: by secunet
X-Received: from mx1.secunet.com ([127.0.0.1])
 by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id st1IO7tMblH8; Tue,  1 Dec 2026 13:44:05 +0100 (CET)
X-Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mx1.secunet.com (Postfix) with ESMTPS id D6601204D9;
	Tue,  1 Dec 2026 13:44:05 +0100 (CET)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com D6601204D9
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com;
	s=202301; t=1796129045;
	bh=ghTBPr6KAR++h8XkmhxStVjzFmJ8e6YTFMBn4ML3CEs=;
	h=From:To:CC:Subject:Date:In-Reply-To:References:From;
	b=j//wziOPsR61uIEfd62gyq210HKu1caprGWA57PGxbxJTQUeDWUpHUywywjuCXmnf
	 UTSTFcCstkVmX1m+IvFe71ghxfV4omkQkyjOClp/wL2iJuZizeDRGbez/AGr6Dejq6
	 rY/LIc35bWAXYfFKcZUkA6/Y/FyNX3fWi5pbGxqM2In+eZ0YfXFwVtzoA8ab1uoxZG
	 fe84QDQx4ErwWjtaW6CXWn++Q1GVQwzHSAnAUmQlX8URxMvlO2DDFh4yon826iYrl9
	 iJlggIfYQJDGd4YZD2pyGZIHDcEPULM965gfvpQ3ejwuW0J2CkHed2VsTN4eylQ8Mu
	 ovJfRg9mLWa0A==
X-Received: from gauss4 (10.182.7.102) by EXCH-01.secunet.de (10.32.0.171) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 1 Dec
 2026 13:44:05 +0100
X-Received: (nullmailer pid 1165806 invoked by uid 1000);
	Tue, 01 Dec 2026 12:43:56 -0000
X-CC: Herbert Xu <herbert@gondor.apana.org.au>, Steffen Klassert
	<steffen.klassert@secunet.com>, <netdev@vger.kernel.org>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261201124252.1163254-1-steffen.klassert@secunet.com>
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-ClientProxiedBy: EXCH-02.secunet.de (10.32.0.172) To EXCH-01.secunet.de
 (10.32.0.171)