From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-10626.protonmail.ch (mail-10626.protonmail.ch [79.135.106.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88D6C1F471F; Mon, 16 Mar 2026 14:57:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.26 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773673027; cv=none; b=bKbStCyE8+GOAp1OJSLEy35SSawFqAQ9vCqhJ+27DQJxhA37GlRGQkmFUrOpHCBDjQXhctPVjjmflt42gDR8Ho2oL3kesv0XQHmmyKO0yVTWySwhKoWU0QS9H12nPFOFPbf95oW9bg3F6MSI2Egb6RjINKqKTEBMIggxuuFplCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773673027; c=relaxed/simple; bh=Y1ReUoDwMJO+LpydzwkDbXsa1KYgRtYo1UWlqvLRxbg=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=iLl/YXwVCyRwDMEOPBz88xya3YraQRhlutrTxv8l9JbfBkYoMJZSd38+FixtvLrtmt1UxJsSNkpneMqY/gRgZwUTTOu9foB1hbCv0YvFzEo6ZyuO05NRtx/PsMawtQIKY7LTJVXjylWz6mD+nGl08k0SjY0ebn4FotY0z+3/4mk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=1g4.org; spf=pass smtp.mailfrom=1g4.org; dkim=pass (2048-bit key) header.d=1g4.org header.i=@1g4.org header.b=rZW/B/xb; arc=none smtp.client-ip=79.135.106.26 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=1g4.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1g4.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=1g4.org header.i=@1g4.org header.b="rZW/B/xb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1g4.org; s=protonmail2; t=1773673016; x=1773932216; bh=Y1ReUoDwMJO+LpydzwkDbXsa1KYgRtYo1UWlqvLRxbg=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=rZW/B/xbv8RTkcBgZxlEZAs0uBgOsFuhBGzcEto8Mt6Ih3gPJj6gVIE7KRH85cejC TrkzWg6ubYRaYKCGwwjljnTi6/ZN8XB4x+cMoPAhdPlgeBYFof9Y4nQYZ0djrtRFpg OpTQlMqRekuDcL1F9V0Rrvw+lpcL/UnscYmxr2TBQQI1DReWP7f0fRlTaXhFxhIqHa Y3OxoaUZNvDhYmf8JFoNIltwWpUBy7cO8yOgVrZ3vuZS56nzs9KtphtniVg5tG6k4C HcONW2GaNzRFBYS9cqEosyH48gXZlvLKLsTALhFX98DGnLqxagutQMoYr0Nsxhu8Yx cCIz8uVSzJRQg== Date: Mon, 16 Mar 2026 14:56:51 +0000 To: netdev@vger.kernel.org From: Paul Moses 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, chopps@labn.net, linux-kernel@vger.kernel.org, Paul Moses , stable@vger.kernel.org Subject: [PATCH net v3] xfrm: iptfs: only publish mode_data after clone setup Message-ID: <20260316145642.4154656-1-p@1g4.org> Feedback-ID: 8253658:user:proton X-Pm-Message-ID: 47428d8ed8b1babe832c1a8256bc94242e64a3a3 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable iptfs_clone_state() stores x->mode_data before allocating the reorder window. If that allocation fails, the code frees the cloned state and returns -ENOMEM, leaving x->mode_data pointing at freed memory. The xfrm clone unwind later runs destroy_state() through x->mode_data, so the failed clone path tears down IPTFS state that clone_state() already freed. Keep the cloned IPTFS state private until all allocations succeed so failed clones leave x->mode_data unset. The destroy path already handles a NULL mode_data pointer. Fixes: 6be02e3e4f37 ("xfrm: iptfs: handle reordering of received packets") Cc: stable@vger.kernel.org Signed-off-by: Paul Moses --- Changes in v3: - Rebase on top of current ipsec tree net/xfrm/xfrm_iptfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c index 2c87290fe06c..7cd97c1dcd11 100644 --- a/net/xfrm/xfrm_iptfs.c +++ b/net/xfrm/xfrm_iptfs.c @@ -2664,9 +2664,6 @@ static int iptfs_clone_state(struct xfrm_state *x, st= ruct xfrm_state *orig) =09if (!xtfs) =09=09return -ENOMEM; =20 -=09x->mode_data =3D xtfs; -=09xtfs->x =3D x; - =09xtfs->ra_newskb =3D NULL; =09if (xtfs->cfg.reorder_win_size) { =09=09xtfs->w_saved =3D kcalloc(xtfs->cfg.reorder_win_size, @@ -2677,6 +2674,9 @@ static int iptfs_clone_state(struct xfrm_state *x, st= ruct xfrm_state *orig) =09=09} =09} =20 +=09x->mode_data =3D xtfs; +=09xtfs->x =3D x; + =09return 0; } =20 --=20 2.53.GIT