From patchwork Fri Apr 19 01:17:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 13635567 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2085.outbound.protection.outlook.com [40.107.237.85]) (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 587E665F; Fri, 19 Apr 2024 01:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713489478; cv=fail; b=lh6Nl4ODOtvCektt6fI0gNfxYd5G7lWbzx1IX8/A3J6V5mmGngty+ZtQ7f3FabjNAS2w6tLqUl/nsSq86/5475ZezwRqd8P8lCk/b8MjQkpBokjHa483Wu5AeWKSxy4HgL3ssqLJ04/2E4K8DTBvqplG+ay34AV1jCH9HG//YKs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713489478; c=relaxed/simple; bh=q7axH4c4s2UH7QepCkZuLb+yoSmmHF8NhxmJw505bgo=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=pTEqWqyqouHz22V2RM9E0iFJajLeIBguF5zDsXASHxG23hzgnisgaBVmE0cn1ERzfle/dvY/tldBJfe3FJIU7T9zM3vlzWURrplBjdGuMnbX9G4sUZN/sh5bTt9kildjUMGidgPQ8ss6Ypqaf0NBk7Oz7yLOnquyf9zHUJp61wI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=O8+iJEe1; arc=fail smtp.client-ip=40.107.237.85 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) header.d=Nvidia.com header.i=@Nvidia.com header.b="O8+iJEe1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kzjHgm/bDVy/GuPDTek3wTLOK+Qw9W7CLp8G0NdDuivIswoyvC1zzA2NnPgUpne6J6zn/y9RBkSujcQUaCeQAsKbsuMTiW3EY80shSN65YA0QdJ2UfFvVwcBz7zDx81B2h2Ckymlg9SlWM/1f5FSd0ZHwzb0aoE0WqR7pSlCVgC6mcGNx9yfgUGsATsS2pBExa1eZ/bmlbLhGKwFQZMHYr+xFOxSiBuY5gQOJXgBpY1cNSxZ3rsxcIJRa+k2jkhdSKuZnE9a02whYt3lwBhvexUxjbzrEE+hCZPmuO3GEUNO3GXDeg1xLLqKH1Cy3/oRUO9qH1TrSymHIb9mqtHkBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Y7vz5cTvvbYDbhMDWjNpseEU7LYS8QqfZHzHqd7wMH0=; b=W8iM34CfxALIi0KO/pPU5odTaamOF2FpKqaHruIJM6Sf+Y1UbJ2ql6Sz1iEBPjcuqlaPs6Mo37R+XV3H21xz9SEBgThKUbrlxLneyd5QUHc5K6apF1lS+bqPU8HZWzZSmEMGZX7fH5kDxIl9V2HLM5SU1Z4JzOCccXaHCDksn14Z4Sz0pSeGZebNkJYVXQEmZMop12WBDUjJF58AN7CEhrZc4zbZVUy9LR9vvEijv1PuFV2NUEvW5bttjyJMUwhuUzGCt5IDImX9mJfbpd+FccK0rlvERrjmhsVA5nqzGPPzENbpgrTamG0nJ6iGa4fcWg60fn/s1mj1GoqVj5Ktkw== 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=Y7vz5cTvvbYDbhMDWjNpseEU7LYS8QqfZHzHqd7wMH0=; b=O8+iJEe1OnigwDYmUr8BT39eYwDht/AZopJRKDmRZXKYO/k7Tpqi3X8n3Mio3hz4xisvACExkNRiwacOPQ5PI7V2x6sV9EqRE6F/piyGVNUXaKhgapAV+HSn0BsrxbqPe3JVSVReYU68iCiUKaVKO0kvj+8XDUK48jUcnzySwZxC/AwtXesjA6vDw1NdGw8MwfCR1uTRGsxhgzpEu4CG+qZ19lh5dQK3KflWpQaaRqOLJZdpShKql7uvwUGDiswxIEbjPReRTBCKJNlZdjTKf/4wgjb71P3KBq41XfXFZaPD428MhOVI/+C8OyoGRuqvxz+8+ZEfGKTp7C80Aej4ZQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by DS0PR12MB6656.namprd12.prod.outlook.com (2603:10b6:8:d2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.41; Fri, 19 Apr 2024 01:17:52 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::3ec0:1215:f4ed:9535]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::3ec0:1215:f4ed:9535%4]) with mapi id 15.20.7452.049; Fri, 19 Apr 2024 01:17:52 +0000 From: Rahul Rameshbabu To: netdev@vger.kernel.org, stable@vger.kernel.org Cc: Jakub Kicinski , Eric Dumazet , "David S. Miller" , Paolo Abeni , Gal Pressman , Tariq Toukan , Sabrina Dubroca , Yossi Kuperman , Benjamin Poirier , Cosmin Ratiu , Rahul Rameshbabu Subject: [PATCH net-next 0/3] Resolve security issue in MACsec offload Rx datapath Date: Thu, 18 Apr 2024 18:17:14 -0700 Message-ID: <20240419011740.333714-1-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.42.0 X-ClientProxiedBy: SJ0PR03CA0011.namprd03.prod.outlook.com (2603:10b6:a03:33a::16) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|DS0PR12MB6656:EE_ X-MS-Office365-Filtering-Correlation-Id: 01dce619-25dc-4e06-268d-08dc600e891b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Pj4L5+74URK4fsPN7v5W6W/x9KRRGG9?= =?utf-8?q?ILxMukiKhSRBkgNBz2rXaRu84aYgFTJPPT9UlP+VYWE4NpmiD0+VzigcSMX7LcLs+?= =?utf-8?q?BhFVW1O+SWBGBJOUCNH6tMZPkjXVW/ZHLr2q3TpauOOhxxSQQgpzsg+TDa3qYf7vk?= =?utf-8?q?DmLfRCucARwxiz/3cM2xRdKYLvOExL+Kf64YwEXzXzXivdJfMMu8twL2RvLyUAWGY?= =?utf-8?q?YC9V/ZS95bu302ffKT4FsNzYOV6mBMfnI4v8NeUD0aWY0j0Zfi9Kyse8KBrbLs9AL?= =?utf-8?q?olXDOD7N5OnImQ5cVWZGJHdBFEf39gqQ7WdH9BR50ZqkL0jmZoDr4EN3rz5NLbPcm?= =?utf-8?q?yQ37YGwAaTK5p236NNugzFCDmxKtEGCdXxeaT0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3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?295LHJJ7SkbucYYQJZvHJwQDh2OQ?= =?utf-8?q?KoteYnWndzusfts14vD+zrucnt8Fq/7jeP8u6VhBWTWocBZ4xBYA/p4PkfrrNLdC/?= =?utf-8?q?bb9eYmk3dClxYexUAXxS60X5wd3TYDZnmbbvH7TauJxBbKcWFd9s1/DdV5O5CCZaD?= =?utf-8?q?9QRhVrrg5M8I4xY2YObq4zPQDAPW++4E4S1J9JB0muireSmtiqpD5jOptpGumL7Gt?= =?utf-8?q?ogdrrBSBBTJoT0dUYbzfkhcX/Yy0r/E2KXOvYjkyo/6ePjCvIoXYqLlS3IUbRMgHV?= =?utf-8?q?zddCO9YOUQpM20EncoLTHasRjg/cgEdMKeRY+8IzC8k9yNwovPloLp86Nu1O8S9Ut?= =?utf-8?q?M0OHWT60z0DT0mrsO5s9ia183SnH9NqLv63HplvEYFEyicB8nxMXbjAgqBdnJRGjx?= =?utf-8?q?sH+ssB83xSQFYYBLSbTYSX52JkstBVQ4pZsvOKSeev8uSpXN5gpD/S0DaTpzHt5Ct?= =?utf-8?q?VVkB0ylJG0ZFlxtBetqSv2AW2G/fnHGcu4z8bZ7mukhNEbEP/vfDRGCYAYNln1+S7?= =?utf-8?q?JPAKsnKJ+sHFZxdWBPw/fV2+5AW9x7h4u+ZkAwpAfrBS47EcxrfEe6NuXZrMp+HpV?= =?utf-8?q?M6NzzgoO54FjyrtQ+D+RjpgptmwKSWenAFzKH9NaK4t1n+nZNw6eIDQwU9aOs8MAS?= =?utf-8?q?xF7IsnkXFdj5XAsccpYFJAYe1XpHn1Sb6tnFniX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=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01dce619-25dc-4e06-268d-08dc600e891b X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 01:17:52.7380 (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: azcYazsvOdDneC2eLYg8aufInBTHvqw2I5yQxSyxXyw9a48fc9Qp3Gd4sI2nyqz+y+Aev1AbC0e7FKI9kBOk1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6656 X-Patchwork-Delegate: kuba@kernel.org Some device drivers support devices that enable them to annotate whether a Rx skb refers to a packet that was processed by the MACsec offloading functionality of the device. Logic in the Rx handling for MACsec offload does not utilize this information to preemptively avoid forwarding to the macsec netdev currently. Because of this, things like multicast messages such as ARP requests are forwarded to the macsec netdev whether the message received was MACsec encrypted or not. The goal of this patch series is to improve the Rx handling for MACsec offload for devices capable of annotating skbs received that were decrypted by the NIC offload for MACsec. Here is a summary of the issue that occurs with the existing logic today. * The current design of the MACsec offload handling path tries to use "best guess" mechanisms for determining whether a packet associated with the currently handled skb in the datapath was processed via HW offload​ * The best guess mechanism uses the following heuristic logic (in order of precedence) - Check if header destination MAC address matches MACsec netdev MAC address -> forward to MACsec port - Check if packet is multicast traffic -> forward to MACsec port​ - MACsec security channel was able to be looked up from skb offload context (mlx5 only) -> forward to MACsec port​ * Problem: plaintext traffic can potentially solicit a MACsec encrypted response from the offload device - Core aspect of MACsec is that it identifies unauthorized LAN connections and excludes them from communication + This behavior can be seen when not enabling offload for MACsec​ - The offload behavior violates this principle in MACsec I believe this behavior is a security bug since applications utilizing MACsec could be exploited using this behavior, and the correct way to resolve this is by having the hardware correctly indicate whether MACsec offload occurred for the packet or not. In the patches in this series, I leave a warning for when the problematic path occurs because I cannot figure out a secure way to fix the security issue that applies to the core MACsec offload handling in the Rx path without breaking MACsec offload for other vendors. Shown at the bottom is an example use case where plaintext traffic sent to a physical port of a NIC configured for MACsec offload is unable to be handled correctly by the software stack when the NIC provides awareness to the kernel about whether the received packet is MACsec traffic or not. In this specific example, plaintext ARP requests are being responded with MACsec encrypted ARP replies (which leads to routing information being unable to be built for the requester). Side 1 ip link del macsec0 ip address flush mlx5_1 ip address add 1.1.1.1/24 dev mlx5_1 ip link set dev mlx5_1 up ip link add link mlx5_1 macsec0 type macsec sci 1 encrypt on ip link set dev macsec0 address 00:11:22:33:44:66 ip macsec offload macsec0 mac ip macsec add macsec0 tx sa 0 pn 1 on key 00 dffafc8d7b9a43d5b9a3dfbbf6a30c16 ip macsec add macsec0 rx sci 2 on ip macsec add macsec0 rx sci 2 sa 0 pn 1 on key 00 ead3664f508eb06c40ac7104cdae4ce5 ip address flush macsec0 ip address add 2.2.2.1/24 dev macsec0 ip link set dev macsec0 up ip link add link macsec0 name macsec_vlan type vlan id 1 ip link set dev macsec_vlan address 00:11:22:33:44:88 ip address flush macsec_vlan ip address add 3.3.3.1/24 dev macsec_vlan ip link set dev macsec_vlan up Side 2 ip link del macsec0 ip address flush mlx5_1 ip address add 1.1.1.2/24 dev mlx5_1 ip link set dev mlx5_1 up ip link add link mlx5_1 macsec0 type macsec sci 2 encrypt on ip link set dev macsec0 address 00:11:22:33:44:77 ip macsec offload macsec0 mac ip macsec add macsec0 tx sa 0 pn 1 on key 00 ead3664f508eb06c40ac7104cdae4ce5 ip macsec add macsec0 rx sci 1 on ip macsec add macsec0 rx sci 1 sa 0 pn 1 on key 00 dffafc8d7b9a43d5b9a3dfbbf6a30c16 ip address flush macsec0 ip address add 2.2.2.2/24 dev macsec0 ip link set dev macsec0 up ip link add link macsec0 name macsec_vlan type vlan id 1 ip link set dev macsec_vlan address 00:11:22:33:44:99 ip address flush macsec_vlan ip address add 3.3.3.2/24 dev macsec_vlan ip link set dev macsec_vlan up Side 1 ping -I mlx5_1 1.1.1.2 PING 1.1.1.2 (1.1.1.2) from 1.1.1.1 mlx5_1: 56(84) bytes of data. From 1.1.1.1 icmp_seq=1 Destination Host Unreachable ping: sendmsg: No route to host From 1.1.1.1 icmp_seq=2 Destination Host Unreachable From 1.1.1.1 icmp_seq=3 Destination Host Unreachable Link: https://github.com/Binary-Eater/macsec-rx-offload/blob/trunk/MACsec_violation_in_core_stack_offload_rx_handling.pdf Link: https://lore.kernel.org/netdev/87r0l25y1c.fsf@nvidia.com/ Link: https://lore.kernel.org/netdev/20231116182900.46052-1-rrameshbabu@nvidia.com/ Cc: Sabrina Dubroca Cc: stable@vger.kernel.org Signed-off-by: Rahul Rameshbabu --- Rahul Rameshbabu (3): macsec: Enable devices to advertise whether they update sk_buff md_dst during offloads macsec: Detect if Rx skb is macsec-related for offloading devices that update md_dst net/mlx5e: Advertise mlx5 ethernet driver updates sk_buff md_dst for MACsec .../mellanox/mlx5/core/en_accel/macsec.c | 1 + drivers/net/macsec.c | 57 ++++++++++++++++--- include/net/macsec.h | 2 + 3 files changed, 51 insertions(+), 9 deletions(-)