From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.67 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796022879; b=zHJ2P6thNioXblZTPVYjuHEa8zemsiJ7Z08zFRlgXy/xIC1i8MIoNuFlddC44aFUTsgQ eYhyiFj389nuGqCCbICgmIct9P+HCYy6a/3ZGXZvhVbvTH5e7106HzH7e5mwCrAot5ECW q2q2Ycbvje0uKMv799W9nEj3kMib/bKPzPFfG+oJSkfjvmz1gC1Pwf+IWfuhlvyi7urXi 4+ZDGaRh32kekjwTRtPDU+GrYBJMEX0vQvGbucefnHp5cRjLSDXaWGfklw5jt2AYmcNjI BDynqinvIpY+EmBDcjz9M+1B9laun5vH8FIzVEuhgavjD7oQCANXYKwy/evEkmj4D9w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796022879; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=cLUIoEtr0WrIaBZBAu0KYlxNywnr9wIV5UuUddK+XmU=; b=CDLy2mBHcnMqzWmSPhfdvquGXUJQTETrnvW6sasL2RvjP/3fZeSAZT5VfR3J2xiSdFeX 4gUtBAwsHiKa6fUkn0sVqWduMv7bOiMezvko2KZ6Anf/beJrT1YWnW91CEfYV+eKE6VmW HobfSpnm9RbK9IdarMMypUouY8aqK2y0kxeokN0CKvt5JF+rlH26Ti/YoB8Up4nRJpE2n f4nMbencrhxPgI6QCztZ0YaIYXnzvhxP2+GGvHVNsyyZubw9U/a4EMNBJmeuZ7Fvkw9uP Hz8aa/WcKOFqG/qXP00egPpIDtPDcLITmtLSRfnEKBalre4FWLJlRnKFy0MlRRIwq2g== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=aVNW6HLO; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.67 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011067.outbound.protection.outlook.com [52.101.57.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3528606A31C; Mon, 30 Nov 2026 07:14:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F3528606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=aVNW6HLO ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lHIXfEeiqBGdIDbdpOmT+OAk4aNx5Jsdl3JYOzm6TbeKvPD+MzyfX4FHlW78ZmNnc6f5vWPWentdygaQk0M1L8MNjxCnG2luxsfQMfuQ4uE+wgUO5XIayLVX59zqhz6G62ILDx0Zuys2XABdJvaBhEfak/cgCxenJylgPLxzR/Ws6Ujyg6IKHLc9k5OaoVY/ddIUhPqFJskkAVM4kKPmAzZ07e4HOHriK1wKA03wI/Zv4rVuekQsDBKBvPF8BjRpn33ZNd3CQIFQwlAe0JHP4QfRw2XOENElFuPJ9nq6WJR/JICwozFVXbFDPyQHvzRNM0i8FvNK5ll1BEgZUSz9Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cLUIoEtr0WrIaBZBAu0KYlxNywnr9wIV5UuUddK+XmU=; b=ym4L5H5gjPoHkEhz8RRXbyjJhjq9K0l415seEIbb5KD2Jmu0pDOyCBCxMUiy3qHtewooNI0sNcXkviKJzDhtRDu9p0qor89MmbTcieTITdmydIPEGqMeKlDOXmf5MI1WbQzPW6M2dxE0xhpgD3HO6cUJSZ96pQ3A0Skuu0IgM0UqY/SCO2iMuyPkyF9wLpMIbTitp7OOapHotRcQYVOyrbp7Y1S0yspBrtLZycgzyd/eDcS1YEjBJrMowgIi3AzHoVm0ZeNmv1k6U37vrn3WMGojHeUlnqFJwpDOgA9Ne7cl96df2FdUAbeHhcbSB5nerANDYiGnR2i519+F3M+nqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cLUIoEtr0WrIaBZBAu0KYlxNywnr9wIV5UuUddK+XmU=; b=aVNW6HLOVlBrDDmg+efkssMWsHtMwSvy+jtZWH9pMavhY4gzsbQtQyuMFxXvVB6yCORN4NSoCcAX8vnKkfGfCxTmou3WhnLMm8+zVVVlAQIy8E7GZ2VIm/IhGcAdgi/lG73OT33XV1g2GtpZhx9H+bUZ1IRmh4nGIOe1nDEKd2VWjFETAsxLtiWJemZgDik5Nrdl5Bms1umnpHmQoivId+QrcM0PkOBJiqv6xdXcwHgEpgGisLeOFFFxS6xJGogmqKUL2UVJ90w7+O/oWwEAuk7DfXWkiIugzLKyrgj8fuIlx/z7eJBWWLuDx6vc/h3E3G9ErHa56IOc1Pc3Jr2zfQ== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from SAVPR12MB999143.namprd12.prod.outlook.com (2603:10b6:806:4e5::21) by CY3PR12MB9555.namprd12.prod.outlook.com (2603:10b6:930:10a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Mon, 30 Nov 2026 07:14:34 +0000 Received: from SAVPR12MB999143.namprd12.prod.outlook.com ([fe80::219e:6553:2ec0:3761]) by SAVPR12MB999143.namprd12.prod.outlook.com ([fe80::219e:6553:2ec0:3761%4]) with mapi id 15.21.0662.007; Mon, 30 Nov 2026 07:14:34 +0000 Message-ID: Date: Mon, 30 Nov 2026 15:14:21 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net 03/10] net/mlx5e: Fix IPsec SA modify/stats update race To: netdev-bot+sashiko@kernel.org, tariqt@nvidia.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, willemb@google.com, parri.andrea@gmail.com, borisp@nvidia.com, cratiu@nvidia.com, eedmunds@nvidia.com, gal@nvidia.com, jmassar@nvidia.com, kuniyu@google.com, leon@kernel.org, linux-rdma@vger.kernel.org, mbloch@nvidia.com, phaddad@nvidia.com, raeds@nvidia.com, saeedm@nvidia.com, horms@kernel.org, sridhar.samudrala@intel.com, steffen.klassert@secunet.com References: <20261126215614.792598-4-tariqt@nvidia.com> <179581872820.3135.14479664745812927249@kernel.org> Content-Language: en-US From: Jianbo Liu In-Reply-To: <179581872820.3135.14479664745812927249@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2P153CA0039.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::8) To SAVPR12MB999143.namprd12.prod.outlook.com (2603:10b6:806:4e5::21) X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SAVPR12MB999143:EE_|CY3PR12MB9555:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d7652f7-85c0-4a78-15fb-08df4eb195ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|23010399003|10067099003|56012099006|5023799004|11063799006|261022115727099003|261022113327099003|261022105027099003|261022075727099003|261021135927099003|261021123027099003|261021121427099003|261021133027099003|261021130227099003|261026135527099003|261026121527099003|261026140227099003|261026130827099003|261028144727099003|261102123227099003|261009223027099003|18002099003|22082099003|4143699003|6133799003; X-Microsoft-Antispam-Message-Info: p+ampLmlvip8C1AOC10LqcfjSMhN5DvvvJ0hHBbdu6iZhcZE+Xyq63I2jVZTMF2D4qzVUVfzp1SXOQJk3Iw2e4UpWZ3kpkqzCfCEqcxUDLwigvycLxCBV8JIwEeeJPhgQL3MwXGI6oyCDJ5pIo2swbIayIS28Z9KnYR8bCxMXgKjTe8ep7Jqd20SFVvX923JDiqUjMDqLHwSVBi8mS1TSqTbhypTUhDGIVikjuKAQZOiYNZl0PxK36mM+jYpMoN6Z14f66FNDu3ZTKWN79dlfKWAukLYkmE8BGezjoXf9tr8y0ncc+/IzUTA2dSE8Nxr00wkzSzc15qwh2F8EtVSq87hD5OgdtugFURN+9tjimdWQdQpu0SqxQYnVFJdGfB5pfMNLSDMS+VM0f/hLzLUco0mJjN9LzbuLaCdp+aHOzIcS7Q2n9TwewAhl3MM5zZWmJ1ZfFSZ7b9YN/Xx7OpDh4FdHlsNpwHNlD8ImzcEmfopBM29y58FDhSVR/py+QLeMV/P60TxGgVg02wMWWkGR5zdnGmarINubkSZ28ATpHVYY1osw7FVKKzS2XincfVIzJzO785v5SIuEtKPTZXC/fIq7u9R+Tcx7QcifIhXwH7U3sdK3sJ8kT7a3FusuIgYsaWKnm6vk5HNFNccjXTdRXDnbi7nNH+8cNkyj/cEe1A= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SAVPR12MB999143.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(23010399003)(10067099003)(56012099006)(5023799004)(11063799006)(261022115727099003)(261022113327099003)(261022105027099003)(261022075727099003)(261021135927099003)(261021123027099003)(261021121427099003)(261021133027099003)(261021130227099003)(261026135527099003)(261026121527099003)(261026140227099003)(261026130827099003)(261028144727099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(4143699003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U1hPVnQ0RENMU2QzaGpaekhidzllTm9GcXRhWGJkQldGSUlqdi9NTEkrM3RX?= =?utf-8?B?c2FXS3cyTlFWVXdBZnhQcWZ6eWNyd1Z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WGpneGxpbDlIVlhh?= =?utf-8?B?dUxGT2NXb3c4RHhYcU5nVUVNUnpjcUwrNDRPK2FHQXZrbVdGU09JZFNyMEFx?= =?utf-8?B?M2NvbnNvdG5FV3ZlbHFIYVpDQzZKN0dQZHV5OGIyazdTQnYrVCtDSFFSZWli?= =?utf-8?B?VlByTjMwbVZ5Z2xMaWJxVnlHYlNFUDFXeEx3ZTIzenBiQ0dHZnZxRjJtV3E0?= =?utf-8?B?bVd5RHpXY282UjVLTjNNRWg0cmhKMjVwY2o4UjhOWm4xaXFneEttTWxhNTMy?= =?utf-8?B?VkNUOVZyYUlleHRQZWVMdmhGYWNkcWZvOXFEVHlGOC9ZdWhxNHdTQk82NEha?= =?utf-8?B?UVFBSVg4aHZINkJDZVB2VHFTb3liYUdzMURVQW5mQ3lFbGpsMWtCMSsxNmFT?= =?utf-8?B?VGhEZytscGw2dGtBUldXeVNVMGEvYmZZZ2Rvck9nTGxROGNmWmRTOTdabCtG?= =?utf-8?B?SG4reGVJM1R6Y2FDZ1psUGlQRktTdHRrYnM2NmtEd3ByTVFlY3hIUT09?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d7652f7-85c0-4a78-15fb-08df4eb195ce X-MS-Exchange-CrossTenant-AuthSource: SAVPR12MB999143.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 07:14:34.2443 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Dg7xTGnsvBewTMeFHQ+0+8AgtMqjXif0CCYbJEo1nGNv1tZ01DcOeg0PDhMLIKwH1ZAOXDgefdmVWE0J0CTHUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY3PR12MB9555 On 11/28/2026 6:32 AM, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issue(s) to consider. > > Critical: 0 · High: 0 · Medium: 1 (3) · Low: 1 > > If you believe none of the issues are legitimate, please reply to each > issue of Medium severity or higher and explain why the AI is wrong. > If any of them are legitimate and you plan to respin, please let patchwork > know by including "pw-bot: cr" as a separate line at the end of your reply > (one such reply per series is enough). > > - [Medium] This patch moves rx_mapped_id into struct mlx5e_ipsec_rule, so > the existing `memset(&sa_entry_shadow.ipsec_rule, 0, ...)` in… > - [Low] The commit message does not match the code. > > Pre-existing issues: > - [Medium] Baseline decision is false: the last patch in the series fixes > this. > - [Medium] Baseline decision is false: pre-existing, medium severity, and > not claimed or relied on by this patch. > - [Medium] Baseline decision is false: the last patch in the series fixes > this. > > -- > > net/mlx5e: Fix IPsec SA modify/stats update race > > This commit moves the eswitch RX mapped id from struct > mlx5e_ipsec_sa_entry into struct mlx5e_ipsec_rule. It also changes > mlx5e_accel_ipsec_fs_modify(): the new rule is now swapped into > sa_entry under x->lock and the old rule is deleted afterwards. Before, > the old rule was deleted first and the whole shadow entry was memcpy'd > back. > >> Fix that by: >> - moving the eswitch RX mapped id into struct mlx5e_ipsec_rule so >> everything related to rule creation is in the same struct. >> - swap the pointer to it under x->lock to avoid the race. > > [Severity: Low] > Is "swap the pointer" accurate here? ipsec_rule is an embedded member, > not a pointer: > > struct mlx5e_ipsec_sa_entry { > ... > struct mlx5e_ipsec_rule ipsec_rule; > ... > }; > > So swap(sa_entry->ipsec_rule, sa_entry_shadow.ipsec_rule) copies the > whole struct by value. That covers the flow handles, modify_hdr, > pkt_reformat, the four mlx5_fc pointers and rx_mapped_id. It is a > multi-word copy, and only readers holding x->lock see it atomically. > > The message also doesn't mention that the old write-back was removed: > > memcpy(sa_entry, &sa_entry_shadow, sizeof(*sa_entry)); > > Without it, attrs, esn_state, limits and ctx are no longer reset to the > snapshot taken at the start of mlx5e_accel_ipsec_fs_modify(). That > looks harmless, since the add_rule paths only write ipsec_rule fields. > > Could the commit message describe both of these more precisely? > >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h >> index f4b2d7b950c00..9bbcd9e4c3197 100644 >> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h >> @@ -215,6 +215,7 @@ struct mlx5e_ipsec_rule { >> struct mlx5e_ipsec_drop replay; >> struct mlx5e_ipsec_drop auth; >> struct mlx5e_ipsec_drop trailer; >> + u32 rx_mapped_id; >> }; > > [Severity: Medium] > Now that rx_mapped_id lives in struct mlx5e_ipsec_rule, does the > existing memset in mlx5e_accel_ipsec_fs_modify() also clear the > shadow's mapped id? > > mlx5e_accel_ipsec_fs_modify() { > ... > memcpy(&sa_entry_shadow, sa_entry, sizeof(*sa_entry)); > memset(&sa_entry_shadow.ipsec_rule, 0x00, sizeof(sa_entry->ipsec_rule)); > > err = mlx5e_accel_ipsec_fs_add_rule(&sa_entry_shadow); > if (err) > return; > ... > } > > rx_add_rule() only allocates a new mapped id when the SA is not in drop > mode: > > if (!attrs->drop) { > if (rx != ipsec->rx_esw) > ... > else > err = mlx5_esw_ipsec_rx_setup_modify_header(sa_entry, &flow_act); > > Consider mlx5e_ipsec_handle_sw_limits() setting attrs.drop = true and > calling mlx5e_accel_ipsec_fs_modify() for an RX SA on rx_esw. > mlx5_esw_ipsec_rx_rule_add_match_obj() then builds the auth, trailer > and replay status drop rules with metadata_reg_c_1 == 0. Before this > patch, the modify path reused the SA's existing unique id. > > On rx_esw, reg_c_1 is the only per-SA field in those matches. Every > drop-mode SA therefore ends up with identical FTEs that use > FLOW_ACT_NO_APPEND. SAs added in drop mode because the neighbour was > unresolved already had id 0. This patch extends that to every SA that > hits hard expiry. > > Under HW steering, mlx5_cmd_hws_get_capabilities() doesn't report > MLX5_FLOW_STEERING_CAP_DUPLICATE_MATCH for FDB. add_rule_dup_match_fte() > then allows only one duplicate: > > if (!list_empty(&fte->dup->children)) { > mlx5_core_warn(get_dev(&fte->node), > "Can have only a single duplicate rule\n"); > return ERR_PTR(-EEXIST); > > Suppose two or more drop-mode SAs are already installed on rx_esw. Can > rx_add_rule() then fail for the expiring SA? If it does, > mlx5e_accel_ipsec_fs_modify() returns silently. Software has > attrs.drop = true, but the hardware keeps the old decrypt and forward > rule until the state is freed. The id is 0 for a drop-mode rule, but the rule add cannot fail for that reason. rx_esw is used in switchdev mode only, and there packet offload is supported with DMFS only, not with HW steering. The id 0 rules also match no packet. A drop-mode SA forwards nothing to the status table, and the ids of the other SAs start at 1. > > [ ... ] > >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c >> index 0facc54771558..d0f738fdeff3d 100644 >> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c >> @@ -2845,8 +2845,11 @@ void mlx5e_accel_ipsec_fs_modify(struct mlx5e_ipsec_sa_entry *sa_entry) >> if (err) >> return; >> >> - mlx5e_accel_ipsec_fs_del_rule(sa_entry); >> - memcpy(sa_entry, &sa_entry_shadow, sizeof(*sa_entry)); >> + spin_lock_bh(&sa_entry->x->lock); >> + swap(sa_entry->ipsec_rule, sa_entry_shadow.ipsec_rule); >> + spin_unlock_bh(&sa_entry->x->lock); >> + >> + mlx5e_accel_ipsec_fs_del_rule(&sa_entry_shadow); > > [Severity: Medium] > This is a pre-existing issue, but does taking x->lock here fully close > the race the commit message describes? > > mlx5e_xfrm_update_stats() accepts other locks instead of x->lock: > > lockdep_assert(lockdep_is_held(&x->lock) || > lockdep_is_held(&net->xfrm.xfrm_cfg_mutex) || > lockdep_is_held(&net->xfrm.xfrm_state_lock)); > > Some callers hold only xfrm_state_lock or xfrm_cfg_mutex: > > xfrm_state_update_stats() /proc/net/xfrm_stat, xfrm_state_lock > -> xfrm_dev_state_update_stats() > -> mlx5e_xfrm_update_stats() > > copy_to_user_state() SA dump under xfrm_state_lock, > xfrm_get_sa under xfrm_cfg_mutex > -> xfrm_dev_state_update_stats() > -> mlx5e_xfrm_update_stats() > > The following sequence looks possible: > > 1. Such a reader loads an old ipsec_rule->fc (or auth.fc, trailer.fc, > replay.fc) pointer. > 2. The worker runs mlx5e_accel_ipsec_fs_del_rule(&sa_entry_shadow), > which calls mlx5_fc_destroy(). > 3. The reader's mlx5_fc_query_cached() then reads and writes > lastbytes/lastpackets on the freed mlx5_fc. > > The same race existed before this commit. The last patch in this > series, "net/mlx5e: Create IPsec flow counters once per SA", moves the > counters into sa_entry->fcs[] and stops destroying them in del_rule. It > is still reachable at this commit, though. Right, the last patch closes it. The callers that do not hold x->lock can be changed by the patch I submitted seperately: "xfrm: Serialize offload stats updates with x->lock" > > [Severity: Medium] > This is also a pre-existing issue, but are counter deltas lost here? > > mlx5e_accel_ipsec_fs_del_rule(&sa_entry_shadow) destroys the old > ipsec_rule.fc, auth.fc, trailer.fc and replay.fc without a final > mlx5_fc_query_cached(). Any delta gathered since the last > mlx5e_xfrm_update_stats() never reaches x->curlft.packets/bytes or > x->stats.integrity_failed/replay. The replacement counters start at > zero, so each neighbour update or expiry rebuild under-counts the SA. > > The same later series commit, "net/mlx5e: Create IPsec flow counters > once per SA", keeps the counters in sa_entry->fcs[] across rebuilds. Its > commit message says it fixes these lost counter values. Yes, until the last patch, which keeps the counters over a rule rebuild. > >> } > > [ ... ] > >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c >> index f8c97954b6eaf..2615bbc89a16d 100644 >> --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c >> @@ -85,7 +85,7 @@ int mlx5_esw_ipsec_rx_setup_modify_header(struct mlx5e_ipsec_sa_entry *sa_entry, >> goto err_header_alloc; >> } >> >> - sa_entry->rx_mapped_id = mapped_id; >> + sa_entry->ipsec_rule.rx_mapped_id = mapped_id; > > [Severity: Medium] > This isn't a bug introduced by this patch, but does rx_add_rule() leak > this mapped id on its later error paths? > > Once mlx5_esw_ipsec_rx_setup_modify_header() succeeds, it has allocated > an id in ipsec->ipsec_obj_id_map with xa_alloc_bh(). Later steps can > still fail: setup_pkt_reformat, mlx5_fc_create, mlx5_add_flow_rules, > and the sa_sel, replay, auth and trailer rule creation. Those failures > unwind through err_add_flow, err_add_cnt, err_pkt_reformat and > err_mod_header. These labels free the modify header but never erase > the xarray entry. > > mlx5_esw_ipsec_rx_id_mapping_remove() is only called from > mlx5e_accel_ipsec_fs_del_rule(). In the modify path the id is held only > in the on-stack shadow, so it is lost for good when this returns: > > err = mlx5e_accel_ipsec_fs_add_rule(&sa_entry_shadow); > if (err) > return; > > The same leak existed with sa_entry->rx_mapped_id, and it is still > present at the end of the series. > >> flow_act->modify_hdr = modify_hdr; >> flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; >> > > [ ... ] > Yes. That is fixed in net-next by commit a6e391baedf3 ("net/mlx5e: IPsec, Fix RX mapped ID leak when adding a rule fails").