From patchwork Mon Jul 15 13:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13733559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FFB4C3DA4B for ; Mon, 15 Jul 2024 13:46:38 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (EUR03-DBA-obe.outbound.protection.outlook.com [40.107.104.73]) by mx.groups.io with SMTP id smtpd.web11.38326.1721051196428950637 for ; Mon, 15 Jul 2024 06:46:36 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=Kqa/AQrI; spf=pass (domain: siemens.com, ip: 40.107.104.73, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XQiCmQnuxESMGl9oTgWAlhVqF8lYKd6oY5o/4AT5sxd/RH2V1dgbkWURDqxfP8HETt453UC3w/sBpYOSNFV1AOjguMSzolacPppVe14CE4+nbaVJwdaHalW8kKn5cQtI7ei1+pN+y/U1vmTgK/38mEBlB6HB8mIvz+qN0Ti4EyXye4/4i6CmvvHy8CbtPRSfeWacyE60BUkGmQb6oJzbTt406yRck4/fThRNgv+6leUI3kfUstLSs6QylmO4rI2qezYuW611vxC/g3DE3t6FOZsCoQhZe/j38RM748VPiQTbLDOlAt1Ud3zSvvzscEQoCGADDqN9A83CXFfVtGXUOg== 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=D6z7js6sYnc0wY1YDfaZV088CCCMQo3pre3jHYk9UNY=; b=n2rtoZXnPbR5lH2Qu5gqiueIcImisjIE532O175tiG42FO2UiFBwCOlBY9D35YAj7V3wJuPXwAHM7wVWNwJcTBaYeOHSwCOJQfzwcaD8hmmCpM1AplyKHf3jzvJs7058niiX9K41z7F3gFAki09bafBANA5nqSG3xo5N3TZltrYvFKu1U3xM3dxouy7UXDGERmR7Cd9OmO9pYa+ZQ6Yasc6bM0GiMVVOeZ2/3iIqbWvE4QbkH8cz2gt0hhBRqpRyuhdpWzV0Cb7ngDAKAc10gGiIkkrC8+pGr1/VKIS+ngB6m2wX5f/Lg5ngJqXFXE9x4irebXTVlV70c22m5qU6ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D6z7js6sYnc0wY1YDfaZV088CCCMQo3pre3jHYk9UNY=; b=Kqa/AQrI0oeJHIihUo4NfUzuaPJL3Zz9y5YrhiV1Q1UmN7CrMdANefkb10Icesi+lQnp9X/N/cuK6sA1VxVNK3WYqnZZbr3R4VHexYvPX9/t3B2ZeSGBAGnhjsux0gNf+FNorGnEav2vTOS2yIQbj785TrSw0Gm3AyibRXS3AMq3VcMKCOlW97PJG0gQSjOVVmG88j9RgYIXOOD3melt/9kfijneJgZlssHNzNvqMOzHBrRBuEQjo430aWrgDzZNA69BZzMdW3N0QMr2pCZK/Oerfj2o4kUGZ0OqQfNff4EhLkw8muBwyhm9CEA+4ZnwRGlLWH4pTiqHOrhKxi8Flg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) by DB5PR10MB7871.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:48a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Mon, 15 Jul 2024 13:46:33 +0000 Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46]) by DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46%4]) with mapi id 15.20.7762.020; Mon, 15 Jul 2024 13:46:33 +0000 From: Stefan Koch To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, christian.storm@siemens.com, michael.adler@siemens.com, simon.sudler@siemens.com, stefan-koch@siemens.com Subject: [PATCH v3 1/4] initramfs-crypt-hook: Do not attempt to repair a partially encrypted filesystem Date: Mon, 15 Jul 2024 15:46:27 +0200 Message-ID: <20240715134630.1640160-1-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 X-ClientProxiedBy: FR0P281CA0060.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::17) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|DB5PR10MB7871:EE_ X-MS-Office365-Filtering-Correlation-Id: ad7f5cf8-b1e6-4321-8ab4-08dca4d489b5 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: UQz6vGLGjbk+8rmGkSJzENNDB7G/MDfmrYvmDROUJ3x1N5HK7DS0PAb8blPbWPtvAtlGt0235H+5JQkdsy2xPn+jWr6UZPy1f0Wr3Li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0a0YqvOpv55wOAcys8L0aIXYwE8fkZcaL32FrQd//urJ0TdEXFgq/YVfxx3ytKyLo+8ewAIsVkSzRVqOot+bAFYg4OcdrfoNpzR/QrbWoceMnswFgRvQlqPhVvmHnwHBHhMF4CbH4a2PduoETEpdMPlAhvsYNJGU5FjRTMePpfGcO82BDFJ/0b1rGp19m7xg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VIg74C4kRUM00p8sxzcuCkVULs3e3nINBosQU3pvPb1Azmt40gTzD2HzIe92eOTHUNuFn3OFHFqLGAGrpHy7nODtPq/kmMK0QcLtHoGcAFsqKHRQiZBIbkRBRu0Vz0dGzwRiem1Gc3l7rjfWbMj0ffWfOH83wh7J8mLyMEa8Piz+7yYGmlXcRnV5MqG6QCp698mz95GEmFff4/9BdFwuHlbX5HBzcQ+flFKairj/SyJAddMkcQyc7AoZDO3SBRCKSMfLgkvHvWqTdDMROOxYSvX0GmiS29TW9ojLdy3fyTEUK1AeLGKtUJEh/OdYlNKGobYm1eKoiIjvW0iPk4mivuMUl13OvVV6d29wtR2x0sC7d6VzTsJt5wcS83iShM3xsKVLhdn0PWdHOIwRcFX5P8psqgk57J7ONKlH5dGkXeuRaGRKFdY9SgyXZrBevl5D2B9OkIsvuqhhubuVAUtDBp99PbquXVHt8cuOIqyyPzeSaPZRWm8B7MIt0F6XuEaG0Cil+kcooFW7ks+k/ABH7JPg7mySKh+lm+lOwAA+/uEKUzMa+dZGZXk71MBD4/ZXRmo2TQcXwxmSWbnINeK3Yevd03gEY29ANk++tuJzY4s6CAoG57XDIsjPOBqKa7Am/ohRQOoawb1X0itLG7XHRBoZHk85XWqDARBxwbDA9XX9ekqnFNFXyHZFuDLK5AXAXUOARfjWW6Z0KvlXR+TN/VmqErYBfIO6MPZfm/ynlaS0eKACsj3cAsgDmDFCul3A8BJZPypJI7kkattRwBL1P8ffa/E/dwAlWoxPX4b6y6WT4j2pBh1L0bYpK31+aWxL/9TsGg7lMqlX1ooRpXQbxnewSdOFUZwZLv/gmpiosjX53Ybvw4aeAof9ovrwOzvaefgA+evkRzHb3VBhTuZpG/reD9tppPTeRgoVho5rr5TFpAlUFq+WkAchp9VI3+tdNlO4dMGKyPZ6/MdLTV9ClUXxmBNviI4G0S4xPLiA/Vk/V3yaoOySPwBgIwophNVK4Yn/fT7Q84GrDC7PMtThX1qwwJ0qO+opOjU7zi47tf/E1+jDXijSMRDDAqmof/SE3SPzB/eXacI8D0hI4Rx7rGprGsr5VRM4mcqBfCMrWNc61usFzx8DgV7xD6JgxtPHSnrgSwQs0vpmZnAYl5caegCKNw+12SqnBjdlwHHON6+UW+X6Zj0TeWNuuR105qRTFnjQcrzqJ2nRnjuRyFW1dFYrokjjYhPZqQdkcL2cSCJsmRpiHeqUp86C21hfrExM8/+MoFkN3DwJ8A7s9CXysnCrJPdTvyG05KjlT1NOCJW/Wl6W0kYWdaZko89bpqEkhfFraFXC+Om81PClLRJwc3swPsBLeTSQld87MI/Z6Nmnsw8f5XGyF2kOysKOoOa/+t3KRzJWo6KhFuxnWJjyll7we9xFrHto7qxBNuhDavxapQ/A7fEjugOUh+oAEhaX/Z794N4uOkMx51j3cMn9eEXfkD9nR2OIPQpOEGVwFio552DhAtdeJKHl/m1Y/ua6mA7RcpWVLTbheirXOs+CDUYVLE626zsfCONchY8R7QY+ny2GnJOazC+hEo0K/TIXYWxgrRd2/12vowU8wtBLIvb7QdN1T4mddbbHPomWr6PLXPqrLU14DMceOWPnfOm0 X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad7f5cf8-b1e6-4321-8ab4-08dca4d489b5 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2024 13:46:33.1300 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NDs1Ojs39Bo+vUGh+LZ78Z9GbPSeKAYIvvnluE8ONmGdswhe4pjFXtdGbTVCvYUEAUY/vgpZdIoaXY/exqcUUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR10MB7871 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 15 Jul 2024 13:46:38 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16494 Avoids that e2fsck will repair the partially rencrypted filesystem after power-loss while reencryption. In general, cryptsetup is capable to resume a partial encryption, but there is no key available to unlock the partial encrypted data, yet. The key is enrolled only after fully succeeded reencryption, yet. Signed-off-by: Stefan Koch --- .../initramfs-crypt-hook/files/encrypt_partition.script | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script index ff4c135..f943aea 100644 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script @@ -77,7 +77,13 @@ reencrypt_existing_partition() { [options] broken_system_clock=true EOF - e2fsck -p -f "$1" + # ensure that filesystem is clean otherwise resize2fs will fail + # do not attempt to repair a partially encrypted filesystem + # ensure that there is no attempt to + # repair a partially encrypted filesystem + if ! cryptsetup luksUUID "$1" &> /dev/null; then + e2fsck -p -f "$1" + fi if ! resize2fs "$1" "${reduced_size_in_kb}"; then panic "reencryption of filesystem $1 cannot continue!" fi From patchwork Mon Jul 15 13:46:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13733560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58830C3DA59 for ; Mon, 15 Jul 2024 13:46:38 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (EUR03-DBA-obe.outbound.protection.outlook.com [40.107.104.73]) by mx.groups.io with SMTP id smtpd.web11.38326.1721051196428950637 for ; Mon, 15 Jul 2024 06:46:37 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=Ur5pCfgM; spf=pass (domain: siemens.com, ip: 40.107.104.73, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sWdzBVecWs+KQ/oWrld6yR6cC68ZLxCEeJeahIwZIW0MJvza1G4fEwdp+w+1BP2aa3ey4r7YYUUUqf/VNQFS9sEdyZsHiBhCmrscd0BXKJz587bxHHmkFsajTRjOsz1PTtV73ieWvrHxl95vA/n/lcTPvF5IBmN2VCcQ1EXXMtaIXqTnpNzB7rDlHYaMB/NQo/JwXdSa6WNP9I0+UJlVwaYeuaJv1YePl6/DZbYn4IWttmZu5nvGbtMkpdPgBt7XPa5pjAc9zB/sAtUa97Wy85WwNoaqpa85guI9pwAB9FZyln7yUeI6gAghdn8Rz4MxLcAeXzzTBHGcqP1TsNnl8Q== 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=k2HS2yeK4UxUP8QZvBXkhssTVQTrl5h0dl2AL/cTsaE=; b=uacRlz5hylmPtnyE1yQk9At17PErFdvMCshDeQeEcDi4zmh0RUjcm9A04RPSjoXBvjlIcOs27pykzlQYMftfpI4cpFj2gwlROQFIC+pj9x9WgDrjcc+Bd5NRYAGWuKE0YpO92EtmLQIlB+rgvqoVhOJB2EZSpdMZf4cS9eS3Z9FGQxJDXmtnxNA1cGfRf1zxSGBqEKs4tA6zPbp6ngGwX19seiLD1u4C1PMfw3Nl9/xauOXBfy5RjZLZRgzjCsxSdZXeFq0WDvKzTFQwSuw8nZV+8jVE3DhDeQOSqL+eqSUfQItXuOMD4MX3Ih0mZgrxcXLxhhZdKCmeK+EcFNwu1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k2HS2yeK4UxUP8QZvBXkhssTVQTrl5h0dl2AL/cTsaE=; b=Ur5pCfgMo2tjja5iUOwrsCifYErWzVA6m+kDQEcRQGA0QtAMH07YVTdsyKs8N0NFOIm6aynv1Ng2fiub173UHTZY4ihb77zpxTplLQouhHneceARfjPp7VsUo8e4ssNLr1rlvXuDRzt1peVjnL0CnZA85NuRAzJv+ETNbA89iPZc4Prith0S6JW8RyOJNbog5I0YKjbcWCL5lncUup6NPgeU18vl4iF+SQkbeD6cjDLw4285ckiziKluDqS1f1nU9AseKDqcQ/3jFoplul1q+/Drjv0uBvqGWaQ+yj9z0uiolVOTIwnnU+1+0Ijw3D86fm/v+GU367KR7IamjXPk/A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) by DB5PR10MB7871.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:48a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Mon, 15 Jul 2024 13:46:35 +0000 Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46]) by DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46%4]) with mapi id 15.20.7762.020; Mon, 15 Jul 2024 13:46:34 +0000 From: Stefan Koch To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, christian.storm@siemens.com, michael.adler@siemens.com, simon.sudler@siemens.com, stefan-koch@siemens.com Subject: [PATCH v3 2/4] initramfs-crypt-hook: Provide full losetup executable Date: Mon, 15 Jul 2024 15:46:28 +0200 Message-ID: <20240715134630.1640160-2-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240715134630.1640160-1-stefan-koch@siemens.com> References: <20240715134630.1640160-1-stefan-koch@siemens.com> X-ClientProxiedBy: FR0P281CA0046.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:48::23) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|DB5PR10MB7871:EE_ X-MS-Office365-Filtering-Correlation-Id: 349a7b6a-a68f-4f5a-dd29-08dca4d48aa4 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft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Lu6bAbAbboa2k44k780nWtSvjbFYP/YCa1W2LQ7eTK9zfh7o+ubAjx//p2KW2CBV+DEa8896Ol5Kv33FxXD20kZRXBIKd7Sh2lwPluVqE/AEab8T7nomcK0XtPOiZwZHpOesq+DNwAVAkG9zQmpBrgYPOrlWixIVTSThFOK1ZJLcV+TxZW5ScOdwAoHZ5SQgZ2ZHotOd2XyEF/Cxb6SNh+GLA93eYWXaoQ1gwEu0Z5i8SujC5iy45DKgOfg/JoaVcvGL3b83Vxhl3KhYiA1R8yrKr1TvWdtKOqYIlqGA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PseQpGngzQKWU5Fy54IWaFblU73nX8XGB7GmR5p9wsgUkcP39dxsN1XY7dfh8wtMDxPBPJX2Imi5YDljXz0pL9QA84xbSrCuirjz4T+xkm8KsTsdU+xwKHsTxmYKrQYPEWk43IR14V8lIn8/4MrJgjeEATiQjPYLwffAjjf3PrNaJmFlVTQK8La/XkbdfCayVui8Wem7drBm6bmpiSD0XMI9V/4gmg+IholfA7c2UugPtkBAr5NHD/49rt6vGu+6DOkguxpcENPa5WcgW6Taxoq9iI8Avg+5uLLwCQdGpysfoUQtrNEmuwf2UsQDrjaeooO0Wp94AsLiAvR8WzIIZ2krvhzQ8YOpVC2hrFMuE3s/dXGq1F2m4W0V5iT3EW58d+MZe86rIyd0u3VnByN6N6Dua7tVx/dUsrUu4EII8qneKKlzSFqdtTmkrIo6BJI3jeMfxDNrFlFsIk7A/kPDz4pF5yzTKo29qbHSMVS7A83sDy7sOathxwnhs2uqbESsvNwqJUxGz72W7EmqIbY5xAvctBWcCuplvUEWPgLTSRL5juLhNYf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zfM X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 349a7b6a-a68f-4f5a-dd29-08dca4d48aa4 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2024 13:46:34.8971 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iHj9QYsCDWKoxX/ZkCR5gTS1dZ1juK+KahNC/ynA+Uoodgsyx0Zn+Rk7zqJDsqZuNv+p9HKqbn0WWs5ZwrMFvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR10MB7871 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 15 Jul 2024 13:46:38 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16495 - Avoids using a busybox losetup executable that doesn't support the "--sizelimit" parameter - The "--sizelimit" parameter is needed for introducing speed-up of disk reencryption with the following commit Signed-off-by: Stefan Koch --- .../initramfs-crypt-hook/files/encrypt_partition.systemd.hook | 1 + .../initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.hook b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.hook index be8c117..1e8c74c 100755 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.hook +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.hook @@ -47,6 +47,7 @@ copy_exec /usr/bin/sleep || hook_error "/usr/bin/sleep not found" copy_exec /usr/sbin/e2fsck || hook_error "/usr/sbin/e2fsck not found" copy_exec /usr/sbin/resize2fs || hook_error "/usr/sbin/resize2fs not found" copy_exec /usr/sbin/cryptsetup || hook_error "/usr/sbin/cryptsetup not found" +copy_exec /usr/sbin/losetup /usr/local/sbin/losetup || hook_error "/usr/sbin/losetup not found" copy_exec /usr/bin/systemd-cryptenroll || hook_error "/usr/bin/systemd-cryptenroll not found" copy_exec /usr/lib/systemd/systemd-cryptsetup || hook_error "/usr/lib/systemd/systemd-cryptsetup not found" copy_exec /usr/bin/tpm2_pcrread || hook_error "Unable to copy /usr/bin/tpm2_pcrread" diff --git a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb index 72de5b6..3497d95 100644 --- a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb +++ b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb @@ -9,7 +9,7 @@ # SPDX-License-Identifier: MIT inherit dpkg-raw -DEBIAN_DEPENDS = "initramfs-tools, cryptsetup, \ +DEBIAN_DEPENDS = "initramfs-tools, mount, cryptsetup, \ awk, openssl, libtss2-esys-3.0.2-0 | libtss2-esys0, \ libtss2-rc0 | libtss2-esys0, libtss2-mu0 | libtss2-esys0, \ e2fsprogs, tpm2-tools, coreutils, uuid-runtime" From patchwork Mon Jul 15 13:46:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13733562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 379AFC3DA59 for ; Mon, 15 Jul 2024 13:46:48 +0000 (UTC) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.42]) by mx.groups.io with SMTP id smtpd.web10.38516.1721051199476428444 for ; Mon, 15 Jul 2024 06:46:39 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=oqJFo9qr; spf=pass (domain: siemens.com, ip: 40.107.20.42, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PUF721e6HAWXiyXQmqwFDpTplaknSN7f59l1GarK93fHyjEg3W4O4G/+vqcxCtJL1OdaBvatwz+kFHkGCW5bP6mE9Wrd0paQ93RuVt54A89FhC+g8zSZ/zhSfIk4xvsLQU9UvdM3RPsm7eYm8ZFj2Ql8HxMew24Uji7b56JDK5qOQTuuDqzvqn+xBlcqAKXq2UXFz5nVwQQpVR8Lmnnz0zqJ3AiWbDrNi1FR7j3edtApliMRcdgs5I9OuSTz1IOAiB30yMyPhKdOPpr+iV6ZyYHYB2/LMRXcW8Z0NRGgRcDyx841jCsJkT19jdtCPvDi8qBw8SyhYOVM45E4mMzIyg== 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=JxiOH+/+tevQ8rkudKOhPgdFWSOJYSBpipb7b6TP9WY=; b=WoMud4qjDyvCV424r05UoGKIbeJdJWGCsPGoIcc/Jx/Pr6R4p/2cBRKsUA4K+6BcCkqjTrFhu0bz4kvpu7Su9qzzz6+ABNX6Cp9Pez0k/JDCBDbRCXrFQGL3KHvpUON+DQ+sAzx6NAujs1SvJkaIe5HSeI+COSetng1kAfKAXaaJbdrw1x/XYyO7tuegKkfv19+54nDlJv6YCyZ7xxTEFO6tt9uF9xN3dMFd+oLtn8nWmLBqtQ0D0/iYtl77tccwW8WQglSxN/lle7rr1Sh5AoT4RJdVaUF0Qljq6b6RFUGRJ1lbyRkmTPMbG1TsHaWeUo8S6BBSM6dxtxy0mtr52A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JxiOH+/+tevQ8rkudKOhPgdFWSOJYSBpipb7b6TP9WY=; b=oqJFo9qrai2mx2D3uYJjclN2J8JSsoQZ4D+dpabmmsw42pZ++D1Gp4CHobGyGqtzWfxH2XOgt4OrFd+o/XQtYjJEpyvnldySK6gJKu2w3UvQMCNJK46qaDMIe/xWTJ/GZW/+GSLAGqLrWHE13DgHdF28sKONxnKRG73aICIP+8KWpunj9/yx9u9R42Xi3ZfEXNeOqb15v0r2ijFbjznXP72m3vABm2vZRlnsI+pukPkA7loxJLV2nRKZ/GN4AQyybDeW05/09QN+4ZIZxgav9M7kmAHDKwkzUnOGidMZOJDxNeHeHwSlAf7bE40STuylSugPMrf0gL5jytdH8BR5mg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) by DB5PR10MB7871.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:48a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Mon, 15 Jul 2024 13:46:36 +0000 Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46]) by DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46%4]) with mapi id 15.20.7762.020; Mon, 15 Jul 2024 13:46:36 +0000 From: Stefan Koch To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, christian.storm@siemens.com, michael.adler@siemens.com, simon.sudler@siemens.com, stefan-koch@siemens.com Subject: [PATCH v3 3/4] initramfs-crypt-hook: Allow speed-up of disk-reencryption Date: Mon, 15 Jul 2024 15:46:29 +0200 Message-ID: <20240715134630.1640160-3-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240715134630.1640160-1-stefan-koch@siemens.com> References: <20240715134630.1640160-1-stefan-koch@siemens.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|DB5PR10MB7871:EE_ X-MS-Office365-Filtering-Correlation-Id: 090adfc1-7f00-4473-ff5b-08dca4d48b8c X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: aUX9+DrlMbojikoqPAFCW9yzqtm68CIdRwyRBPB3acZssEY+q7loSAGl4pW1edIdgc52jNrLX9sDf/Rl2ll8J5WmmmV6A+zp6R+GVVuDFHv609gAjznwfK/zzSF95AYnqFAzZEtWflcpYendFcyoSZnhOlmS2hs4EnUmHtTHLPRH1ofcphfhJ2yW3jJK0OmGhqyd4OGeDOZVzlNg3XnfWt3t366TRcFBc/sYzoIiVND7yu0/020FkjOO3hmVyllKY0073Ui+KIDMJcJMSFbj43gRfekccFLh7jQs5kxMpcGdCrjUKL4VGkohO4IhdCDr+5TH0iFPAcneOZhLNZg7/SJjOktMmMIVhH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JIDPlaVrHD8qt0Eqarh7TJHjzwyfzV4S8NxwPlYyuVhe0vrBll+aKpHSaqu0AYvZWMFW2oZPM7JAQO+XKQSEmnsCvjOmLy6wqvSIGVAHjKIy4kk2wsAf8sZikg5ACfbBnNwOt7gXXptA0KsWjZHciTonXUmVr8rtQInPaYcSdENoE9R/A6U5xHKQeMygCi0Uq2Ry4HK1baKZqTVTRGfRrpXQs9TI0QzuUxfQpM6owtXWH6KLxXiRASiL8mtwS6PbwEWOONtLYXYOPIWb/u1cE9x50AgQKbQacR0dMrVEaK/Zq9wjJ6nTwD/9ShMTDtvTjbc5kVZ/BXtYSt7C7PTvezNL32QLvnYVVsknzatecN9IRtnokM22YhsrhqEF+gmD7NSFFkn/DPkNEKpOS/5Vz9o5vzHl4naguQrjJ5IzN+wXMzm/uC0h4p/6mdYKQa6uohkA6K54/Ae7AoMjw1q6RJr4dThy0yD2bUHU1iCW8SKv4Ip2FbxYd50py+vln8VYV1M2IRn85d8WAp1qA0amMqueApTmOdUapuJ1pbelFuX/opFgazk6+d1RXMb3KNriggTfn2aWP11KZb8Q7fWSIPdHnE5BbnUwPG06UHx/baZZrF75cyty9VH3dw0r6rIZdRzTilPZFgFQBvlIdmw+t9wuCFuL6NL/UF/4n8u9zO8Bu9wGBgiMNNYnxGYNbLjasXNzUf+ER7znadAZVfoXQLh3xxh+6Sir1xsY1uGKFGC764pZ1BXzOGGHRhPG2AFMYNQ== X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 090adfc1-7f00-4473-ff5b-08dca4d48b8c X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2024 13:46:36.2048 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 48W+4Gbv+BU97EekkhzeKHFGHTA4YJB1dJ5wBijGf/zJxGklIMW+Fbz72PZSIo1rpVAD6pXml1c8QbkQdyjqgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR10MB7871 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 15 Jul 2024 13:46:48 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16496 As the reencrypt mechanism doesn't work at file system level so it wouldn't detect used and free blocks. This means that the block-wise reencryption process could take a very long time depending on the partition size. Using the format mechanism instead of the reencrypt one would delete all existing data (without wiping). This would be very fast, because it doesn't matter whether a block is used or free. Set CRYPT_FAST_REENCRYPTION to "1" to speed-up the reencrypt process. So, this would be done: - Obtain used space of the unencrypted userdata partition - Shrink the partition and resize it to the size of used space (minimum size) - reencrypt the userdata partition now with smaller size - Expand the encrypted userdata partition back to the maximum possible size Some disk encryption implementations like within the Debian installer will overwrite the entire partition with random data for security reasons (e.g. wiping old already deleted data, hiding metadata, etc.). However, this speed-up lacks the described security benefit of implicit data overwrite. So for security reasons, it behaves identical to the format option (there is no support for explicit random overwrite within initramfs-crypt-hook). Keep in mind that a power loss while reencryption will cause data loss (with or without fast reencryption). The key is only enrolled after fully succeeded reencryption, yet. So, no recovery from already encrypted data would be possible. Signed-off-by: Stefan Koch --- .../files/encrypt_partition.env.tmpl | 1 + .../files/encrypt_partition.script | 53 ++++++++++++++++--- .../initramfs-crypt-hook_0.2.bb | 8 +++ 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl index bb93361..2b02f55 100644 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.env.tmpl @@ -5,3 +5,4 @@ WATCHDOG_DEV="${INITRAMFS_WATCHDOG_DEVICE}" HASH_TYPE="${CRYPT_HASH_TYPE}" KEY_ALGORITHM="${CRYPT_KEY_ALGORITHM}" ENCRYPTION_IS_OPTIONAL="${CRYPT_ENCRYPTION_OPTIONAL}" +FAST_REENCRYPTION="${CRYPT_FAST_REENCRYPTION}" diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script index f943aea..7bb40c9 100644 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script @@ -54,6 +54,9 @@ if [ -z "${create_file_system_cmd}" ]; then create_file_system_cmd="mke2fs -t ext4" fi +# Path to full (non-busybox) losetup binary +losetup_path="/usr/local/sbin/losetup" + service_watchdog() { for n in $(seq $(($SETUP_TIMEOUT / 10)) ); do printf '\0' @@ -62,13 +65,16 @@ service_watchdog() { } reencrypt_existing_partition() { + reencrypt_device="$1" part_size_blocks="$(cat /sys/class/block/"$(awk -v dev="$1" 'BEGIN{split(dev,a,"/"); print a[3]}' )"/size)" - # reduce the filesystem and partition by 32M to fit the LUKS header + part_size_in_kb="$(expr "$part_size_blocks" / 2)" # blocksize 512 byte + partition_fstype=$(get_fstype "${1}") + # reduce the filesystem and partition by 32M to fit the LUKS header reduce_device_size=32768 - reduced_size="$(expr "$part_size_blocks" - 65536 )" - reduced_size_in_byte="$(expr "$reduced_size" \* 512)" - reduced_size_in_kb="$(expr "$reduced_size_in_byte" / 1024)K" + reduce_device_size_blocks="$(expr "$reduce_device_size" \* 2)" # 512 byte blocks + reduced_size="$(expr "$part_size_blocks" - "$reduce_device_size_blocks" )" + reduced_size_in_kb="$(expr "$reduced_size" / 2)" # blocksize 512 byte case $partition_fstype in ext*) # reduce the filesystem and partition by 32M to fit the LUKS header @@ -84,9 +90,31 @@ EOF if ! cryptsetup luksUUID "$1" &> /dev/null; then e2fsck -p -f "$1" fi - if ! resize2fs "$1" "${reduced_size_in_kb}"; then + # shrink partition temporarily to minimum + min_size_fsblocks="$(resize2fs "$1" -P | awk -F ": " '{ print $2 }')" + if [ "$FAST_REENCRYPTION" = "1" ] && loop_device="$("$losetup_path" -f)" && [ -n "$min_size_fsblocks" ]; then + # set encrypted size for expanding step + encrypted_size_in_kb="$reduced_size_in_kb" + # minimum partition size + min_size_in_kb="$(expr "$min_size_fsblocks" \* 4)" # blocksize 4096 byte + # shrinked partition size (reduce_size + minimum partition size) + reduced_size_in_kb="$(expr "$reduce_device_size" + "$min_size_in_kb")" + # set loop device as reencrypt device + reencrypt_device="$loop_device" + else + # continue with default reencryption in failure case + FAST_REENCRYPTION="0" + fi + + if ! resize2fs "$1" "${reduced_size_in_kb}K"; then panic "reencryption of filesystem $1 cannot continue!" fi + + if [ "$FAST_REENCRYPTION" = "1" ]; then + # use temporarily loop device to simulate shrinked device + # because cryptsetup uses device size at reducing + "$losetup_path" --sizelimit "${reduced_size_in_kb}K" "$loop_device" "$1" + fi ;; squashfs|swap|"") [ "$debug" = "y" ] && echo "skip disk resize as it is not supported or unnecessary for fstype: '$partition_fstype'" @@ -96,9 +124,14 @@ EOF ;; esac if [ -x /usr/sbin/cryptsetup-reencrypt ]; then - /usr/sbin/cryptsetup-reencrypt --new --reduce-device-size "$reduce_device_size"k "$1" < "$2" + /usr/sbin/cryptsetup-reencrypt --new --reduce-device-size "$reduce_device_size"k "$reencrypt_device" < "$2" else - /usr/sbin/cryptsetup reencrypt --encrypt --reduce-device-size "$reduce_device_size"k "$1" < "$2" + /usr/sbin/cryptsetup reencrypt --encrypt --reduce-device-size "$reduce_device_size"k "$reencrypt_device" < "$2" + fi + + if [ "$FAST_REENCRYPTION" = "1" ]; then + # remove temporarily loop device + "$losetup_path" -d "$loop_device" fi } for candidate in /dev/tpm*; do @@ -182,6 +215,12 @@ for partition_set in $partition_sets; do reencrypt_existing_partition "$part_device" "$tmp_key" enroll_tpm2_token "$part_device" "$tmp_key" "$tpm_device" "$tpm_key_algorithm" "$pcr_bank_hash_type" open_tpm2_partition "$part_device" "$crypt_mount_name" "$tpm_device" + if [ "$FAST_REENCRYPTION" = "1" ]; then + # expand encrypted partition to maximum + /usr/sbin/cryptsetup resize "$decrypted_part" + # expand filesystem within encrypted layer to maximum + resize2fs "$decrypted_part" "${encrypted_size_in_kb}K" + fi log_end_msg ;; "format") diff --git a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb index 3497d95..e3dd515 100644 --- a/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb +++ b/recipes-initramfs/initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb @@ -57,6 +57,13 @@ CRYPT_PARTITIONS ??= "home:/home:reencrypt var:/var:reencrypt" # CRYPT_CREATE_FILE_SYSTEM_CMD contains the shell command to create the filesystem # in a newly formatted LUKS Partition CRYPT_CREATE_FILE_SYSTEM_CMD ??= "/usr/sbin/mke2fs -t ext4" +# Fast reencryption state +# It uses temporary partition resize, +# consider security and data reliablity aspects when enabling +# (e.g. wiping old already deleted data, hiding metadata, etc.) +# Keep in mind that a power loss while reencryption will cause data loss +# (with or without fast reencryption). +CRYPT_FAST_REENCRYPTION ??= "0" # Timeout for creating / re-encrypting partitions on first boot CRYPT_SETUP_TIMEOUT ??= "600" # Watchdog to service during the initial setup of the crypto partitions @@ -68,6 +75,7 @@ CRYPT_ENCRYPTION_OPTIONAL ??= "false" TEMPLATE_VARS = "CRYPT_PARTITIONS CRYPT_CREATE_FILE_SYSTEM_CMD \ CRYPT_SETUP_TIMEOUT INITRAMFS_WATCHDOG_DEVICE CRYPT_HASH_TYPE \ + CRYPT_FAST_REENCRYPTION \ CRYPT_KEY_ALGORITHM CRYPT_ENCRYPTION_OPTIONAL" TEMPLATE_FILES = "encrypt_partition.env.tmpl" From patchwork Mon Jul 15 13:46:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13733561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B992C41513 for ; Mon, 15 Jul 2024 13:46:48 +0000 (UTC) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.42]) by mx.groups.io with SMTP id smtpd.web10.38516.1721051199476428444 for ; Mon, 15 Jul 2024 06:46:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=GYKQkfcw; spf=pass (domain: siemens.com, ip: 40.107.20.42, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V1NW4BPc9eocgao+ag6js5ntQ7tuG7gV22Wel82sRNmWo10BH5I3d7j/XJQW0p54HFZbd2vv10vgH56rro9Jw1XNcLCrkMKbXtbgfK30uNyAHFBqnfONnKmt6p9tWUJQpCT5VhCIxyGNAvv4RnjBchGazm2ga2CvWyfKLiyptej81JPBsm/edzCHOYfiRNc+0JwyZ1De/DeqMZ15JwAqjShg+62a+cZoKilfOomlRFYlG+rf/TvkqBZTj0F0HYnK3vuDPB2xcUNxR07SGyQEpZUfj4n3HKvEQqJ6N452vh8zjkw1mS5Vpnt7ot5KWOmXQalqk6g5Gx00aT4szdSEUA== 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=Vh23SGjVeAGUQ7fYmDH/4QReXYbWs7qDEPWCrtZ+yXU=; b=gTdxh/tnpERAHRtFz04QnYDPdqT58nDT2uGqi4wxpAjE6mn0tg68nR8BgEiLnEz/qUhbjH3gfFugA8mcWHMIf3AcNuVvgcXSQQg9rSBl2kWVJFaJUDnpPOpyVA8REu8TMsZaGHg2bsLTzK8I+tcq+SUU+F8eIdVpZFswaWrChyYryilluUmC6lEh+hsrjah2Ofh4C0oP1XFmgVRfrgocIh81v1P94clyPDhs5ZTwzslZGhovhvLaJJBQ/5k9k4zUpw80Y/dk0GL9nlasaXhKaN/dBz0lSkkFjlNjiGCntsxk0yLOkHA7P0ZQA6afXVD+DBRgxqHYD/Erh2BfYweTNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siemens.com; dmarc=pass action=none header.from=siemens.com; dkim=pass header.d=siemens.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vh23SGjVeAGUQ7fYmDH/4QReXYbWs7qDEPWCrtZ+yXU=; b=GYKQkfcw9KevJk67LdjMuC4s8vFSitf2GVr5QFPPn0tRlLWFoeJNSHXzNQ1qaqlf+YyUEr7CtI/XY7BpTKVadpDEElM3E7WHJMb60mXWwkV1ZaIdBBWROkeF29iUmIe1deR4V0dj0P1Nxp52lg1za6+iuMp/D/S7mW9eTXsJdP8m/lmeyYcNUlnnkEjItCXWtJ/+4OHKFfy2iimXmcXUV1Hut1U0Zds4/8hjgkEk9C/RHem86R0T4DLgSZShk8ZY5BN4D0ZM3HORaNk+iazeASlNIwUgrUc9zXsTIw7ElktCcb7/raBL+yDbkXiIq4iDdY2ccDO0vxh2cEbywbhr6A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siemens.com; Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) by DB5PR10MB7871.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:48a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Mon, 15 Jul 2024 13:46:38 +0000 Received: from DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46]) by DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM ([fe80::f75d:ad6e:d321:cc46%4]) with mapi id 15.20.7762.020; Mon, 15 Jul 2024 13:46:37 +0000 From: Stefan Koch To: cip-dev@lists.cip-project.org CC: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, christian.storm@siemens.com, michael.adler@siemens.com, simon.sudler@siemens.com, stefan-koch@siemens.com Subject: [PATCH v3 4/4] initramfs-crypt-hook: Extend README.md for CRYPT_FAST_REENCRYPTION mechanism Date: Mon, 15 Jul 2024 15:46:30 +0200 Message-ID: <20240715134630.1640160-4-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240715134630.1640160-1-stefan-koch@siemens.com> References: <20240715134630.1640160-1-stefan-koch@siemens.com> X-ClientProxiedBy: FR3P281CA0083.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::21) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|DB5PR10MB7871:EE_ X-MS-Office365-Filtering-Correlation-Id: 0aa66632-4f02-4af0-5663-08dca4d48c8d X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 9p3bX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YwNY55TGQtDKosCaAX9B8CY8vdG71GIBcH0mh54cqDPkCZIBNBoyQV+BweNg1AUq0QoEOt2ZiVoCwdzlLk9EDFCfzuOomz1XSliiVjPIBTv4PPw/ZsnXz7OJcC9486bF4iyvTQq4C1/XwD0ZEe/wooYuuSzyEa8qEmp5RHt49Aayb9jXS4PD07vec4p1sOnPMuPJcGZGSu55vC+NxBoWcatXL+3cBFVKXdnl2Fnxb9hS+m+XIbw0wL83wvCam/WNxWomC4CvPQTj7QH8AqWjpPXXBOykYGLQ46Og== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QsybTZTIRvvjPzXqXLOixaUgWI0dt+xiYOGPgoWS/97oyrl70R6NiTb4UfnHUSagto1WYLiT8SZhEHPewtQSwsHWZ4AqBkznemHP/bjMKQAmoV20OBVCJwuBzPFJN551R9q7iHzfEujvlLrCJhRKATgLPi6oXPFUMPlfIvrxrDJMrTSA6Cnx8qti+zah3sF/CCDfow9wLtKGBwNAt1MOpu2W+rDiFFxdybgbcDh7ym0khrm5ABu18TAQlboWSibbcsOBtFoiwU04jkyP6BNEbJlxpOoRPPEmhIVq6tkOjukVJs+EG1KRu3g8ssMsEmT4652zuxf+X1kxrfKFN3FXOaTKUqE1i6HIwzMOuxve9zFBfFv2UvdondvMXMAJkqw+o9S71LPAXiN1WICBxKuy/NaAsmfz3MNFT9Ei/SRiTk0hXe46mueFdozCz8Pa+OlVqbSx2s++F9N5Ywk9WnAzlTWTW2YL+e/Rxlc2mEjhNl2SMVrHu1PbA696AzdnpYFThx5BStsXmfwxonAoGEIGQ5aGrGJZriv2HcP8LbTlBXQ5NKUTyDdVKQ/duq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3Z4I/aAGtjuTCfd X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0aa66632-4f02-4af0-5663-08dca4d48c8d X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2024 13:46:37.8979 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uSlSFBrSwdfRzUspGGxFqslMtRaDtLtwWjRcWCVOQyRDKedvM2HVOKkcsxvEE6moa4AT0Pp3BPNpbh2ObzMYMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR10MB7871 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 15 Jul 2024 13:46:48 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16497 Signed-off-by: Stefan Koch --- doc/README.tpm2.encryption.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/README.tpm2.encryption.md b/doc/README.tpm2.encryption.md index 3f7e89f..a1e6dd3 100644 --- a/doc/README.tpm2.encryption.md +++ b/doc/README.tpm2.encryption.md @@ -38,6 +38,7 @@ or by adding using the following command line build: The initramfs-crypt-hook recipe has the following variables which can be overwritten during image build: - CRYPT_PARTITIONS - CRYPT_CREATE_FILE_SYSTEM_CMD +- CRYPT_FAST_REENCRYPTION ### CRYPT_PARTITIONS @@ -58,6 +59,36 @@ The mountpoint is empty as the root partition is mounted by a seperate initramf Both partitions are encrypted during first boot. The initramfs hook opens `${ABROOTFS_PART_UUID_A}` and `${ABROOTFS_PART_UUID_B}` during boot. +#### Speed-up disk-reencryption (`CRYPT_FAST_REENCRYPTION`) + +As the `reencrypt` mechanism doesn't work at file system level +so it wouldn't detect used and free blocks. +This means that the block-wise reencryption process could +take a very long time depending on the partition size. + +Using the `format` mechanism instead of the `reencrypt` one +would delete all existing data (without wiping). This would be very fast, +because it doesn't matter whether a block is used or free. + +Set `CRYPT_FAST_REENCRYPTION` to `"1"` to speed-up the `reencrypt` process. +So, this would be done: +- Obtain used space of the unencrypted userdata partition +- Shrink the partition and resize it to the size of used space (minimum size) +- reencrypt the userdata partition now with smaller size +- Expand the encrypted userdata partition back to the maximum possible size + +Some disk encryption implementations like within the Debian installer +will overwrite the entire partition with random data for security reasons +(e.g. wiping old already deleted data, hiding metadata, etc.). + +However, this speed-up lacks the described security benefit of implicit data overwrite. +So for security reasons, it behaves identical to the `format` option +(there is no support for explicit random overwrite within initramfs-crypt-hook). + +Keep in mind that a power loss while reencryption will cause data loss. +The key is only enrolled after fully succeeded reencryption, yet. +So, no recovery from already encrypted data would be possible. + ### CRYPT_CREATE_FILE_SYSTEM_CMD The variable `CRYPT_CREATE_FILE_SYSTEM_CMD` contains the command to create a new file system on a newly