From patchwork Wed Jun 6 01:08:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teddy Reed X-Patchwork-Id: 925699 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XrH13PYA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 410rD60RB1z9s08 for ; Wed, 6 Jun 2018 11:09:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C03EDC21F78; Wed, 6 Jun 2018 01:09:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 58D74C21E88; Wed, 6 Jun 2018 01:09:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 88E70C21E88; Wed, 6 Jun 2018 01:09:00 +0000 (UTC) Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by lists.denx.de (Postfix) with ESMTPS id 0C9E2C21DFB for ; Wed, 6 Jun 2018 01:09:00 +0000 (UTC) Received: by mail-qt0-f196.google.com with SMTP id d3-v6so4706763qto.1 for ; Tue, 05 Jun 2018 18:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version :content-transfer-encoding; bh=wmEA7D8rOhjEu2NiUhLrUw/q2Xq2MBekIT1mUDAJl/A=; b=XrH13PYAv2Y+SzFh2osYEsaA1JIqEwlRfY9uwjZPclBrFK0air7dWTGuvkEBThaqAJ 133nJ2Rav5fzt89EXYmYl1ipqwKKW2Lp1uHTG02+byMj2wBftHUXys6+79Zeywihm2R0 A7/OABW7q18K4YMua5Cg/0/0qBIuyCubnIbrCNLQcnKCW55F2BKHa5R4sG7hsmMxrTnD GWUpHE9bYt74JRk+9AHaEU7CYCyLntSsk5HcV8tsg2zlAg4qRdAIk0HxZSlsYzAXcWeX C52DvGlUzHX+xcEHp8zOYlABAeZVyO85YC/MtUT3yLqTzKCzcTmNhwRmzcvNI78QTqKh cTEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-transfer-encoding; bh=wmEA7D8rOhjEu2NiUhLrUw/q2Xq2MBekIT1mUDAJl/A=; b=jMsar0Jssaz9nmEdwDlSb7NoSURL/FZsQTo4rrtUir5kmDysvhCe5MLiB/OWf55xa/ lW5NU1LlzBQSNZhCWAtj5HxCV7hACh62dC3JJdeRgy3MliuJiGLZpHAfkXzth1w6KoqH 6vXcQFI6J/OjZsA18M/VXrlnlU4N0bJe1GQskkN7pyws8KJw8GvW/tIq+MxjcuvLp9+Z bXBEqSU45rm4xUln1AGf1NXwCfNmzF4spd28YtIrXdPZicda7wGyo4XsFji2wayDEkwd dp4C+8xqm7bwCCjWlMPbzAmZdIXMOViNZiE+rX7rS/R49X2Zy/HYoXNAtRhpzCGHK0JD 0b+A== X-Gm-Message-State: APt69E0SpN2yRwtu3VHztBaTgmIvCiuozERaarZaLx8OecOEPD1/I+MI 9sCruYUiGvRTfyxfF8+z04uz6JZn X-Google-Smtp-Source: ADUXVKK9vVL2PDwmswyESDfaO6vZUXh1jlLpeAZHyTqKLg2c58voXAxZABhz2UwWr6DGR5x7rRIqTw== X-Received: by 2002:aed:3e26:: with SMTP id l35-v6mr955905qtf.102.1528247338824; Tue, 05 Jun 2018 18:08:58 -0700 (PDT) Received: from maverics (pool-108-35-88-207.nwrknj.fios.verizon.net. [108.35.88.207]) by smtp.gmail.com with ESMTPSA id 34-v6sm14259963qtt.76.2018.06.05.18.08.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 18:08:58 -0700 (PDT) Date: Tue, 5 Jun 2018 21:08:57 -0400 From: Teddy Reed To: u-boot@lists.denx.de Message-Id: <20180605210857.688122cf3f44bbd0e5bfa152@gmail.com> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Subject: [U-Boot] [RFC][PATCH] spl: vboot: Verify content before using load_addr X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" When using verified-boot in the SPL, the FIT content must be verified before it can be used. Currently the load_addr FIT property is read and used as input to memcpy before the property is verified. Signed-off-by: Teddy Reed Reviewed-by: Jun Nie --- common/spl/spl_fit.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 2321ebb0dde..a35c6092cee 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -244,6 +244,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, src = (void *)data; } +#ifdef CONFIG_SPL_FIT_SIGNATURE + printf("## Checking hash(es) for Image %s ...\n", + fit_get_name(fit, node, NULL)); + ret = fit_image_verify_with_data(fit, node, + (const void *)src, length); + printf("\n"); + if (!ret) + return 1; +#endif + #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS board_fit_image_post_process(&src, &length); #endif @@ -269,16 +279,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, image_info->entry_point = fdt_getprop_u32(fit, node, "entry"); } -#ifdef CONFIG_SPL_FIT_SIGNATURE - printf("## Checking hash(es) for Image %s ...\n", - fit_get_name(fit, node, NULL)); - ret = fit_image_verify_with_data(fit, node, - (const void *)load_addr, length); - printf("\n"); - return !ret; -#else return 0; -#endif } static int spl_fit_append_fdt(struct spl_image_info *spl_image,