From patchwork Thu Jul 18 10:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13736360 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 35945C41513 for ; Thu, 18 Jul 2024 10:32:30 +0000 (UTC) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (EUR02-DB5-obe.outbound.protection.outlook.com [40.107.249.44]) by mx.groups.io with SMTP id smtpd.web10.12257.1721298740012609024 for ; Thu, 18 Jul 2024 03:32:20 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=nNYwfK0I; spf=pass (domain: siemens.com, ip: 40.107.249.44, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oeiDXoDuzABkfh0xjcVdWeIuHp0uD1jyyYlk1KE6ZQxtfsP1yHc7oesKwuh4vs5VvfKCegK8I0lvvqSgpytHtXFJ0y6JKlMw/0KgiU63Af8liCLsIOEVncRl+poJLAJkvIGVhj9VgKcy+XcHG6inUXrbuGyoLX4/cqpv0le6wvitF9C4jDyDgUkvk1iyGTV/7aZW7p+18fYl2kR8VovAw8BC7C5+MdryEvhNN3ayG9gmCXor8v/F8AXzOPCfwvXAS7dOs5DbcxMRosiaDb6iafB8OLj6R+mA0bwCdxqyLqPc+IyHNuIR9fcBL+5S9T9CcP7dtliZUFFEncw5Ohf4jg== 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=KY99/zTHFnxw2QRhMV9zrMdakjT9nD+TpHOuimVVxIs+NUii88r2ZVeUuPivUGV6WFVnCVS0fOBoPnPPc0FWkQSnTjI7cCtb4kO3oHuGTY2/QC7BAWFWnyLARgn05WMof4uAE2MHecYYk8GlFDqVbJBYIpIBXbTyBwwdK8JI3k5BwVefJD+lHnJBu4R0XiBbn+MZmeRSZUKXluJnR/DHE4vwxJPgn06r+kOnlz0NomxeMax7lYgTZt1Ka6eNIoZsBkd8pPDnJNPwMvreJJoyrM5VLwCuN58wggPflk/1mLyXTbNuoSRdY7dGMTOC3kWFWflcGiwdDAl7NdwRO5xgxA== 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=nNYwfK0ImKzkL8x40MJlN1NcKoctc0dJ6HmESWoi4CWT3iKDSmi3UUV0bIOVtgFCGk7ZXzWCoXl8XksAxoaKY1eiznfrE35GkCp1vt4Hvt541IGP4M2MA0qoFjMqMdO4CwUvvEBpx2meCBn6a4pe+k/bzY6wFU9WevwzrSGHAspsuf1bvvtN5952fQ3KLAq+DrpEYj8azNsMKK582kpnSZhIRkALtUvMWPO1pE0baC+AzhPFuNoonzqohP2bAKIvAfldVhGVjWSjjQHqumo2gk5JjMr6DnvQ5d7OKwC/mKaTbl6JkMhYMbD2minBm3wuCFH9Mnbi9elR6J8pItEfhg== 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 PA1PR10MB8389.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:44f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.31; Thu, 18 Jul 2024 10:32:17 +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; Thu, 18 Jul 2024 10:32:17 +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: Thu, 18 Jul 2024 12:32:11 +0200 Message-ID: <20240718103214.1583403-1-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 X-ClientProxiedBy: FR2P281CA0088.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9b::13) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|PA1PR10MB8389:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ab5dbfd-cfb1-4eeb-582c-08dca714e581 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: 9/AvlPZ68g1Xx8pP1wvc2KgD3f48uTxBdFg5L0zA7Mx7xqxHbzmFR7iXKdQmiq9kD+kkLzzd5q2JkZI2WCc5dvnPsKOgx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X9Imo/tQ+Z+7FEfw162+VIlj3dAICGUTDliXxmlmf6ssM/7eKeWGpKh9/HSGhmAM21QBDkfk+MrEqWdEaxQ9y/CiVwpdHWa77XF9Ju//TS/TJ+PaehEo6TE0IZv+TvdPrJiVsdoPWYUnvVSfpbakKPs2CC7kOj34FycGTDt447awMnT2B0bXSOp74IYYpA== 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)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X/h32aEk6MoWUjc53YtZnJgvSWGJykBLSNfKiIT+7OVMLRTAnHO+qgW8saJ9S8i2XfFPoutbyt/Euy8eF0PCDYdToWDqAR4RZOr7QU2rHr+Lbmo7NQZAJYPzRPBbGhYL1GOsmexcL0NG6t2dzdM69KR9xYEDQTTDCL6PAI7nwGVVlA3vOnbHVA8RNe2b3spCt4hpsqZ+UQukoLWzJmbqpWI6DM7K6wDLp9GiemlFKixuQ3MS2B6b21hC1LaP8tE30PtRZVtFffnmeqBQ/Ug47BCej4Gb5mpW58ViG/LDWZv9OMv5qiXWYAIDjBY5MoOW7VDPAijfYTp/i+fILgq/E/6OQgTcZCueb2Kpif6USsDmKnGiA7NqMpa6XdfOqWJlcZz+5EYXskxBGcWJwPIzxCTksv3KEcfNiRFK+qi2it2cYGnCYutP4/HLkTEfhKiIiqd3sXKXBzdVhafcvJGnWo9OAhwxt7/wgFc2Cj/O7iKcUMShVMoKJ0UlOWlPYfJnMKa/RkxDb+E1+2DrN0yb8n4vukMiEHR61LronPkFWmmzOCzIfkNY5/Dzmv1dabN51ykwtRbx7XJjMFwfTI+nHMhd4iQmIgv+7Z2lBm4IyqDVFvOeQ/3tSGcFk9pOY2GonDAnDyClSPE35y84PN7s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714e581 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 10:32:17.3003 (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: rr8FX5s4hZqykDVDNWKj/FxeehP9vd6skUgaT6Dtyj5tdy4/XMZMnnRlAm7IPNyAc4PJEj4gspd1oDB+5OZN4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR10MB8389 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 ; Thu, 18 Jul 2024 10:32:30 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16579 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 Thu Jul 18 10:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13736358 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 37052C3DA49 for ; Thu, 18 Jul 2024 10:32:30 +0000 (UTC) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (EUR02-DB5-obe.outbound.protection.outlook.com [40.107.249.44]) by mx.groups.io with SMTP id smtpd.web10.12257.1721298740012609024 for ; Thu, 18 Jul 2024 03:32:21 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=gQI/3Unu; spf=pass (domain: siemens.com, ip: 40.107.249.44, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CPTgl1HXjNieAFYC/6d5TUojMuL9pVNXYN0qh8v7LWssWiYtQvcNjWK5YHK73v+9d57wGT0jKHlspI9Nj7oCyNMEgPFrUBHLeqLfumS3e1XO2faEO+kSreWIrG+RqyPWcLs0BKr0eWN3TIfhWeFZPCfMGdomat44LtrWUrc0zaCIf0e9BuEc4wg42sk7hpI9FHLGrUcSvptnloS4LMlXLXlsSigWU1Ds/hUUg7U69R6GohSI7TBxN2NhQPIPdxBD0CtNr1dEgnJxQWkFlggVVWADA66/BD8cAKAXyf9HCG5I+PlzYOwdCl30C9jGMXbfzvBNZnrmsxmwzNDpxe5LMw== 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=EjivbEIPHjFk3iSGC1mE2FctmjjY1UM9Hiquzd29eYY=; b=bk4TkyFToUmCbM0dgKN+xgiWZvIbu3mryxMW9xGhalf3fbU/LdS/21QOGvoP8vs7BqTPMTIo8ySrI6Mrrq+7IZy99ZtwpPCQk1eH5cCK9joVJ2pXdRQc/tOjE1ilPn/iweKReSR19Fpk0BGtH4iDn60w1r1D4CkEK60KImxdFzEgEGEQo5HTtBq3sykiiP39H06/TxlWA/11SlL1qfqQxUm9UJxxtYQPDu/rBsmmxzzj2qdUg0IAcrKVECT75KoWezD6BYy/53cJ9/PWKXF+auFRApatF7hpNJR/aRu3k5V0RS2von/u+C6tU66QcoLa+6Urj7XyxU02iz2SNdv5aQ== 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=EjivbEIPHjFk3iSGC1mE2FctmjjY1UM9Hiquzd29eYY=; b=gQI/3UnuZYnDkLYZp5cCIxX6I7f0uGjx6wZ32TBsqiUl3RQMV0PgshGZFEfb7SAkm5sSdWTgf7YToHJsuBCpfJYyUbzFv4io17MFc1N0Jo6F6u7jYEpYVWHYn1+P4BPQZheE4jwM4DTuhI2Nx+oCvwy8PZhodT7BYOI7TF5jIm5OkpIZAhk+k6wINDMfXyGHcwwe6Y3tSBNzRTHY8bX9rfEcpnydge2y13LPuBtr3+fLn5N579nxmsLjY4H+xefXa6jgD56IBHdKVYWhS2l7uULQnn2hTJXhPbyrTFkXcDT2x09sTjHS/ELNKmr7p0a9Q6eLzoNENcCh8OHoC7WynA== 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 PA1PR10MB8389.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:44f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.31; Thu, 18 Jul 2024 10:32:19 +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; Thu, 18 Jul 2024 10:32:19 +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: Thu, 18 Jul 2024 12:32:12 +0200 Message-ID: <20240718103214.1583403-2-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718103214.1583403-1-stefan-koch@siemens.com> References: <20240718103214.1583403-1-stefan-koch@siemens.com> X-ClientProxiedBy: FR4P281CA0426.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:d1::9) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|PA1PR10MB8389:EE_ X-MS-Office365-Filtering-Correlation-Id: 49b05091-2294-40bc-37e2-08dca714e6e3 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800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P9y/X0oE/4x8Bw1/V/1Z85zIQd7tL6cEYp4KDmx5JmkPwBfPB+ArDx+pRTAXKS412xBfqnC1YUJxnIra9XttjrvBfLSwtr/3fAGVVWVAAwlQs/gJq5prYo/uW5v35K2QCtdmAtOlOqJnV91Dxx/GVG8M+yqxAXaS9DgujS+/Uq7eCGLWM84zF56hjRO894ScAajoUxpi1UJwo6Nuh6PzySLJmlun5S+gfIIraeBtYefrqmTvWnYf6vl1394jrXDrh5CMbEKpC6bDWOuKzTatOJR0SwWVS29eIw/7/OXZixGUU0S6NHosqn75WBRA== 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)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w3YAF/DEVRuyrV1s+rqtPuhz1fnxXnTUNZsJ/nE5t7mqmrF44D7wRBEq6KsWduk/2gvCfLJOY6KqhSuD3GBFyhuhVb95dTHYgqh9xZHH0S9oXFt00kSChziWzL6urhpfxoIEeipswd1mUUw7S33ZeRp93OnDL0it3d+Foxw7rJ1wR/tldWWp8dU8ztj3rnOny8Tng7iGa3sLRpL0ev18AYhJ7A8A3Oh8iTWKRjniu93cQeyzPXkNiyfznRP/9jf1fe967rKFAocgMP+8aAhrKO2KOWt8fu1W8p1hPzjKzZGWRDjwVjgVpSttUkNZ9p9QkL/jJ5DijjekqFFYr4P7utWbBNsyg/IxiWSK31jnvRl62xnBGvfKvH/eUYI0S/bEm9EvJc3Z4LuZ62Q95sxASa2NlE9o2Qw0UrUzIDqiXQ3DZ9lGS52cUqiNy89t5ZvmM+xct3Zjv4i5ruZTmBy2InACZoVft6sKzOpdgKUlSwguN6RYO0P9aWf2ITfzpw0OVTnB4udVdPoQ8MRue+6jGDU5mC10aV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W2WD9yMcc3AtO6poWdfp3J+tRHcUOw0LF03pmYv1c6mM X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49b05091-2294-40bc-37e2-08dca714e6e3 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 10:32:19.5405 (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: Tsv9TY4tTVoKznP26PVGJ4TXNMuwjJdFBnQ80+LApZSvwmicACfLAe4EGJzQJLd1jGPwb//ZrmaMufEg2pX/1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR10MB8389 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 ; Thu, 18 Jul 2024 10:32:30 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16580 - 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.clevis.hook | 1 + .../initramfs-crypt-hook/files/encrypt_partition.systemd.hook | 1 + .../initramfs-crypt-hook/initramfs-crypt-hook_0.2.bb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.clevis.hook b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.clevis.hook index 4e62ef7..4fbf830 100755 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.clevis.hook +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.clevis.hook @@ -74,6 +74,7 @@ copy_exec /usr/bin/file || hook_error "Unable to copy /usr/bin/file " copy_exec /usr/lib/*/libgcc_s.so.1 || hook_error "Unable to copy /usr/lib/*/libgcc_s.so.1 " copy_exec /usr/bin/uuidparse || hook_error "Unable to copy /usr/bin/uuidparse" copy_exec /usr/bin/mountpoint || hook_error "Unable to copy /usr/bin/mountpoint" +copy_exec /usr/sbin/losetup || hook_error "/usr/sbin/losetup not found" if [ -x /usr/sbin/cryptsetup-reencrypt ]; then copy_exec /usr/sbin/cryptsetup-reencrypt 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..b331a58 100755 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.hook +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.hook @@ -54,6 +54,7 @@ copy_exec /usr/bin/tpm2_testparms || hook_error "Unable to copy /usr/bin/tpm2_te copy_exec /usr/bin/basename || hook_error "Unable to copy /usr/bin/basename" copy_exec /usr/bin/uuidparse || hook_error "Unable to copy /usr/bin/uuidparse" copy_exec /usr/bin/mountpoint || hook_error "Unable to copy /usr/bin/mountpoint" +copy_exec /usr/sbin/losetup || hook_error "/usr/sbin/losetup not found" copy_exec /usr/lib/*/cryptsetup/libcryptsetup-token-systemd-tpm2.so || hook_error "/usr/lib/*/cryptsetup/libcryptsetup-token-systemd-tpm2.so not found" if [ -x /usr/sbin/cryptsetup-reencrypt ]; then 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 Thu Jul 18 10:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13736361 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 45F17C3DA61 for ; Thu, 18 Jul 2024 10:32:30 +0000 (UTC) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (EUR02-DB5-obe.outbound.protection.outlook.com [40.107.249.58]) by mx.groups.io with SMTP id smtpd.web10.12258.1721298743786560977 for ; Thu, 18 Jul 2024 03:32:24 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=nnX97XGp; spf=pass (domain: siemens.com, ip: 40.107.249.58, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V3mwtuH0CH+hntuaJu2BkK5wBCK8Jag+cm+43XOWNyMz8KtKpeiPGUb3R4QAaAVmaWcNVApL53QTDrqkJKyyk86WOM92rZeoGuym+NrDjhNRe7NAnRjICbHx4czE1wunu/+Xrojoa03w0KFK3/s8qyJ2PdDZB5Ciiz4PO2FD7PeFsj3w2bvGv8HdMFzJegFl4KNbJUcpEoY75Ocqw4OO45r8/HvxCfHClyQ7HUHetWyt2KceIYCeJYWQF9DmSxEkB89/fR04hmxhYAr2BYhFe9YfCH8fpu6Uh718f8lk8Sq7gkZF+qbzDp3uljHwnbBZRTNQsl30DHw8R+RvXMwEDQ== 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=W5NtRbt7QNLPEYarVwq94bYisbxes2UEJkZcIlRKKRA=; b=qwyJScOCqmnvuJlZnzS2ywPm43XEX8hBAdxeJ2hsLDkaqih+XLFUz2DAIgq/vSinIBs4/RatfMEHnPg6WPk3sKKHrnUkW8wh+SIJlF9sNloHXiVjOpgBixglJoD3ebVLyW6QTp979rwXPQkBL2a8dnqCxKUSkTuavj9z857JUOBcVt6qGVgWyA07IlXTML2FjZd/btvzBAk/wcBdobZ4F+rTr9ML5LRRe6lXyrfpEI1ufDLWQI1XQzR416+V7NOoVYvKNMqMHo2C+NlA8rERLOILzGV7ryWjMexe+9EhnLWth2j1b+LYlV3vJzuGLTBK1yY4NX/7T4AOsxHuTvuHtQ== 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=W5NtRbt7QNLPEYarVwq94bYisbxes2UEJkZcIlRKKRA=; b=nnX97XGpnYIRODhjpeIIiaVa+BGlNKPziwLeCMfGuJliMD7+V4L7WIzHRn1klVnlQWSOzX8NjBPiUiVjsZA3pqSDUFfLUU9Kf9XYjSaR7ESyGyMhIfDjnG29HBprfCBN9MrBmaAZ2fKPQjhyoYtiB2HNJKHEqdqqlHjfBar/PSTN3vhrKrO7P9JzbgQQtjyxewIgipDrwKSpudDw9Bv9td9H+R/Ur3xKDi549ousommy1aJvFnkFuUeJgLM/mK7tA+rkkHO0vuL2C8EGlShyhRF9Kcb/JK27hYjIxJwW9RLs6pkr81SW4YM7SPH/PxrX4WIkjn/wpiHLZfxRvJcquw== 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 PA1PR10MB8389.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:44f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.31; Thu, 18 Jul 2024 10:32:21 +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; Thu, 18 Jul 2024 10:32:21 +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: Thu, 18 Jul 2024 12:32:13 +0200 Message-ID: <20240718103214.1583403-3-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718103214.1583403-1-stefan-koch@siemens.com> References: <20240718103214.1583403-1-stefan-koch@siemens.com> X-ClientProxiedBy: FR4P281CA0428.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:d1::11) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|PA1PR10MB8389:EE_ X-MS-Office365-Filtering-Correlation-Id: afd44357-a2a2-4fe5-b643-08dca714e818 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: dHGMfrdt0fX+kRMkK/KollvL70GyJcUlkyZLW+cvjXLsliKmvR2itl/lvCASXEjGNnE1yw7VusvYpyC+MlyClJH1ugmDxxj0UGO/GcyASa1PUAAQ0J49/U/zu6+NKeaWLAuyqK1pSXTuOp2KPYNS8r6o1uHPBfuDBiWxWsAMyXTalo0z4IeCNORR0i1jhvcfiwuGoej3VuyNEfZAwRHuUVtTB5HC9JhuhekiAWs3biiPJWpXdOm8LHkXJR4Jn7IlEPHsyGssD5XdLLCQDyFWE8jomHnn0CuIVsGYimetsxvN4iJ7o1d/2/BZRo+c3/vEQOR1GsDdMXvJpEu0KWMAfQCNRGkEtUMYEUX3QfDdfwayDtoHu6a4UVXSvuSQinrZQ9D7E2MFDVe5PDTkW8LjEYFzd4aR/JFX2yekvqVymO2qVKnUJyqJjIbOHDf5R2wJWnj4cttoNyZDgWwpizxLmpuvsSlmdNP6+Rvboj0Z22RYsa0ouQT/eURSwtNuwUPy5d1FwFlQjVdf5zqxVOLwgg3laY2PLAcx6WuwfFTGjAe+yu7XF+Cixc7XqsoPOq6RZYUVoq2bqdSHU7OpAusBLKSTIXTOxC7SX+FNaFtbjfkzSDJRQsU9FFazatm5k4uKhu+OVbUz6iRafDo3NUgbpA6Zb9/GEomfdhorCUEpMB1KI/UDDHWObenz3K8CHuUvCrZ4H8j2CtiMEwK4tJaoL3KcoVktpB3GGLpzJs8OmJVoERLsSYEuK8gGs6DO89zyyVHapgRY409QMQy+WWR2voalqQGoxy3JZbTMnv+WSXdbSwZ0+7f+QPw02UZQ6dPciUv8rknEoOMkVDGNG8H1SjCcRwEoqt6jfXLPyiUxQq/dL+Mrr603kY7X5tSbAglrFeh7kJZl75rjA6FfEclzEOmpOXD7X7GwYk4KHbjavEML8igN0wca0pGkLS2/gleigZ8XJ0esLQkLIyCdTqJtDrpeY+84z4mx6r5V1seWrMMjYXQuAZH+LHSVfUW0L/CcK40BcA7bmx1vX1ewzkKX3QeYmm5QSMgRBYyacc7ZSNRdf9KLcMjQvWrdIsri90wlTSSfoA72XeoZjFCLqS3lFxVBV/LFsKLWOmgtFYyyfrgGhzdaAJgyYOo6btBRx1DOWq0Fn7nW5y7WrS2fMhHQVpfGimsJ8Mnx8OTRUeLpsnfXFxofMb8C1CzRmqopDgPLfFKZ4Hs3d81cfAoP8I4q9Ha2l6FDlM1BOFrFvvjgUbBWTQUHshLQZIMBG0YxC7//+oiaqyeuBEWn6JHg75n2v8fOQnB9Yh5Hgg0y2CDTLq2C+mYpdnjj/DoTmgbXxi/CNQ1rVJWj/6hCLAaivaI6LA== 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)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NUiBU6CflvjAPHrdVY8ZABzj8IM4AjXYJAk6rBXbSuaIyrEsaH5tQmCleAcgjB8ELmpUtXlyFm9cPu0VMTxoMT6fFkexN+3L4cai87yKTGa2M/3GLcgYyrFFG1j97S+/c+ygLfE8/i1boy/9X/zCCF52TEb88qnVEVdrtsJiny9JVIjHiX+9mg0bg8wuua/fIAG2aZTjsh0+4bX4DLoL3NNn1uPZ9iElCiUBIFl82zrPWFIgQCw4g115H7IbFSnKQhWiumywStd5rTXkbwJPAowInz6mbRq2svuqzwg3S3f9n2KIrffx4ldI98DHXqn7GlKHWK3ofuD1eJpw4rpyj5LrOh97Q15xOCLhYeoLYDF1QleFupUbSJ4CPpMdXCsg3QmzWELbvmXNttdBE+LCB+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PVrsymYxST/n3OfNt1uFNAJVCzwjCdbGsv+hcDVpAwdsZtIv0XMXJCczwTV5hxE90IxoWStMX4CfmYagr7zlLknOZ9QYTvI21/tcFZtj0EPaOJa8DSVB1iU6sShPkuvvWxw0PlN9pABHQpQ4g6392RkbdFb1xwID7A7UgB X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: afd44357-a2a2-4fe5-b643-08dca714e818 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 10:32:21.5863 (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: PjksYOLdiu7kDSxTBrwzVA2dpltkodn7R0daCnbLg+WeXFqynQVhALtKafuwhbFRSVPEWFH0r6Rtq1wmn2y36w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR10MB8389 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 ; Thu, 18 Jul 2024 10:32:30 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16581 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 | 56 ++++++++++++++++--- .../initramfs-crypt-hook_0.2.bb | 8 +++ 3 files changed, 58 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..f72889e 100644 --- a/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script +++ b/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.script @@ -54,6 +54,11 @@ if [ -z "${create_file_system_cmd}" ]; then create_file_system_cmd="mke2fs -t ext4" fi +# Path to losetup binary +# binary must support --sizelimit parameter +# which is not supported by the busybox variant +losetup_path="/usr/sbin/losetup" + service_watchdog() { for n in $(seq $(($SETUP_TIMEOUT / 10)) ); do printf '\0' @@ -62,13 +67,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 +92,32 @@ 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 a temporary loop device as wrapper to simulate a shrinked device + # because the used cryptsetup takes care of the device size and + # the --reduce-device-size parameter is limited to 64 MiB + "$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 +127,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 +218,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 Thu Jul 18 10:32:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Koch X-Patchwork-Id: 13736359 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 30215C3DA60 for ; Thu, 18 Jul 2024 10:32:30 +0000 (UTC) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (EUR02-DB5-obe.outbound.protection.outlook.com [40.107.249.71]) by mx.groups.io with SMTP id smtpd.web11.12230.1721298746878820135 for ; Thu, 18 Jul 2024 03:32:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@siemens.com header.s=selector2 header.b=ww7/lycg; spf=pass (domain: siemens.com, ip: 40.107.249.71, mailfrom: stefan-koch@siemens.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XzTEGFipYtqWnxOWiffg3q+Cu6cLkQBif5ddBDmbCsClBILbRndTm4cE2kONwQQ7E0KrKvqkKsY/p4nkTcSFSz/tnlR10ylOb4FL6MLAeZWPw4WZpNOTT6ibZLQD5ADRarOcNQaTdRuYukUCVFiWLr+0moG9XzV5u8QU5ZIlnnje4hXKNwCLJs3XmaIZezezW5dWXvmKtIzZbaOhINoRxyn2blQW+gDOfe+AoNxuuovGg2FYNTYU5pKpVlRCPBKZXRkKRgWzhE/dPC6fyAZKE8rrpTCOF+Hjvq16+Dd1MDHBncgeuCCc/gWrHgnhuUVxZOPkYygr7mDk53wU6ehk6w== 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=vmhf6pjsjaQn40nCtLLpSxwoH/tLp+yLPREUb6YFbWk=; b=D5FBoZsXpb/RmfNnMNhempdMbY5/iA8YRn9H/2fv8D6t7JQDM3iVRAsrclCIFOZSwH/iqu5o7Ag01XPcyIn9H30wPiCzN1RzCMQBqHHzk82fkRsCqw52gcF3S32Ra12aPfx/DOcx782G0qFx0tqbXob2kZM4znekvxSqa6BoltmqRBGEdp1AvL2ewxuIh5DEGN4tIpHkOYHYV4QRzZ6dWOQdDZtlQNVnQKjg/+LKwJrsFL5/5LIOvBUH+q1FvdY4APW7aUly/b6NwujStBtX7PpvSlcYpRHxC6jv8/D98wBjx3vlClpEDiiEeD0enJUUFXWSqljiPWeQ1laICxWHfw== 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=vmhf6pjsjaQn40nCtLLpSxwoH/tLp+yLPREUb6YFbWk=; b=ww7/lycgoLdmNYE6YVWS0DxQ4l5+WbUFNnzqu8rExzskt2wV46Lw99zunEPhK/z0Ese3bA2WYYca6QnG0I/TsCrbcfbGlYloIfypGbK54fgsqcFQg2bjxMWw+I4o6mKgWo4hCDDvdv6TjyMGoLOkXViuhUOFCdQxVai9uNejS471CmEu+Qv8SXoXizw5xBzfFEuih0U0DE5ix6vjTV3DX7S+aU4Oe5e1gXipjArZ7541FDuuHxlQ0+QJZKYq9woXGDUpFItYk+j6SmH7VyaG+RquebJzOV0wM12GqR9PaRRUhyta4TSVAaXfhcyfsXAAKxIc03ZrLB2Zo6HdqDPeWA== 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 PA1PR10MB8389.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:44f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.31; Thu, 18 Jul 2024 10:32:24 +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; Thu, 18 Jul 2024 10:32:24 +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: Thu, 18 Jul 2024 12:32:14 +0200 Message-ID: <20240718103214.1583403-4-stefan-koch@siemens.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718103214.1583403-1-stefan-koch@siemens.com> References: <20240718103214.1583403-1-stefan-koch@siemens.com> X-ClientProxiedBy: FR4P281CA0434.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:d1::7) To DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB4953:EE_|PA1PR10MB8389:EE_ X-MS-Office365-Filtering-Correlation-Id: b3143b04-a4f4-4019-190f-08dca714e999 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: bl0E7rBNmUYqEeb8nvSOmOQxk8qw1VqTy3++lv238Kn1NconLeYnKD0W+RfzYIamESeyB3BHHPbjNTrEGqA+5acCx6EoTGl/L2BaC7YaMQrmVt1tkEl7GDyPTDa4/DdiXO/4JSK1jcQjR7jwwhoLBOE+1NKJ5dhK4m8xXl0kPpTZFjpt5KEdIT6vFdQo2GrRGBHHJz2fGaxbP/MGyVOXf9gui8V+fusvnXM2wsoHvRK98/dB22FWJV+Yygg0YWC9ZAvnTRDRlw2MyVPYI6Xrd2VjEM8CHAUSamWwKZSTIz7sTxsXvO24AiWVaWJa/5C8asVPnHSYy8UoevIxoDwb046TCe9kUWVmyQQ1mHcbP/+Fifx0c5zBl+JLVMjp2tmJgNXMBeIGvRi0K/v+nVCdZyNKUXRpzHgSZVUa3LyxwztroYYI8eHd9InFGAxsfBgzNiVjOHMohGNBN5BFip9VjoPgTDgeUHetjlC1HGV26rzs9mq9crtcZVLgBu1InSakJtFMJTSk4DhlqeRFebpi7yeM4hfk5DC5IyeOOwr4uw6cmxhApMff+q2TayPB414ozR3ea3JBkiDL5j4Uk5drvTGVvbsNeLsmm6HZTNvjvoWPs24nbmBojgNczDLSn4M08eKCLtlCyVfpF1PQ72aeFnSo8SVlzyATY/11WxaOvZ6IRn8QYfIHOKa2JQ9i0MXbry1sADD04VNINdCEuyfhsDEOkfVmPNIm9GZeD2vP9mhcBANpJE/Js0E4JSgFy2iSakxWYoQ3lo8t7xfZnaVGl9Rs99zU2jrERB1bMVXnxFnD3jYH4IKSf76FN7LXch++U9HwRpFnY47rATMYBqdOJ4/APBBS9Rpqd0CKcBvCgxjSekkAJblfgziJrZxurGfHQZzLRv6uww53Nu+b02N0DxWc1oK+U06ylP7As7h8LAYNDdYdR2Jnb0A0uFKXsz1Wh3ds5eRM74y/QlPiUuH/G3AtgdWzG1m3B0F4GbZn/DQ51AX6QwA4/nyILdqfqvpj2cb++4/VWeDfg9BfNir6W7aOdSIYFxh6FSGKzFSnaWs+dEhsO9Uy7nBlUrYoPNazvjMERkwk+3jsO+klh1ij1qi9a79JD3YE9ZguYDAbbki/C1ppHUnjHSAzZnwyvvFsflReHD6KP4OiGREX7nq4N8ScscVxAwNnLDIJg0ZTMAO6UtXYluzlsoallgVxxhFd3GT5UqMrvpNWXt1w97iIrGQ9oBKYb8LKFju7yXlE7KPFgTJLvtPj3oTeiqg4bBooDmD+nP06KfTIsE6ZTfuctcj9fGQAs2Qxr1N1mDkTl413KfAQ9yjVd5sS0j21bCm/bBs7zbZMH8HUfSot8y6w8g== 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)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WG9E4/ovJ9qW+UdLavKKD8/a1juvGP1dCjSb0VLGFmecLZqgMKhvshE9RWDlzJrRnWK6+L2pOr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26MgSCDElcKeyWOASFK2AWv3Jdb8eCM7wlvINd4f+hKflMaqVNPgYbZmpy2/hkmmqQGm7kofeqapXnOlNTgIP2KW4f2saqW3ruqoT98Xo81Okq5KSpJtEnZZXpqDlJNP7gVRx5bodIBaJF8HwFt9adqe/SsaBMn4m3tCMIECOWxJpZ4FckD6rbmx5B5PZQ1px1N5fBTtT2sWzHMCpVUPhwqEiYqB7aCbFtbjj0CoF9ar99P6LHP49u5ntOi027okT7tG9D31R2qWT7ceJZ/i8c8ibuX1XoOmbV79wGNCwODjQZd9XlxZtO6RfzPkEbabr2kTuC0nCUmI+bnEdmRgTJzqRVWrMAbCdfTe3uuV0u5FggyIAj5bityLuVKRyEOcEYf7fsnbmGYX8X2LYZPavd21ItYHA8ioT015aaJGN3hcKtGr9HVhI3mZGQ4R9FqTvQwXCy8n5tF7gfDhMp0WpEx8Paxzb4ZkbmAcpW8IxUKrp1l0 X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3143b04-a4f4-4019-190f-08dca714e999 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB4953.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 10:32:24.1136 (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: umEiPakYsPFR1lH6CWsgk3Loqtp3+ey6YIl2UTZHZMq3VrfJoIcmSJUuWZ7tOSJ08jmjaySjhDbGYqyklVmg4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR10MB8389 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 ; Thu, 18 Jul 2024 10:32:30 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/16582 Signed-off-by: Stefan Koch --- doc/README.tpm2.encryption.md | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/doc/README.tpm2.encryption.md b/doc/README.tpm2.encryption.md index 3f7e89f..3efbd79 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,41 @@ 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 + +A temporary loop device is used as wrapper to simulate a shrinked device +because the used cryptsetup takes care of the device size and +the --reduce-device-size parameter is limited to 64 MiB. + +However, this speed-up lacks the described security benefit of +implicit data overwrite. In general, there is no support for +explicit random overwrite within the `initramfs-crypt-hook`, that's +only implicit for the `reencrypt` case without speed-up. + +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.). + +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