Article View: linux.kernel.netdev
Article #5312Re: [PATCH ipsec v5 0/9] xfrm: state: exact mark/mask match for control-plane SA lookups
From: Steffen Klassert
Date: Tue, 20 Oct 2026 05:44
Date: Tue, 20 Oct 2026 05:44
73 lines
13211 bytes
13211 bytes
On Wed, Oct 07, 2026 at 11:34:13AM +0200, Antony Antony wrote:
> While looking into a XFRM_MSG_MIGRATE_STATE issue reported by Sashiko,
> we found the underlying problem generalizes: xfrm allows multiple SAs
> to coexist for the same (SPI, daddr, proto) differing only in mark,
> and every netlink method that resolves "which SA" - xfrm get_sa(),
> del_sa(), update, get_ae, new_ae, expire, migrate - uses the same
> wildcard mark match the data path needs. A broader-mask SA can
> silently shadow a more specific one:
>
> # ip xfrm state add ... spi 0x1000 mark 1 mask 1 (SA_target)
> # ip xfrm state add ... spi 0x1000 mark 0 mask 0
> (SA_decoy, catch-all, added after -> bucket head)
> # ip xfrm state delete dst ... proto esp spi 0x1000 mark 1 mask 1
> -> deletes SA_decoy; SA_target survives, untouched
>
> xfrm policy had the same bug, fixed in commit 4f47e8ab6ab7
> ("xfrm: policy: match with both mark and mask on user interfaces").
>
> Netlink state lookups using spi use an exact mark/mask match except
> for UPDSA; the wildcard match stays for the data path and state_add only.
> This series applies that fix across every affected method,
> not just XFRM_MSG_MIGRATE_STATE.
>
> Also reject marks with value bits outside the mask (state ADD,
> ALLOCSPI, policy ADD, MIGRATE_STATE new mark). These are
> misconfigurations anyway, since the extra bits can never match, and
> break exact match added here.
>
> This series does not touch PF_KEY, which no longer receives
> non-critical fixes.
>
> state_lookup_byaddr is out of scope. This is only fixing spi based
> lookups.
>
> ---
> v4->v5: policy: drop the redundant mark sanitize in xfrm_policy_insert()
> - tweak commit messages
>
> - Link to v4: https://patch.msgid.link/migrate-state-fixes-v4-0-d5054459fc78@secunet.com
> v3->v4: add 3 patches to reject mark value bits outside the mask for state and policy
>
> - Link to v3: https://patch.msgid.link/migrate-state-fixes-v3-6-836125bb53dd@secunet.com
>
> v2->v3: mark match use only values and no mask in exact lookup
>
> - Link to v2: https://lore.kernel.org/all/migrate-state-fixes-v2-0-c3e2767f0d96@secunet.com/
> v1->v2: few more wildcard mark check reported by sashiko and Yan
> - keep wildcard match in xfrm_state_update() (UPDSA)
>
> - Link to v1: https://patch.msgid.link/migrate-state-fixes-v0-8-a69e8637ba3b@secunet.com
> ---
>
> ---
> Antony Antony (9):
> xfrm: state: reject mark with bits outside its mask on add
> xfrm: state: reject mark with bits outside its mask on ALLOCSPI
> xfrm: policy: reject mark with bits outside its mask on add
> xfrm: state: exact mark/mask match for SPI-keyed control-plane SA lookups
> xfrm: fix use-after-free of migrated state in xfrm_do_migrate_state()
> xfrm: fix hw offload state leak on xfrm_do_migrate_state() error path
> xfrm: include mark in MIGRATE_STATE SA collision check
> xfrm: pass extack through to xfrm_init_replay() from xfrm_init_state()
> docs: xfrm: include mark in XFRM_MSG_MIGRATE_STATE EEXIST tuple
>
> .../networking/xfrm/xfrm_migrate_state.rst | 25 +++--
> include/net/xfrm.h | 7 ++
> net/xfrm/xfrm_policy.c | 3 -
> net/xfrm/xfrm_state.c | 101 +++++++++++++++++----
> net/xfrm/xfrm_user.c | 81 ++++++++++++-----
> 5 files changed, 166 insertions(+), 51 deletions(-)
Series applied, thanks a lot Antony!
Technical Details
Message-ID:
<atb_rttOpKrO3MRP@secunet.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349046-linux-kernel-netdev=dewy.ruReferences:
<migrate-state-fixes-v5-0-d9d3d794553d@secunet.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-349046-linux-kernel-netdev=dewy.ru From: steffen.klassert@secunet.com (Steffen Klassert) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH ipsec v5 0/9] xfrm: state: exact mark/mask match for control-plane SA lookups Date: Tue, 20 Oct 2026 07:44:14 +0200 Organization: Usenet Network Message-ID: <atb_rttOpKrO3MRP@secunet.com> References: <migrate-state-fixes-v5-0-d9d3d794553d@secunet.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Injection-Info: usenet.network; logging-data="3789611"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:a7OkK2kxL8ZeYl8zYqqXa/XiU2U= sha256:bdwH0HOZr31+cQOffIW+vS29MU161OcxvdAUV4PCCtg= sha1:v81Nc2s626bHvohy39HD/A024QU= sha256:ZzJCukMYqlUmgUWAQoROlSZWDlB5TsnbPP03xCGYMTw= 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 1B46A110C05; Tue, 20 Oct 2026 08:44:50 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.049 X-Spam-Status: No, score=-3.049 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.25, 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 Kwws8Tz160TP; Tue, 20 Oct 2026 08:44:46 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-349046-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 448A6110C03; Tue, 20 Oct 2026 08:44:34 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 46B6D43FC2; Tue, 20 Oct 2026 05:44:23 +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=1792475063; b=jfRsQKhwXcbT0HU5iyeEufpSPJ0nv4souDTHKSP3MqoXS8loiqAO42G3zkUIdQByaztD 8HGLpAfj7a1mFvzjxqNAW3lGjFHAn6UU+WOZUopw2RTKnWr3rfGWTbVlzUxTeGHfU1ItD 7I5LANlRXCeih54LWJLuFC8zuPoElQdI3/OMp4R2ba/Mr88mrACMgSsQANKCabZAHMLJi kgZfmY0dYEs48WXffIaNoyPql7lEehODUzO5M83QNdR70ZXl22AtHmJbURzUVRKlOwguq lXpOAjjMPfi/sBaY4HPFEWTSl76lQlRUHUYEpwMsAB3Oyi2OodxMRoRCNR9iaHrYlNg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792475063; 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=SHP+ZuI0NbQryrK1GfspQZp3EZ/0jC5OKBRZ00AmRe4=; b=Mu0envhxTis9GeKixud0zGhHHH1tNbEXr2uMjpYn1hNe2SsMD1s5+z7vUzYqD5pl8g5V p8KALAYMfBf+PJszsU5RdGAovx5JWU3j4obK2JGP8l7dZ0Y/3g+vc5ItM60tbT+93DNlM XSIfZNqPoleaC+N/4kJ/dKuNHWvO/Pd8m/5Cmn212x0oGk/wmlwnVI/rUnjNq1n9Zqz6R Ll4CQ9jIdmGFlfTxDaeuIVNd2jSBKCtcDyDIEa6amDtZ+Lh26Mj6OKP8QXp3XjkPc2tZY 2wNaHuRWhUG2AuAP2qH0U92RJxaPqbR4dqyavbe+AhP2ZYmBypK3UKO5RqMyzPAe+iQ== 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=Bf71C4Si; 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 1DE89606A322; Tue, 20 Oct 2026 05:44: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=Bf71C4Si 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=1792475062; b=s3AEMuiMTdV9XcMX2mMH34k0m50MqSNyqQG1RGrhFR+YI4NNAph2VSkrN12a+uwYwPXh gI8MDTK5iD+2wQXBX3EnevcS5j32OrjCXrIlpQATzZIYNNHJapY/4u7mWW8A3Fn0ba75s oyAQn6AAtEsXFkmqIIcvvPAPbk9v/leruVgWBaWSSvrw7izzVY+wm0Oy+JV15COM5bDF0 DfWP2ucykZI6eb9bGG69wAnGBP5FoqvTd6EERZyK/bcX4rzwIXr2J4+mbfr2OyyqhRZcO DhwxWD3P17h9fXLeXdaArjGQfarTHU6+D7np1ls40/70ftfjEwBbW9OzPyuFj5l15yA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792475062; 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=SHP+ZuI0NbQryrK1GfspQZp3EZ/0jC5OKBRZ00AmRe4=; b=eLE45N+8dcEqJ+5rA7lByZI4TvHnVD7B1Huf4zLP4JMq+wRtmMEjWj6LQ6ysqRe2BN/N c02LOSV0p0GwQ2g7pV9dBv764ZnQtR0h9Cvnlya5dxGd2SGxkeRLMBt98sZrRv+Pnh7ar 8PfYwk7RZX3JVSh6jnOSVw57IMol6nZYHqKXpj99flqAe8oYRXtw6FLoS7NUh+mhSfx/J v/yyP2jk5+rY7uNrZRp7DGUWWQbcDA2DiQMCl8yE/gIA0m6pdkdC1C+nFiCu+jBLfjSWJ 40QAfw6Y1ns9wrNauUK6mnKSgF/9wmZsN4NZjcujem4bPMDddZtqBc8PrJhW49jzWpQ== 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=Bf71C4Si; 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 55E74606A319; Tue, 20 Oct 2026 05:44:20 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 55E74606A319 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 34F88207D8; Tue, 20 Oct 2026 07:44:18 +0200 (CEST) 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 4xHASxzx2J8G; Tue, 20 Oct 2026 07:44:16 +0200 (CEST) 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 C173D207D1; Tue, 20 Oct 2026 07:44:16 +0200 (CEST) X-DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com C173D207D1 X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1792475056; bh=SHP+ZuI0NbQryrK1GfspQZp3EZ/0jC5OKBRZ00AmRe4=; h=Date:From:To:CC:Subject:References:In-Reply-To:From; b=Bf71C4Si4GxTzbyRFtPWYQnCDAxNZIuWup4b5Cl8J6QTemD6eRKQKEF7TZpKSoGOG ObpQeH8Hdcswi74qFLN1pcReQUYX9FJ0c+Z5SZPIWsDu6T3eVCXLdJlPydlw7CAEiv /8O4JzKy0I4KdgNKtfm+V2rXc0BM6kA49P/QgxUCmE+1qXZN0g6pXlwUrZ6gNBdbiC LAREP9Sk1iFswRqAZExktnziJb9e8Wy/uoJCBOq1W4hGZjImf4T9gAcPXG6CytJnwB k6CRFptHT5Xsl6BsRt5Xgdr2elBRxRwQXJdhyzHJzuCqTajSFWWbr5wZHc3pX97DgD yPrZEsWaq9nzw== X-Received: from secunet.com (10.182.7.193) 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, 20 Oct 2026 07:44:15 +0200 X-Received: (nullmailer pid 2880014 invoked by uid 1000); Tue, 20 Oct 2026 05:44:14 -0000 X-CC: Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>, Jamal Hadi Salim <hadi@cyberus.ca>, Shuah Khan <shuah@kernel.org>, Sabrina Dubroca <sd@queasysnail.net>, <netdev@vger.kernel.org>, Yan Yan <evitayan@google.com>, Tobias Brunner <tobias@strongswan.org>, Florian Westphal <fw@strlen.de>, <linux-doc@vger.kernel.org>, <stable+noautosel@kernel.org>, Sashiko <sashiko-bot@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: <migrate-state-fixes-v5-0-d9d3d794553d@secunet.com> X-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de (10.32.0.171)