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.53.59 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796032917; b=bgGBtTFZ+rpVy5lCfJ4NCe9wUxJb4utl0nWZcAqSHmydYLTclsZzaG5uYfAemrI/e+6c x/sNCy81cSEwWOtWLBUliq3ESLIsyp4F4CE4MudR8rhoy0mPBBI8rMm7dVLMA3Q/Jnqzy HE8hI6ULKAk3vK/bUJqf5EBJ1Bkf88l48CG+Ck+8+3GKghAJrks+0sCdDdyWK8Vrcaob5 51OXLLSKT0Kdgca63hFmigSnIdEiveMLtlKDWSbGIkm00czLAZSaWgJkfSOi1J7Hf7FeG 61rbmpBlQ+TiG0a/k1PDwyURCM476O+0ai1oxCrmYgIiD+SSMdx4dokqSkPod/+N4dA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796032917; 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=hrGp7f9W3Sj/V6v6a5/yKnXn1baaU/dqx9GDaT5Sqgo=; b=LD9r259IqQclGJYqB6ogDfvTHPW2B4Z9MnjvQm0Sm1bxqilgK6d7VsJr0jBBvTPmtSOu v0eu0M3t1c6Mnr8qT/8k8FT+iPz5Zl12S0hFRF6J3/mN8EJqVustgWm0Styyy3tNo9LFC J5QZdvjNzNRkB066rKb0J35/DXAy9u+lWzyNrA1CUlL5ZLccRwFAnYNdbgbdDbp2xrytH VTT9WADjLmNpA9jvAYnjlIcOvE9Mk40HXagO2gVamk6Cf9mOw7sB3M7dXRtxjDVN01rw2 crZmse1G0AzSeXTg3E3OI+CZpqbTeClBSqR01qbXff7+N0ACywBaaIolwFo8pwzGE9A== 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=Y6eLW1+N; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.53.59 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012059.outbound.protection.outlook.com [52.101.53.59]) (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 BF0F6606A31C; Mon, 30 Nov 2026 10:01:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BF0F6606A31C 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=Y6eLW1+N ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vj8zyZqT4e0SmAMcRb/DudYCcY9jzL2jcbXmRauaWZhLYd6jsbtE5z+wgPYUNamVd+UefJVcYUD55QeTLV0QANKIn7QqDCznbNkEQAiOY1f3LHOOetLwuxoVnl1ECTeu7mynRtQMpIVUd8cg4GTKwF25ltoYhBALHgz3XILvfsBRo6QC7Lqi/qCc1CFkHxp7BR+RNWY0fnv3VMbbRhhG/FIcQuWJeZrFlwYu2bYbTG0Fp/9k4HGDJwbM+0fwG8EDfz9szrj1XX9x756LkawKcUgE3OzSkuZ94Nln6QHx5HJz1bHaQZYo29v2+dcrpPBCih/x1sYs328QOVkdrCTAfA== 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=hrGp7f9W3Sj/V6v6a5/yKnXn1baaU/dqx9GDaT5Sqgo=; b=FaJrzEnSGlFMoYcx38m5wAlAY0qqQjXO5tk++tYfBNhHU/MpX0SUK4LAQhSO0CtlUfN3naT7hDM0BhTv2hr313Lz9wRPxiw1cJ2SVZrB9kgclb4buEAIs7jb3k5JRPpQqkpYZuH2c3rm/zH9ceNkTiSDjMzXitwnS+FQpaA9dQtQH87jIZp8JJQxwiVdT9w+Fd1WsrR1m1g2Jz9uc0hSAp1OLMjgkD2N1C0QMndJ67+zLlpITXO5aDsQM1wOmR16nMocFmoS2BY62v1oS3BcW9bz+TgOCF3aS1ridtIdJ3Db/LpJlpsyoWW+/sIUk9I95fBsaruMQz2zjo/fZlmtGw== 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=hrGp7f9W3Sj/V6v6a5/yKnXn1baaU/dqx9GDaT5Sqgo=; b=Y6eLW1+Nq/b1oNWPNSsrtkHxlyUXPgEsBi145D4lsYCY6zuOJl0uISlzcLx+jXrUb5HJI/e33lz8rIShz9OqAeAMS3Srh0wrrHr7+a06Enxj9W0U4UNVr6wAiIrRJQfjDKqqNhNUgGmo2Mt6nzDJ2EwOcbrkPPN6bUqAZgdEYXdTapG0Ghb8p+HWG4AZzjuCB3KdnMyEifURvtR8h7EUH2f02mHNrjB8FEYc2IICmDfceon9Mec54KaIILFNWUlHYLMaTIVpvT8UjZKrW1r1dsfjFtoNIBuoPPsmZw/9SmwHsT7uVg5I8NAme5r1o8KmrsD7amLsi+T1BUgN7Ds6LQ== 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 IA4PR12MB616689.namprd12.prod.outlook.com (2603:10b6:207:12a::10) 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 10:01:53 +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 10:01:52 +0000 Message-ID: <2646b595-be84-4c0a-8cfb-87e0b64630e5@nvidia.com> Date: Mon, 30 Nov 2026 18:01:38 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net 08/10] net/mlx5e: Validate neighbour events before updating IPsec SAs 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-9-tariqt@nvidia.com> <179581873585.3135.8443874889177753516@kernel.org> Content-Language: en-US From: Jianbo Liu In-Reply-To: <179581873585.3135.8443874889177753516@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2P153CA0001.APCP153.PROD.OUTLOOK.COM (2603:1096::11) 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_|IA4PR12MB616689:EE_ X-MS-Office365-Filtering-Correlation-Id: cb40bd6b-abef-4d78-e895-08df4ec8f531 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016|23010399003|5023799004|4143699003|11063799006|261009223027099003|22082099003|18002099003|3023799007|10067099003|56012099006|261028144727099003|261026135527099003|261026130827099003|261026121527099003|261026140227099003|261022113327099003|261022105027099003|261022075727099003|261102123227099003|261021121427099003|261022115727099003|261021123027099003|261021135927099003|261021133027099003|261021130227099003; X-Microsoft-Antispam-Message-Info: oqTrJiTZPvPmCR27M7IXmEtz+e75RZvu0qCgEvmsSq2AgXfwcsnRBH+ccQf3Um4+veScBlqJMKXPzzFD7xmxWxWxQjBQWWUz9Eyh5hRwm8EXelZffo9xAW42z22jeohPUkAQa0k6XuxMjwYo2gPnVI+geE59Q3swgONTEat+qU2aEE8mRKNysPPgBOf1dTiZ2O3qZQT++WvqSYMCVuEtln+v40+vHkNZkzefPM3No8rDPj8HPAvPISQMgOMTAXZpYQ8Hwg51YxFdmb3mFTk1Rh4LV0Qm2XSb2a/FtvmNJRpj/5ThZOvwrTzr45CieI7ophr85yVZzDOjaF6v7Hj31DdsXAT2sHqwWkezH1Ixpj1W6LM34azAA6xYT2l/uXUUbV1KEc/toXrfwLRSKAH9ETUntG+wPPrIUlSO2aMZ8DI8MN+aWEV/FDJvZzD4ONmSkHw6CVpx4jiV/4wTYb86fMWhY2RIOe6U9tHwZM0M1ma4+lmGs9Rv5BdJbaox9KIYro0NWl/EIXSOvPueVk/cDNncWmSbnBWiHKEGRNVetON9wJ0gFIrFTYYiH60yAHR2zYvmt9IrCdyabzUo5H4lwZFLG7yKmVgOyvO94cdMsiG+GW1c+EhtbJeq13hF5RjubQ2uEgPdtSyYnDdZhyMxadozTRkSJHa+Wz2lQ+jST/w= 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)(7416014)(376014)(1800799024)(366016)(23010399003)(5023799004)(4143699003)(11063799006)(261009223027099003)(22082099003)(18002099003)(3023799007)(10067099003)(56012099006)(261028144727099003)(261026135527099003)(261026130827099003)(261026121527099003)(261026140227099003)(261022113327099003)(261022105027099003)(261022075727099003)(261102123227099003)(261021121427099003)(261022115727099003)(261021123027099003)(261021135927099003)(261021133027099003)(261021130227099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Rm11OHVLS2kzWHhod2tRVzRsUkovWUNoWDdQRkNONTF6dzJ1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VZkS3pWRnplQjhNZ1hpOFYzdmZY?= =?utf-8?B?WG83NkVIS2pyQUorTG1wdmZtcG5xR1BPUVJzVmVjaGI3b1ZHQSs5Sld6MTE2?= =?utf-8?B?RjIwOXF4NjNybFF1UTZNQm4yRk9XdVphanh3MHkyWWFSc2ZNT0Zxa3Jaa0Ru?= =?utf-8?B?a0tZcE9oMmdTSk5qYVdKcnFvQVBFWWFGdHZiSU9qWml5cjVzWXcyQjZWSzVZ?= =?utf-8?B?Zjk5dzlzdzMzL0g0QmFhMC9RbjhQamNBQ0FWT1llYmxXWTNUTDdlOVhEblEy?= =?utf-8?B?eklQb3VYYTY2UWFaZ3I1WHBPYUtHY3pSS2NEWUt5aXppSUZzcEpRa2FVTXFk?= =?utf-8?B?RVdxUFpqZUJjTFIwcXM2SHpMY2ZnQnhnVm1kM2RWUk5NUkg1L1NYOXQ0VzNv?= =?utf-8?B?N0s4S25FU3FVRUNJdGhCSHAxUFhQTzBteGJNcXF4UEdzWFpacVA2MkVYQnlt?= =?utf-8?B?RGo1T3BZdUJCZktqemJ0dEc4UHlyMmp2TFZYdEZzSEZFMTBMM1p4dz09?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb40bd6b-abef-4d78-e895-08df4ec8f531 X-MS-Exchange-CrossTenant-AuthSource: SAVPR12MB999143.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 10:01:52.4961 (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: wXDfVWE/1qbaOrKEu9N//KoDrJOHHbwDr4OrwNM3xfBsLtFbcHWHEFcCiOwbWJoC3UJDsdxmKNfF6R/J7qVipA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA4PR12MB616689 On 11/28/2026 6:32 AM, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue(s) to consider. > > Critical: 0 · High: 0 · Medium: 1 (1) · Low: 0 (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] With nh.ifindex == 0, a foreign neighbour on any device in the > same netns can still overwrite the hardware MAC. > > Pre-existing issues: > - [Medium] In the route-resolved branch of mlx5e_ipsec_init_macs(), > dst_neigh_lookup() can return an unresolved neighbour with an all-zero… > - [Low] In this commit, the per-SA MAC buffer work->data->addr has no > synchronization. > > -- > > net/mlx5e: Validate neighbour events before updating IPsec SAs > > The patch stops matching neighbour events against the SA source and > destination addresses. Instead it saves a snapshot of the resolved nexthop > (neigh table, ifindex, key) in mlx5e_ipsec_init_macs() and matches events > against that. The ifindex is saved only when the nexthop device is the SA's > offload device (xso.dev); otherwise 0 is saved and any device in the netns > matches. > >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c >> index 4084f8a88695b..cc75fcb0aa152 100644 >> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c >> @@ -256,6 +256,17 @@ static void mlx5e_ipsec_init_limits(struct mlx5e_ipsec_sa_entry *sa_entry, >> attrs->lft.numb_rounds_soft = (u64)n; >> } >> >> +static void mlx5e_ipsec_set_tnl_nh(struct mlx5e_ipsec_sa_entry *sa_entry, >> + struct mlx5_accel_esp_xfrm_attrs *attrs, >> + const struct neigh_table *tbl, >> + const struct net_device *dev, >> + const void *pkey) >> +{ >> + attrs->nh.tbl = tbl; >> + attrs->nh.ifindex = dev == sa_entry->x->xso.dev ? dev->ifindex : 0; > > [Severity: Medium] > If the nexthop device is not xso.dev, nh.ifindex is saved as 0. > mlx5e_ipsec_neigh_matches() then treats 0 as "any device": > > (!attrs->nh.ifindex || attrs->nh.ifindex == n->dev->ifindex) && > > In that case, can a foreign neighbour on another device in the same netns > still overwrite the programmed MAC? > > This looks like it always happens in the bonding fallback path. > bond_ipsec_add_sa() calls: > > real_dev->xfrmdev_ops->xdo_dev_state_add(real_dev, xs, extack); > > so mlx5e_xfrm_add_state() sets sa_entry->dev to the slave, while xso.dev is > the bond. The neigh: and IS_ERR branches of mlx5e_ipsec_init_macs() pass > that slave netdev, so ifindex 0 is saved. The route branch ends up the same > way whenever the route's output device is not xso.dev. > > For example, a container behind a host-side veth could send an ARP request > with sip set to the nexthop IP and tip set to a host address. > arp_process()->neigh_event_ns() then creates a NUD_STALE neighbour on the > host veth and raises NETEVENT_NEIGH_UPDATE. > > The table, the wildcard ifindex and the key all match. neigh_ha_snapshot() > copies the attacker's MAC, and the worker reprograms the TX dmac or RX smac. > > The commit message documents the ifindex 0 trade-off. However, this looks > like the case it describes as fixed: > > "a foreign neighbour (veth, other netdev or netns) sharing the SA > address overwrites the programmed MAC" > > The only difference is that the nexthop IP is the target instead of the SA > IP. > > Would a tighter match close this? For example, n->dev could be accepted > only when it is xso.dev or the nexthop device, instead of using a wildcard. > This idea is possible. But it closes the bond case only. For a device that only carries the route it leaves one corner: nothing removes the SA with that device, and its ifindex can later go to a new device. That is why the patch saves no ifindex for such a device. Closing that corner as well needs a netdevice notifier, or a new route lookup on each event. It can be done as a separate patch on top of this fix. >> + memcpy(attrs->nh.key, pkey, tbl->key_len); >> +} > > [ ... ] > >> @@ -360,6 +372,7 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, >> if (attrs->dir == XFRM_DEV_OFFLOAD_OUT && >> is_zero_ether_addr(addr)) >> neigh_event_send(n, NULL); >> + mlx5e_ipsec_set_tnl_nh(sa_entry, attrs, n->tbl, n->dev, n->primary_key); > > [Severity: Medium] > This is a pre-existing issue and was not introduced by this patch. Should > the route branch of mlx5e_ipsec_init_macs() set attrs->drop while the > nexthop MAC is still zero? > > dst_neigh_lookup() can return an unresolved neighbour whose ha is all > zeros. For IPv4, the route's neigh_lookup creates one if it is missing. > This branch already checks for that with is_zero_ether_addr(addr). > > The zero address is still copied into attrs->dmac (OUT) or attrs->smac > (IN), and attrs->drop stays false. > > The TX rule adds MLX5_FLOW_CONTEXT_ACTION_DROP only when attrs->drop is > set. setup_pkt_tunnel_reformat() copies attrs->dmac into the encap header > as is: > > ether_addr_copy(eth_hdr->h_dest, attrs->dmac); > > Until the neighbour resolves and the netevent worker reprograms the rule, > could encrypted tunnel frames go out with destination MAC > 00:00:00:00:00:00? > > The fallback branch sets attrs->drop = true for the same unresolved state. > So does the IS_ERR case added by "net/mlx5e: Drop IPsec tunnel traffic if > the neigh cannot be created". > > The problem is still there at the end of the series. This patch does make > the window shorter: gateway events now match, so the rule gets reprogrammed > once the gateway resolves. > >> dst_release(rt_dst_entry); >> neigh_release(n); >> return; > > [ ... ] > >> @@ -988,21 +1018,9 @@ static int mlx5e_ipsec_netevent_event(struct notifier_block *nb, >> >> ipsec = container_of(nb, struct mlx5e_ipsec, netevent_nb); >> xa_for_each_marked(&ipsec->sadb, idx, sa_entry, MLX5E_IPSEC_TUNNEL_SA) { >> - attrs = &sa_entry->attrs; >> - >> - if (attrs->addrs.family != n->tbl->family) >> + if (!mlx5e_ipsec_neigh_matches(sa_entry, n)) >> continue; > > [ ... ] > >> data = sa_entry->work->data; >> >> neigh_ha_snapshot(data->addr, n, sa_entry->dev); > > [Severity: Low] > This isn't a bug introduced by this patch, but nothing synchronizes access > to data->addr here. mlx5e_ipsec_netevent_event() writes it from the atomic > netevent chain. mlx5e_ipsec_handle_netdev_event() reads it from the > workqueue and programs the result into hardware: > > ether_addr_copy(attrs->dmac, data->addr); > > Can a worker that is already running read a torn MAC while the notifier > rewrites the buffer? With the ifindex 0 wildcard, two notifier calls on > different CPUs could also write the buffer at the same time. > > The next patch in the series, "net/mlx5e: Serialize IPsec netevent MAC > snapshots", appears to fix this. It adds a spinlock_t to struct > mlx5e_ipsec_netevent_data and takes spin_lock_bh() around > neigh_ha_snapshot(). The worker then copies data->addr into a local buffer > under the same lock. >