🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12060

Re: [PATCH ipsec] xfrm: keep the mode module pinned until destroy_state returns

#12060
From: Steffen Klassert
Date: Fri, 06 Nov 2026 07:50
114 lines
14673 bytes
On Thu, Oct 29, 2026 at 11:19:11AM +0800, Cen Zhang wrote:
> An IPTFS state keeps its mode module referenced while mode_data exists.
> However, iptfs_destroy_state() drops that reference before returning to
> xfrm_state_gc_destroy(), which has no reference covering the callback's
> return path.
> 
> With CONFIG_XFRM_IPTFS=m and module unloading enabled, deleting the last
> IPTFS SA can overlap with ordinary module removal in this order:
> 
>   XFRM GC worker                      rmmod xfrm_iptfs
>   iptfs_destroy_state()
>     free mode_data
>     module_put(owner)
>     <preempted>
>                                       delete_module()
>                                         xfrm_iptfs_fini()
>                                           unregister mode callbacks
>                                         free_module()
>     resume in freed module text
> 
> An unload started after the put can finish before the callback resumes.
> GC invokes the callback outside an RCU read-side critical section, after
> its grace period. The RCU waits in mode unregistration and module
> freeing therefore do not protect the callback. The GC mutex only
> serializes GC with device state flushes. Resuming the callback can cause
> an instruction-fetch fault in the freed module text.
> 
> The Oops below was observed on an earlier kernel with scheduling probes
> holding the worker in module_put() after the decrement until ordinary
> rmmod completed. The fixture created and deleted the SA over
> NETLINK_XFRM.
> 
> Take an additional reference to the already pinned owner before calling
> destroy_state(), and release it in XFRM core after the callback returns.
> Cache the owner before the call so releasing the extra reference does
> not need to access the callback table after the callback has finished.
> 
> Oops report as below:
>     BUG: unable to handle page fault for address: ffffffffc0407455
>     #PF: supervisor instruction fetch in kernel mode
>     #PF: error_code(0x0010) - not-present page
>     PGD 80a9067 P4D 80a9067 PUD 80ab067 PMD 0 
>     Oops: Oops: 0010 [#1] SMP KASAN NOPTI
>     CPU: 3 UID: 0 PID: 53 Comm: kworker/3:1 Not tainted 7.2.0-rc5-pmb-xfrm-functional-v1+ #11 PREEMPT(lazy) 
>     Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
>     Workqueue: events xfrm_state_gc_task
>     RIP: 0010:0xffffffffc0407455
>     Code: Unable to access opcode bytes at 0xffffffffc040742b.
>     RSP: 0018:ffff8881013e7aa0 EFLAGS: 00010282
>     RAX: 0000000000000000 RBX: ffffffffc02199c0 RCX: ffffffff816fc84e
>     RDX: ffff8881013c0000 RSI: 0000000000000000 RDI: ffffffff86338344
>     RBP: ffff8881013e7ba8 R08: 0000000000000001 R09: 0000000000000001
>     R10: ffffffff893e0257 R11: ffff8881013c0000 R12: ffff888107e9ec00
>     R13: ffff888102b07980 R14: ffff888107412ec0 R15: ffff8881013e7ae0
>     FS:  0000000000000000(0000) GS:ffff8881fd929000(0000) knlGS:0000000000000000
>     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>     CR2: ffffffffc040742b CR3: 00000000080a6006 CR4: 0000000000770ef0
>     PKRU: 55555554
>     Call Trace:
>      <TASK>
>      ? pmbd_gate_maybe+0x47/0x60
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? lock_is_held_type+0x8f/0x100
>      xfrm_state_gc_task+0x17e/0x790
>      ? lock_acquire+0x17b/0x2f0
>      ? __pfx_xfrm_state_gc_task+0x10/0x10
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? lock_release+0xc8/0x280
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      process_one_work+0x908/0x19c0
>      ? __pfx_process_one_work+0x10/0x10
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? lock_is_held_type+0x8f/0x100
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      worker_thread+0x65c/0xe40
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? __kthread_parkme+0x175/0x220
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? __pfx_worker_thread+0x10/0x10
>      kthread+0x34f/0x460
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? __pfx_kthread+0x10/0x10
>      ret_from_fork+0x659/0x940
>      ? __pfx_ret_from_fork+0x10/0x10
>      ? srso_alias_return_thunk+0x5/0xfbef5
>      ? __switch_to+0x74f/0xf80
>      ? __pfx_kthread+0x10/0x10
>      ret_from_fork_asm+0x1a/0x30
>      </TASK>
>     Modules linked in: [last unloaded: xfrm_iptfs]
>     CR2: ffffffffc0407455
>     ---[ end trace 0000000000000000 ]---
>     RIP: 0010:0xffffffffc0407455
>     Code: Unable to access opcode bytes at 0xffffffffc040742b.
>     RSP: 0018:ffff8881013e7aa0 EFLAGS: 00010282
>     RAX: 0000000000000000 RBX: ffffffffc02199c0 RCX: ffffffff816fc84e
>     RDX: ffff8881013c0000 RSI: 0000000000000000 RDI: ffffffff86338344
>     RBP: ffff8881013e7ba8 R08: 0000000000000001 R09: 0000000000000001
>     R10: ffffffff893e0257 R11: ffff8881013c0000 R12: ffff888107e9ec00
>     R13: ffff888102b07980 R14: ffff888107412ec0 R15: ffff8881013e7ae0
>     FS:  0000000000000000(0000) GS:ffff8881fd929000(0000) knlGS:0000000000000000
>     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>     CR2: ffffffffc040742b CR3: 00000000080a6006 CR4: 0000000000770ef0
>     PKRU: 55555554
>     Kernel panic - not syncing: Fatal exception
>     Kernel Offset: disabled
> 
> Fixes: 4b3faf610cc6 ("xfrm: iptfs: add new iptfs xfrm mode impl")
> Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
> Assisted-by: LLM

Applied, thanks a lot!
Technical Details
Message-ID: <au2GuZzD5np1nwiY@gauss4>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357823-linux-kernel-netdev=dewy.ru
References: <pm-xfrm-core-objects-candidate-0003-v3-3f3e13b81234df0bb10f@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357823-linux-kernel-netdev=dewy.ru
From: steffen.klassert@secunet.com (Steffen Klassert)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH ipsec] xfrm: keep the mode module pinned until
 destroy_state returns
Date: Fri, 6 Nov 2026 08:50:17 +0100
Organization: Usenet Network
Message-ID: <au2GuZzD5np1nwiY@gauss4>
References: <pm-xfrm-core-objects-candidate-0003-v3-3f3e13b81234df0bb10f@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Injection-Info: usenet.network;
	logging-data="3822101"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:GpJVD2uWaQ67AafWaZXwe4rHPqk= sha256:2W1pk7MhZeUPj5uMNV1QLK93iCiCsuF2aymtykM+M9s=
	sha1:I+atyIt7BZQ7rUFxP3fT7+8FPFQ= sha256:8Ubz0zgKGEsv5rb5PvkHP17rpnyjirwNgJSePwI5aVw=
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 46B411131A5; Fri,  6 Nov 2026 10:50:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 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]
	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 p793uAof5uiF;
	Fri,  6 Nov 2026 10:50:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-357823-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 97AE711319B; Fri,  6 Nov 2026 10:50:27 +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 30D14601517; Fri,  6 Nov 2026 07:50:27 +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=1793951424;
	b=N8pX4/Nn5Zoqe9Mej9BFl0rh8EZtV2SfCR1xVKusFCe2m4rXGBMYR+O8Tm7qAC4LSdxd
	 qsGxkyD3JwzsDVVeFhJBU0dm0Ruag9fBgVSEH06ScfY6wm6fRjfnfXUjoV4XF+YRmlD5k
	 YGZpOlWm979miTE1RGlo/Z6gneoc9TZ/h6vf6zs7P54mhF/+xICQna42IGiN8JEBvPrn6
	 LfDRW/ZDq0t3IHA1csViAeK8kZTQ/mRb3/B7NzvPuvymNIJAILjcFpaqSc8oTgqKZJHyj
	 QsJ4NhyfkseQRlKN04OtB9OvDV4fX5FcG/SVeP078mWx905lT79JWjLvvJ3wsK1bKgQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793951424;
	h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned:
	 Received:Received:DKIM-Filter:DKIM-Signature:Received: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:
	 X-ClientProxiedBy;
	bh=0WPYejdlZaNbGWqikmEW2WWog+lfVYOfd9tK6fXAjJM=;
	b=0N25+nxAJezotGZVI1obQdBnebpYFVKllC7+7flR3PYfwgHZfor6Heu562XCbQeAaV9U
	 3Ln91OL2fT+Dy61TkEWMbX/Iqmk965Msec+zQnWCQ/4Sc/v+ZuYQ+X9jGexaw7fCR8LnM
	 VU/kZvc+QZCxwksj5FLVm3AgjhsJZe2gZvKx4dvAWgxstT7/GEyNZFddTQJKdctJElLFM
	 xSFjioh/SRcrRZKishYMn2cLQhofHJK8oxma1ib0SQYh+wDEZoOPN+7YPdwsC7IBF6nFz
	 gos3SM2roG/VjShX3P8PJeghK0F2FxkO9FGAz62dLKtlaU5PG1UwFamLybOzVSwfVnQ==
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=q+71oVcA;
	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 886D0606A330;
	Fri,  6 Nov 2026 07:50:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=secunet.com header.i=@secunet.com header.a=rsa-sha256 header.s=202301 header.b=q+71oVcA
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=1793951423;
	b=NbcrB3mzPjDfxdiDH+2RMlplAJmHlDk2QrhS66hHUqhBX07PYUdyMK3GbMLxh6GGp3xt
	 0VVemjissQvMhxvCtkdQOnmugvH2Atws51OItr+350uOgnNZc1+WTMMnYl55IKfyOnJTw
	 g7crzuvzv3XzxveRrFmEkMAd/36pnZLksdwDUeyjywgkBeo7jK4/SrMs2UzBf3ZeDhx6j
	 MjW6TrJJjVh8XeByetN9TRGaeNeG3SFsNfH5vPMIMwR0Aygv8L0U7DspW6/QZA8JD9ue2
	 1nbG01MhivvO4fM6HeJgtg/jvYB+apRjFldLZ7v1StXcmBA3lYfBwB7AFadKWMKh57Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793951423;
	h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter:
	 DKIM-Signature:Received:Received:Date:From:To:CC:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:
	 X-ClientProxiedBy;
	bh=0WPYejdlZaNbGWqikmEW2WWog+lfVYOfd9tK6fXAjJM=;
	b=zNxokWgjaLA6WeYn8PmXr1cObaEpv9xWwwi+2bMuE7vXgv56PkhLFDzgRTKSWdepQguU
	 +DoPHDNCrYAsRNePwpRZq5tlxtPsK3HDcDc/5Kchw906y4y/KiIO+u8zm6k4PUUXmwreK
	 gc6A9oPbisMjcJ2CY29bGIxyMID4b8aphEO0Vo0cXIw5xGJgmMt6qFk34uZr1NK6mBOIV
	 +GUxFnIhKyIBRMedxTBL+euGZ/7qo7Kdc0VOkj9gTsslDKGWgsma6Eckzhwf7iXAyxPaN
	 JsVhiBkZJgRDkSS8Sn9H3p2dV7w/baXVBoQILDLvDZtqMoerfO0xb4hetkByRpjqbEw==
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=q+71oVcA;
	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 31FA3606A326
	for <netdev@vger.kernel.org>; Fri,  6 Nov 2026 07:50:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 31FA3606A326
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 5CBC820870;
	Fri,  6 Nov 2026 08:50:20 +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 VskECbvq89cT; Fri,  6 Nov 2026 08:50:19 +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 A3ADA2074F;
	Fri,  6 Nov 2026 08:50:19 +0100 (CET)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com A3ADA2074F
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com;
	s=202301; t=1793951419;
	bh=0WPYejdlZaNbGWqikmEW2WWog+lfVYOfd9tK6fXAjJM=;
	h=Date:From:To:CC:Subject:References:In-Reply-To:From;
	b=q+71oVcAHQrvZo+4515Bkjs3Y+6OOPKM6EWCrxg/uU0OX3UhoflwaY90dV3zyPsaI
	 iUOu+ORwP00o9ZHVGPwNyw4sXGivkYzwXBQx/diYt/WPTedUaIg238jxSDLUUeI0+9
	 zzsecN7wOCROcWbizs7dEpYpUf7Vv+0MsiWwVoxbvhdat2EBGv3Q+MUTgvVCOiXAld
	 7QeLeCwJ1CUizuPrYjDWc5kGYbdrkyTAY3R0o4XSGEC3Bqoo6KQnvzNMgSdLS3iXPV
	 6jsU2GTtxjbi4A5MQfTUuCPu9uAnQxbQ8rydCcVu6yHvbZCAjO8IO3FdxNeibxYgz2
	 e0QqtywrZ3QMA==
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; Fri, 6 Nov
 2026 08:50:18 +0100
X-Received: (nullmailer pid 3071058 invoked by uid 1000);
	Fri, 06 Nov 2026 07:50:17 -0000
X-CC: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
	<netdev@vger.kernel.org>, <baijiaju1990@gmail.com>, <jjzuming@gmail.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-In-Reply-To: <pm-xfrm-core-objects-candidate-0003-v3-3f3e13b81234df0bb10f@gmail.com>
X-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de
 (10.32.0.171)