From patchwork Tue Oct 29 09:15:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 1185930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 472R6N3JVJz9sPK for ; Tue, 29 Oct 2019 20:26:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Xr4Q3lNj"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 472R6L3LMXzDqrV for ; Tue, 29 Oct 2019 20:26:18 +1100 (AEDT) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 472R132cFqzDrPt for ; Tue, 29 Oct 2019 20:21:43 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Xr4Q3lNj"; dkim-atps=neutral Received: by ozlabs.org (Postfix, from userid 1023) id 472R122wCVz9sPL; Tue, 29 Oct 2019 20:21:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1572340902; bh=EAQtNB1Jy41XWRnXsBVhKv6ugdP/apJdAkT96yVXXNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xr4Q3lNjbRyZQXvdToNFhwMIKbl6jRJFhv53sXb42AbcMBza/5XS+N/3vEX0VHFMW MXbz/7pMM08cLT0VYoHydnwFAslorPOx1g51DXFLwL6L3U6hTxj2GhANs7eeB6s1ef XPPrq0bG1rkjPUIZtMvs9EHmO9cin/sBu41thYCA/hJq91D1bYX4DDU+K62pbeb6xs a+9rohFu8xC8nm4KVukJFIKSZDodBza2GG8mdM5tHf0Xdc/HyB9xY4ilbnlXQgFrTl 66wCSeMtfAZHj+0ZK1vNHuX10zryYVk07j7ZJtBSB1a+++L63+H28/KsGh4vnzStyi b2BfSFQYTZeag== From: Jeremy Kerr To: petitboot@lists.ozlabs.org Subject: [PATCH 2/2] discover/boot: unify verification failure messages Date: Tue, 29 Oct 2019 17:15:40 +0800 Message-Id: <20191029091540.6767-2-jk@ozlabs.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191029091540.6767-1-jk@ozlabs.org> References: <20191029091540.6767-1-jk@ozlabs.org> MIME-Version: 1.0 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nayna Jain Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Currently, we have two sites where the result of validate_boot_files is interpreted: in kexec_load, and boot_process. In the former, we generate the pb_log message, and in the latter we generate the status message. This means we have separate places to maintain similar error messages, which is prone to future errors. This change does all of the interpretation directly after calling validate_boot_files(). Signed-off-by: Jeremy Kerr Acked-by: Joel Stanley --- discover/boot.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/discover/boot.c b/discover/boot.c index a6b88f0..9e7054b 100644 --- a/discover/boot.c +++ b/discover/boot.c @@ -75,16 +75,30 @@ static int kexec_load(struct boot_task *boot_task) boot_task->local_dtb_override = NULL; boot_task->local_image_override = NULL; - if ((result = validate_boot_files(boot_task))) { - if (result == KEXEC_LOAD_DECRYPTION_FALURE) { - pb_log("%s: Aborting kexec due to" - " decryption failure\n", __func__); - } - if (result == KEXEC_LOAD_SIGNATURE_FAILURE) { - pb_log("%s: Aborting kexec due to signature" - " verification failure\n", __func__); + result = validate_boot_files(boot_task); + if (result) { + const char *msg; + + switch (result) { + case KEXEC_LOAD_DECRYPTION_FALURE: + msg = _("decryption failed"); + break; + case KEXEC_LOAD_SIGNATURE_FAILURE: + msg = _("signature verification failed"); + break; + case KEXEC_LOAD_SIG_SETUP_INVALID: + msg = _("invalid signature configuration"); + break; + default: + msg = _("unknown verification failure"); } + update_status(boot_task->status_fn, boot_task->status_arg, + STATUS_ERROR, + _("Boot verification failure: %s"), msg); + pb_log_fn("Aborting kexec due to verification failure: %s", + msg); + validate_boot_files_cleanup(boot_task); return result; } @@ -451,21 +465,6 @@ static void boot_process(struct load_url_result *result, void *data) _("Performing kexec load")); rc = kexec_load(task); - pb_log_fn("kexec_load returned %d\n", rc); - if (rc == KEXEC_LOAD_DECRYPTION_FALURE) { - update_status(task->status_fn, task->status_arg, - STATUS_ERROR, _("Decryption failed")); - } - else if (rc == KEXEC_LOAD_SIGNATURE_FAILURE) { - update_status(task->status_fn, task->status_arg, - STATUS_ERROR, - _("Signature verification failed")); - } - else if (rc == KEXEC_LOAD_SIG_SETUP_INVALID) { - update_status(task->status_fn, task->status_arg, - STATUS_ERROR, - _("Invalid signature configuration")); - } no_load: list_for_each_entry(&task->resources, resource, list)