🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10110

Re: [PATCH ipsec v2 2/2] xfrm: use cached offload ifindex when migrating an SA

#10110
From: Antony Antony
Date: Tue, 03 Nov 2026 08:01
61 lines
12116 bytes
On Sat, Oct 31, 2026 at 11:28:49 +0800, Cen Zhang wrote:
> An xfrm_state reference keeps its offload record alive, but does not
> prevent xfrm_dev_state_free() from clearing xso.dev and dropping the
> device reference. xfrm_do_migrate_state() checks xso.dev before
> xso_to_xuo() dereferences it to obtain the offload ifindex.
> 
> With XFRM offload and migration enabled, XFRM_MSG_MIGRATE_STATE inherits
> the old SA's offload configuration if the request omits
> XFRMA_OFFLOAD_DEV and does not set XFRM_MIGRATE_STATE_CLEAR_OFFLOAD.
> Device unregister can flush that SA between the check and the read.
> The supplied report used a scheduling probe to delay migration in this
> interval while in-tree netdevsim was removed through sysfs.
> 
>     Migration (xfrm_cfg_mutex)       Device unregister (RTNL)
>     xfrm_state_lookup(): hold x
>     test x->xso.dev != NULL
>                                     xfrm_dev_state_flush()
>                                       xfrm_state_delete(x)
>                                       xfrm_dev_state_free(x)
>                                         xso->dev = NULL
>                                         netdev_put(dev)
>     xso_to_xuo(&x->xso, &xuo)
>       xso->dev->ifindex: NULL deref
> 
> The netlink configuration mutex does not serialize with the notifier,
> and migration takes the state lock only after this read. The result is
> a NULL pointer dereference even though migration still holds the SA.
> 
> Use the ifindex cached in the offload record at attachment, as state
> dumps already do. The SA reference protects this snapshot throughout
> the read, so serialization no longer depends on the device lifetime.
> Annotate the binding check with READ_ONCE() to match the concurrent
> WRITE_ONCE() in xfrm_dev_state_free().
> 
> Oops report as below:
> 
>     Oops: general protection fault, probably for non-canonical address
>     0xdffffc000000001c: 0000 [#1] SMP KASAN NOPTI
>     KASAN: null-ptr-deref in range [0x00000000000000e0-0x00000000000000e7]
>     RIP: 0010:xfrm_do_migrate_state+0x1f06/0x2c50
>     Call Trace:
>      <TASK>
>      xfrm_user_rcv_msg+0x3b3/0xc20
>      netlink_rcv_skb+0x133/0x390
>      xfrm_netlink_rcv+0x76/0x90
>      netlink_unicast+0x504/0x840
>      netlink_sendmsg+0x7f7/0xcf0
>      __sys_sendto+0x425/0x470
>      __x64_sys_sendto+0xe5/0x1c0
>      do_syscall_64+0x115/0x6a0
>      entry_SYSCALL_64_after_hwframe+0x77/0x7f
>      </TASK>
> 
> Fixes: a9d155ea9b44 ("xfrm: add XFRM_MSG_MIGRATE_STATE for single SA migration")
> Signed-off-by: Cen Zhang <zzzccc427@gmail.com>

Reviewed-by: Antony Antony <antony.antony@secunet.com>

Thanks,
-antony
Technical Details
Message-ID: <aumUwuVWsOOQdMG-@moon.secunet.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355269-linux-kernel-netdev=dewy.ru
References: <pm-xfrm-core-objects-candidate-0050-v4-3c6b8c5369a802e9be0e-0@gmail.com> <pm-xfrm-core-objects-candidate-0050-v4-3c6b8c5369a802e9be0e-2@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-355269-linux-kernel-netdev=dewy.ru
From: antony.antony@secunet.com (Antony Antony)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH ipsec v2 2/2] xfrm: use cached offload ifindex when
 migrating an SA
Date: Tue, 3 Nov 2026 09:01:06 +0100
Organization: Usenet Network
Message-ID: <aumUwuVWsOOQdMG-@moon.secunet.de>
References: <pm-xfrm-core-objects-candidate-0050-v4-3c6b8c5369a802e9be0e-0@gmail.com>
 <pm-xfrm-core-objects-candidate-0050-v4-3c6b8c5369a802e9be0e-2@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Injection-Info: usenet.network;
	logging-data="3118941"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:eDEvjgNv8EG+QFsShaH7z9DraRU= sha256:/rQCTmjWb8qZ5PQQ9l8NbNSoAZV3Dz6RZBbDJj78jRM=
	sha1:lYY5rTDF39Pe8kl/b1zNQNeK5lo= sha256:LzI8YtckvSfe/v6T5N1ZgI1XSi/To3X6c/eJzhSYMK4=
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 D7C2F112767; Tue,  3 Nov 2026 11:06:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 7eLsLp-hDXZN;
	Tue,  3 Nov 2026 11:06:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-355269-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id D10881126DB; Tue,  3 Nov 2026 11:06:00 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 8DB3E2EE26; Tue,  3 Nov 2026 08:01: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=1793692884;
	b=WmrLA3AL1TorMLnWIkHEnvdDNl9KNIeLjNFf5fxhVZ1dDSuiK+AL0BShFvyjmTixhdo7
	 f8XwsNJ6iYcDHoDKrNXDQJF1CJATQF6ETsjlyd8azvYFLaG0d7ZC1rCDuOqyi+pqupcE/
	 iIBl7GmEYKJ5IaU5U0XyHzUSv0bSkJN3dKaM96ZMAoEnT3ESisuHsL2/oWy/jIMEMxhtt
	 9r2k3eziavM+PS57bxY4O+tcokvn4GMWIvi2+GydMob8q6XwjuhsSfK0gcZgXu5oerb+y
	 l8kVdAY7tf0FjgB+ySkRUk+QsGfI3xgOL4Eye7VvBfy6ad2e2jslVb0cC+BSfmq7yew==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793692884;
	h=X-Original-To:Received:DMARC-Filter:Received:X-Virus-Scanned:
	 Received:Received:DKIM-Filter:DKIM-Signature:Received:Date:From:To:CC:
	 Subject:Message-ID:Reply-To: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:
	 Precedence:Priority:Organization:X-ClientProxiedBy;
	bh=AulrUU0VFXvSrJAGFo85zXAc23lwBKp4vP1wSVUq+Rk=;
	b=MEqANC5nHbBNZsP2zRBuDAb1fKKeDZ4gNS5a9uZJrU7bBYhbn7wxtro4QZuZx8SdOwNc
	 TtfqaUYtG7zrCR/0x1sV8CJyodb28r8MLlV61mJOQIxpXw4pgry4qWS6jN4djLMHf4vbL
	 ALHoTWNuZ9X/csBCn4eXcvYLqq79SGI83Vdx53Kjo/B0Pg4f6wGlIa/TnD1jVcWu10H2V
	 zGeQE1lJXRVRNkoyqCUhb6ZKqRz1AyhFpu8Ga0IeX1apVnNsyvnr+b6ieHVn5Wvk47fu5
	 1TlaVAtdZn87bpELq6BW/ymL2VJUU7A0hBQmIrKPERMqwpHpVb4EEeB8x9RtZrh1d2Q==
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="LTu1W9I/";
	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 EC9C4606A332;
	Tue,  3 Nov 2026 08:01:23 +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=LTu1W9I/
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=1793692882;
	b=SHnOXT2j31FJISCwcpN9CC/le03nYG7NrqXs0hl51mWuTpww1YtSoFSvO25WCjk5h0TD
	 QbT7+OLbMdMHH1dBHz/NX5RfopTba1d2DoaQRH7EvcoIZj8M98yR9DuvIcVHR2keXufqG
	 E8qL1lVjzfuD9oWViugeJhm6AQWm275Y62coRSxCii+qNM90e6Hsokunn7/+d+O2lf/dS
	 w9vhM/n5FlbGyKH/izMABVqW8OrvVwT1bnYPiSpy+zjh8hPBBRL5LSc95FRpMcnJWepRX
	 iA0ogAbzjBYCVqZXRC4vWVjcS+4pGhgeqNaqt6dOCTi9QBHbXlxTqX3t4o53XWwOoYg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793692882;
	h=DMARC-Filter:Received:X-Virus-Scanned:Received:Received:DKIM-Filter:
	 DKIM-Signature:Received:Date:From:To:CC:Subject:Message-ID:Reply-To:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:
	 Precedence:Priority:Organization:X-ClientProxiedBy;
	bh=AulrUU0VFXvSrJAGFo85zXAc23lwBKp4vP1wSVUq+Rk=;
	b=3HaQPBZnG9G6VXUOSjKR0vRvm37yKEb2KTZnbtZxvLW2QStRL9YlhBWg1j54bIqPyxrq
	 hWzpx7zirjaJtEiRyQEJiCux27ROC14umT5+AFx3Aryq/Wcq1L+zTKakvydODIcFQ5wsx
	 RPPdX5E86IKZ8ahpho4yRJumyim4U/huRe4L4b594ckpToL/ITTdKCIZFT8uT8+pqGykj
	 DfSW8yB0n62BE+bVmlleOBR83naXk91CZb4QvBiIZRim8NR22iV8vkp08sQeugITft81g
	 eQAuCwMYf5fZmifpA6WBt6QLn8Mw5bsyf0mD4ZAJz+a4jvSQCI/0hJnfWFvCC9KJirQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=secunet.com;
	spf=pass smtp.mailfrom=secunet.com;
	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 087EE606A338;
	Tue,  3 Nov 2026 08:01:20 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 087EE606A338
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 D95BC20748;
	Tue,  3 Nov 2026 09:01:18 +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 dr39lHmud8xT; Tue,  3 Nov 2026 09:01:18 +0100 (CET)
X-Received: from EXCH-02.secunet.de (rl2.secunet.de [10.32.0.232])
	(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 3A42F20190;
	Tue,  3 Nov 2026 09:01:18 +0100 (CET)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 3A42F20190
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com;
	s=202301; t=1793692878;
	bh=AulrUU0VFXvSrJAGFo85zXAc23lwBKp4vP1wSVUq+Rk=;
	h=Date:From:To:CC:Subject:Reply-To:References:In-Reply-To:From;
	b=LTu1W9I/GERA4yBvnwWR9m32ftaX72hSnQcQBoqua3IbiVOBtaHJa0EV1Dn8O6vRr
	 0uOAckMZOiqwuKFvO8Yaau64/ZxMd2VvxKErJhbPw0zMsA0JukabvI6RBg4TyBbkAS
	 KLTO+dEvenFCUudvf5mbKkrsiDhBBXOeRSSP+kMBVYOoMwyIM9KfWN+pVmlb7W6wKJ
	 MrdkzXSPAWbnTGSZwfDpqAIFCZnEVZTSahJle16uxs+LPWNGB82OrTOZzudOJqK494
	 KM2MJ6YME6mkn5rKYP/XChnSql4CB/4fmxyQFcFEdtWtNj3BpYSB6PwoTcisFTGIRr
	 H39dvPsYdVtgQ==
X-Received: from moon.secunet.de (172.18.149.1) by EXCH-02.secunet.de
 (10.32.0.172) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Tue, 3 Nov
 2026 09:01:17 +0100
X-CC: <steffen.klassert@secunet.com>, <herbert@gondor.apana.org.au>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <horms@kernel.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <antony.antony@secunet.com>,
	<baijiaju1990@gmail.com>, <jjzuming@gmail.com>
X-Reply-To: <antony.antony@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-In-Reply-To: <pm-xfrm-core-objects-candidate-0050-v4-3c6b8c5369a802e9be0e-2@gmail.com>
X-Precedence: first-class
X-Priority: normal
X-Organization: secunet
X-ClientProxiedBy: EXCH-04.secunet.de (10.32.0.184) To EXCH-02.secunet.de
 (10.32.0.172)