From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (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 250AB379991 for ; Mon, 23 Mar 2026 08:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.96.220.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774254902; cv=none; b=D2ivEkvAYajlCJuKzMtWGb9caP/hj2LYVJC0nvNYBaPLpBcHfkF9KoFYLowWaEab73SjQHb4RSYhJotkZsGCEsfbfMe2PAU3lqiX5cAKxAOH/oUgC47Ozr8y7mA02cME0esO6UWwbK1TiUHfSuEZrhyagsrUvFwobkzLC9fQPXY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774254902; c=relaxed/simple; bh=3j+XZrCFIPBDHW6Yu2JsEsxSSdjtvt3Jjns1Q1JxkYQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gQrrw0mV8gQ6B5tcYcfXcaLHG4EyGXmyG8DP5uq2/qth3B6wG/Dt4ozuVJ9HHgyBl0OF3hQP2WeXihVAsT8edY9ZQqcbMcTuzUyUGxsgqU+RDVF23flXXpKepr57wLrViy1McZBQe3upJr/aHwUDzRrQu2FpOxUXPM1axOsiAzQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b=HAJ5Lmc8; arc=none smtp.client-ip=62.96.220.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b="HAJ5Lmc8" Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id 40B81207BE; Mon, 23 Mar 2026 09:34:57 +0100 (CET) X-Virus-Scanned: by secunet 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 YcNHnYt_YkeB; Mon, 23 Mar 2026 09:34:56 +0100 (CET) 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 9C566207AC; Mon, 23 Mar 2026 09:34:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 9C566207AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1774254896; bh=N40GMO+OpI+C4m6aX++wL5AB3kryyXyFA1RbY2LB0ag=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=HAJ5Lmc8G6cyq0uoEEpxpxhJCm9OmGWHx/Ngf6Cy00v5HOzjC0V/6V4/1VWEzbwPD 3RdyqRGmIkH37lz+XgX6QODqk/X9vw5Uar3RTztPGNN9lgXPZy2OVUr9md2kjoQZeT evFnEyCAKh7KsV7w4P38bpCVRVzNVcfrdXM1e8OFrToLSp0GNxH/tVuZ+Sd3tGQ9y6 UTHrauyLk/tNrj2PkHefQ/hxgaYIC6svUiesUrMVdpA4oMTyNTtTc8CKZ5k/w/Hy+c jaLpCpuJR+62aC7JgvUYQHf/G+srsQQ21cIu0V/kWFGF0vresBzBcFRaZvbxBQyFdC rn9znHNaPsz1g== 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.17; Mon, 23 Mar 2026 09:34:56 +0100 Received: (nullmailer pid 2741857 invoked by uid 1000); Mon, 23 Mar 2026 08:34:49 -0000 From: Steffen Klassert To: David Miller , Jakub Kicinski CC: Herbert Xu , Steffen Klassert , Subject: [PATCH 20/20] xfrm: iptfs: only publish mode_data after clone setup Date: Mon, 23 Mar 2026 09:34:01 +0100 Message-ID: <20260323083440.2741292-21-steffen.klassert@secunet.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260323083440.2741292-1-steffen.klassert@secunet.com> References: <20260323083440.2741292-1-steffen.klassert@secunet.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EXCH-03.secunet.de (10.32.0.183) To EXCH-01.secunet.de (10.32.0.171) From: Paul Moses 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 Signed-off-by: Steffen Klassert --- 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, struct xfrm_state *orig) if (!xtfs) return -ENOMEM; - x->mode_data = xtfs; - xtfs->x = x; - xtfs->ra_newskb = NULL; if (xtfs->cfg.reorder_win_size) { xtfs->w_saved = kcalloc(xtfs->cfg.reorder_win_size, @@ -2677,6 +2674,9 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig) } } + x->mode_data = xtfs; + xtfs->x = x; + return 0; } -- 2.43.0