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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ADECDC433EF for ; Sun, 21 Nov 2021 14:56:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91ED38317A; Sun, 21 Nov 2021 15:55:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="XyvB1bQB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EEBAB83230; Sun, 21 Nov 2021 15:55:55 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0710.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::710]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CC50381287 for ; Sun, 21 Nov 2021 15:55:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=giqol+NIHDFhmbMkRoZpcT++vvvQPg86enjlYfF+iBW+KFUvVtuQWnXBNvyxD1J4ezao/GOl42r4goveXUc8d9tm7Puf0PkxW5CkEYDuqLEODZAyjuyvFU4zt94la92OiZvvsgftW7/L0NWjyXgMPU4kseiRchdEGX3VdFobUt71ZrPiHtnpfVgDDBqry0mBWOGp+luOlKsj5KkY34GeMLH7gTH3USuBm2thuOoRdHRrhWG+HOk8xMv1CJ1mXa1Ho9tuUx0so5DDgg2mHeIz+68OKi9BrJuKGOhkE8tZr0CdfNeUFulWoZnvv7jDiaaoUxS0I/gzxraUF1ZFeCTovA== 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=5zSM+OqwB+HjKsJWtDEdTOsW+QvKAS5VTgmBQYzNEVs=; b=WzSGTcZeqxiWSSv3T+E+PIFhuuDm984heeMs/ulfHInk0MS9rk2dCpxIjUMpu56UZHe+93sRw6TzbIa/Pkjfj4X+7czimyDSnq/xVnvdGkScq9NE6jhIQNMWV/7vUQ3kI6RiLuNnTQ87Fx9txX9OFtCLAHijQNOIeqFV83rUDRAVrNXxaqjEOxjVVaUQzZ6l0xhI05XEy1JM/NF/CLISMYrecetHGDo+NsJeSIVdf7Vf++zfXO5c0U00rg/R/WkVmdOBp1bLbE/ENf8NBwpmIPd7nWP93jjbyK3KT141Y/J3JCbfwP0dndCQkXjXc8h7vDRL3Zrv8oUCMTHBS1EBOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5zSM+OqwB+HjKsJWtDEdTOsW+QvKAS5VTgmBQYzNEVs=; b=XyvB1bQBjnNhq8PxiZrEqypcL0hnr8rgHaViq2U3sQGXhH+3xc7MLfhEeAL+4R6metNGzDbiwavxBQ2uHTsyx7L6dwDKz/kgO0kdtmjuYKXI8bpnCqawM5bqOjHvNDghBJ37t6g9W9B3PnbAQR0BQsWlsHg+jVcCgUpgiHakTQ0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=prevas.dk; Received: from DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:34a::22) by DB9PR10MB5164.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:326::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21; Sun, 21 Nov 2021 14:55:51 +0000 Received: from DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM ([fe80::e1f4:ce93:7894:bd1e]) by DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM ([fe80::e1f4:ce93:7894:bd1e%5]) with mapi id 15.20.4713.024; Sun, 21 Nov 2021 14:55:51 +0000 To: u-boot From: Rasmus Villemoes Subject: two questions on verified boot Cc: Simon Glass Message-ID: Date: Sun, 21 Nov 2021 15:55:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AS8PR07CA0035.eurprd07.prod.outlook.com (2603:10a6:20b:459::27) To DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:34a::22) MIME-Version: 1.0 Received: from [192.168.1.149] (80.208.69.72) by AS8PR07CA0035.eurprd07.prod.outlook.com (2603:10a6:20b:459::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.13 via Frontend Transport; Sun, 21 Nov 2021 14:55:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93d67e9f-3a5a-468e-d0b1-08d9acff02d7 X-MS-TrafficTypeDiagnostic: DB9PR10MB5164: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UUqdr6SHYkMdXHIiXFHyJyOAqbkBnl54+Arjl2SZHolRG7hkQBXxLTufp4ICTVaTejwdkKpgyI6qbXsf42QbVElMob89Lzt2FWmE3t/U8Ra4yBUUSCFvmW14/JgodEM155hPJ5glCHLJYsd5b+CwF8b9vTopbPHeMmud5W1hOJLosz5VPU6sVk7mowW8a3uvNOrHBJWSEY5C46uds7H//j5lQRz4phT+BIVtreAFujS539NOhuWm+wTYjMFry4ZKWPsOnHfpj7uJzXW26oWZijBC+kzcZeaeTloRwAz4XV9omsI4cV/Ru9u5axFtedGniYYQpou/RbXcraNBdmN+ZAGtGJrSXiJzp0hzzaa2ZVOAwD7csgsq8Gc2Doa5TdoZx9nu+jta+i8BVu7MB+UbGfvr8iSqjfZxjLg7n3PlqFue/BeyWUGw92SF42LI+J34ZbbnYh1la75CEfdCRDNJWicIYl0k733UB8YdmhFEErxle0AriJQGhB7FfVsSgBSdwfDpUyseud7bAUdgQFm0xGFglA8u09nTKeElnKBuJ2/UDngSSoPAj8g5Oovfh2KkpUeZq6HK2qk91v65Lk/42qoRGcPZrHVszrKwM9S/OolpmQfUm08zNLBYI/ZmpYNokGzVHmCiQ7R5ID1cdRbV3XtOKJEfSLkpxUBeaRdopvc8ihxLfLJ//BuvdhioNa6ncLew2vj6r5835bWZSQ2nSHK3T3KCdnZXuhtWHQEuBIosWhmdCm4LygnoPPk+q4D5ptBkS5x2sPtxPaRmgxBKIQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(366004)(36756003)(66556008)(66476007)(66946007)(6916009)(16576012)(31696002)(2616005)(186003)(83380400001)(4326008)(38100700002)(5660300002)(8976002)(8936002)(26005)(6486002)(8676002)(44832011)(508600001)(52116002)(316002)(15650500001)(31686004)(86362001)(2906002)(38350700002)(956004)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?Windows-1252?Q?vevv7NFJX2Acv2pU3fYmm16ORVZJlEFcLhGWKGxiKd4x+8y62sM84wvz?= =?Windows-1252?Q?N9IwJHFzJMwYUnQ7R9Cn4IKD5QL6Er/vB9d0PFAz82Y4Gp3/m2uTC1ak?= =?Windows-1252?Q?3dj0IkTYuJ7PKWC9eMFO7MMpe39snI5shL8fyIID9swEFoeplWDmIiTF?= =?Windows-1252?Q?HVQzlEMsldhmq+sBDBk1WegCDhQD3ikJEwf4H+Kh7ACJ4SQJ0Q7ipoSD?= =?Windows-1252?Q?zdsuVaFKEdV83Y0WYEAQG7qXyFSBFZSoiYntkkLU4exZuUhnQwuItBUA?= =?Windows-1252?Q?dGyfIg6bdzWB+GNT90bM3VB30rRdgFSRVq9Cz4inLKION2CQ5teJIMx5?= =?Windows-1252?Q?8z0s/NSp/JA4z00anI2e4zGhq7MN+DSjFic7rWNKor+9DxvaGVh9vPR5?= =?Windows-1252?Q?kpDPWmOS8XTWKDG5+HUCAWOQfMuc6N+YbyR8qjzrBVub+GMBF8152ge7?= =?Windows-1252?Q?0ayGco+QDYmzR+ifjpuPXDnm0VQf5kNUDtr/LZPNitaczzzg7RiKWa2f?= =?Windows-1252?Q?g4f6outrQW2rmk+dhVhZg1X/uRj9VpNkL4QZ9Q5avhvprDZLis4gNgYP?= =?Windows-1252?Q?FUiLaBXC35tbmvPphrLhx1hunITomn+g3RSXCvahv6c4P47KCvAtqPvh?= =?Windows-1252?Q?U5QITtbJm3uRNiI+ys9X/3dXWovePrSKlcgZHn9BLZ/2lMLpbZRQbaec?= =?Windows-1252?Q?caBsBw+3eqWFMN+390egoB/FvHf74Ei6M8aMEAhDjWNGBVJxaLgGe1jo?= =?Windows-1252?Q?uD2OmICm9wR9cVQz/3sOKL9OWQ+2NlaUA+wD7y79IxdrqvvbtSw9zSpq?= =?Windows-1252?Q?gHbWBZCfdRXVeKCItYHKGNNNLYA3r8ZgTWUjxTWl1/vlK3UoTvcal/C+?= =?Windows-1252?Q?cWUbxeYxPoumHwXemZM0OOG77pU3OENJyS4f0tIpoF2qcdHHwIF5OgFE?= =?Windows-1252?Q?BCNzaK5iGKvPSJGclU2qaQAc9PoLsxwk24qtRuMTaKfrQaTfs+Lr9jF0?= =?Windows-1252?Q?H4rSG5/wZlb58VBxulNhB5bwP8abiOSgzSnMEGXVsH9r65On0bGiIpTj?= =?Windows-1252?Q?kN/MR6iNXygLnYiI8HYIbE+5Ks+gxstTm+VzfSQZmu+Yr18JyoqkR7oW?= =?Windows-1252?Q?AA/RXMj6MWUYBJvoAAuNFz2wRhc++yrwdINh8XC5s1UIALDMCgKRvPxq?= =?Windows-1252?Q?R8WfhZmGU76CmORHRbjM+CQ2mF+SfX7cq/+/WofCni5lLqAz2P5RwqRc?= =?Windows-1252?Q?A30IJdoEW1Q+Yvu5OrogrvGmtqWdm3/+Q9BV9WD6f/aneEf0QZbWKFSv?= =?Windows-1252?Q?7DrMB8A6i75m06+baKXQmJldLaEJ4xTvUKFOQ0dTRgTtCcgamzWDgBuQ?= =?Windows-1252?Q?YZ+FnhJh7gPWfBYrJCSvLd7cIWGWXrbXayLo5S07TAgVnYdpAyB82zgi?= =?Windows-1252?Q?AS/b5VIpLbnsM+uWpwA9ENaH3n6IZw7vNv4NRTOdxO3cyiLB61sdHdMP?= =?Windows-1252?Q?SRbvi7a5YMOAR0Oz5st4jKvC4JFiZ/HAp+5qfr9q44iq7SMXFNoTb5Ku?= =?Windows-1252?Q?z901Wrk7AwzmCUl/+JfcTORQfL8LTkL83GbiiO/v2kMJcZPSqURJfg49?= =?Windows-1252?Q?p4bZQI1vVdj1NRtXXVJXSCAGKeU8ku4rXgIA81CcQmlVMPyQV8vhEYyG?= =?Windows-1252?Q?RQhlXQiY67c9gWoIf5q42cKjUrkphxtQ98L3HK6lkyJAIsXOqhpCoO+/?= =?Windows-1252?Q?/avuQ2lK4Wj46IfmjlDAFD+bxHmDCK53xKG4A2w1HYCPjsINQ+CERajM?= =?Windows-1252?Q?+bo3Sw=3D=3D?= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 93d67e9f-3a5a-468e-d0b1-08d9acff02d7 X-MS-Exchange-CrossTenant-AuthSource: DU0PR10MB5266.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2021 14:55:51.4828 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cWviGDYmhNYkhB0H3r8lA3zL0sr0HI3nsDH8gKZ4lqDcaTBky14AH7Bp55VNFU3eJBEOZ/r7B1zSoAQSTZSbc8WUY5TZxSwSHTJvf+bREo0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR10MB5164 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean (1) When one wants to get rid of CONFIG_LEGACY_IMAGE_FORMAT, one also has to wrap any boot script in a FIT rather than a uImage. While it's not directly documented anywhere how to do that, it seems that a minimal .its for achieving it is /dts-v1/; / { description = "U-Boot script(s)"; images { default = "boot"; boot { description = "Bootscript"; data = /incbin/("boot.txt"); type = "script"; compression = "none"; hash-1 { algo = "sha256"; }; }; }; }; [The UX when one doesn't guess that the description string is mandatory is rather sad, but that's a separate story.] Now, I can get that signed if I include a signature-foo node inside the "boot" node, and also add a dummy empty /configurations node (otherwise mkimage refuses to process it). But that will only work if I have added a "required = image" property with the public key; if I want to use the safer/saner "required = conf", how do I make sure any boot script is properly signed? The code in source.c only cares about the images node and calls fit_image_verify(), and there's no concept of "configuration" and combining multiple images when talking about a simple boot script. (2) Assuming for the moment that I would be happy with just using required=image, am I right in that not only does that mean that the combination of kernel/fdt/initramfs is not verified, merely the individual parts, but more importantly (a mix'n'match attack isn't really very likely), _only_ the data property in each node is part of what gets signed, not the other important properties such as load= and entry=? IOW, suppose I have a FIT image with images { kernel { data = blabla; load = 0x1000000; entry = 0x10000000; signature { ... // correct signature of blabla }; }; }; and I know that the boot process uses $loadaddr = 0x40000000. What is to stop me from modifying that FIT image to read images { kernel { data = blabla; load = 0x1000000; entry = 0x400abcde; signature { ... // correct signature of blabla }; }; }; some-other-node { pwned = /incbin/("pwned"); }; where 0xabcde is chosen to coincide with where the data part of the pwned property lies in the modified FIT? (That pwned property can be put anywhere; I could even just replace the signer-name property inside the signature node with a value of "mkimage\0".) In fit_config_process_sig(), there's this elaborate dance with fit_config_get_data()/fdt_find_regions() which, AFAICT, ends up including all the property values (and the FDT_PROP tags and string offsets etc.), and then we call info.crypto->sign() with some appropriate region_count. But in fit_image_process_sig(), we call info.crypto->sign() with nregions==1, and AFAICT, the data being signed is just the value of the "data" property, nothing else. Rasmus