From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1427CC433F5 for ; Sun, 26 Sep 2021 01:47:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8CB1760184 for ; Sun, 26 Sep 2021 01:47:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8CB1760184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8CAFE835DA; Sun, 26 Sep 2021 03:47:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="YHUaP6FK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0F4A083596; Sun, 26 Sep 2021 03:45:20 +0200 (CEST) Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B3071835EA for ; Sun, 26 Sep 2021 03:44:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x232.google.com with SMTP id u22so20291989oie.5 for ; Sat, 25 Sep 2021 18:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5O/iaPj1AKlW1E6rW06QPWicK1r9HijosxWGHZLSwms=; b=YHUaP6FK2BXVus7X8omU7DSlQYFeWl5GJfWmFDssZPJjjnUqAU6ZMMyZ+C2eQzh1RL /PyGot6+JvaKBzDhM3UDUTCedhqcvxuA9t4NZbQiyqM71ovVgOC+cnpwcdwLskH5OigV YglyUib6cpLKvmXBUt/ItUwwoVqgu/UQYRA7A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5O/iaPj1AKlW1E6rW06QPWicK1r9HijosxWGHZLSwms=; b=C/XgfXvRkobvshq1WPYF2cG6ARXTPI58yiKlSe5+5GVJSZgVsgubp1Ei0zWpZ6VUuD FI0wVO714upNmAYOtq+loT48n51bbT8LkVOvIIcjQKJQiozZItnhtxsY6fYtsAGZim6Y Na0AFLyW0X3fRGAAIN2JtoeQK3Gv1GdZ8Su2gMX08/7VJaW3e4gUkZU5CJBEqtGCDZ2W nqMo8JNe9h0uybPnGZ/4qOo7dZjP8SCeksPiY54Njw6u9SbaGfwjk3KN4/mN456L+Lt+ BDznVR10q0rgcdyybaOdqlwgOFS7ENwYnVvF4R9gYCZxIDtD5BMndn6SzwGxH9DTIDbt p98A== X-Gm-Message-State: AOAM530taYH6F9gRMbLz53d3StCSx+y4it9XprrPAbGFsD/LUNjip48C NiKxQxPKdLLvAnxWOYArodeizheDY79AvA== X-Google-Smtp-Source: ABdhPJzO3KUe9x6TGUGLSkRINHIr73xo7KGBK3Oygy/LzgBCd0ge/LyUU1DOoYqxNRm5k22ca+QvFQ== X-Received: by 2002:aca:4b8d:: with SMTP id y135mr6972931oia.177.1632620656235; Sat, 25 Sep 2021 18:44:16 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id c18sm330378otr.72.2021.09.25.18.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Sep 2021 18:44:15 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alexandru Gagniuc , Andre Przywara , Rasmus Villemoes , Robert Marko , Masahiro Yamada , Tom Rini , Simon Glass , Joe Hershberger , Marek Vasut Subject: [PATCH v5 26/29] image: Remove some #ifdefs from image-fit and image-fit-sig Date: Sat, 25 Sep 2021 19:43:39 -0600 Message-Id: <20210926014342.127913-20-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog In-Reply-To: <20210926014342.127913-1-sjg@chromium.org> References: <20210926014342.127913-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 Drop the #ifdefs which are easy to remove without refactoring. Signed-off-by: Simon Glass --- (no changes since v1) common/Kconfig.boot | 10 ++++++++++ common/image-fit-sig.c | 8 ++------ common/image-fit.c | 7 ++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/common/Kconfig.boot b/common/Kconfig.boot index f23b9988521..9b84a8d005f 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -165,6 +165,16 @@ config SPL_FIT_SIGNATURE select SPL_IMAGE_SIGN_INFO select SPL_FIT_FULL_CHECK +config SPL_FIT_SIGNATURE_MAX_SIZE + hex "Max size of signed FIT structures in SPL" + depends on SPL_FIT_SIGNATURE + default 0x10000000 + help + This option sets a max size in bytes for verified FIT uImages. + A sane value of 256MB protects corrupted DTB structures from overlapping + device memory. Assure this size does not extend past expected storage + space. + config SPL_LOAD_FIT bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)" select SPL_FIT diff --git a/common/image-fit-sig.c b/common/image-fit-sig.c index e95e64bd2fe..4edebbf2d32 100644 --- a/common/image-fit-sig.c +++ b/common/image-fit-sig.c @@ -49,10 +49,8 @@ struct image_region *fit_region_make_list(const void *fit, * Use malloc() except in SPL (to save code size). In SPL the caller * must allocate the array. */ -#ifndef CONFIG_SPL_BUILD - if (!region) + if (!IS_ENABLED(CONFIG_SPL_BUILD) && !region) region = calloc(sizeof(*region), count); -#endif if (!region) return NULL; for (i = 0; i < count; i++) { @@ -72,12 +70,10 @@ static int fit_image_setup_verify(struct image_sign_info *info, char *algo_name; const char *padding_name; -#ifndef USE_HOSTCC - if (fdt_totalsize(fit) > CONFIG_FIT_SIGNATURE_MAX_SIZE) { + if (fdt_totalsize(fit) > CONFIG_VAL(FIT_SIGNATURE_MAX_SIZE)) { *err_msgp = "Total size too large"; return 1; } -#endif if (fit_image_hash_get_algo(fit, noffset, &algo_name)) { *err_msgp = "Can't get hash algo property"; return -1; diff --git a/common/image-fit.c b/common/image-fit.c index 3952ab749ad..5a377a7f85f 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -2009,9 +2009,6 @@ int fit_image_load(bootm_headers_t *images, ulong addr, int type_ok, os_ok; ulong load, load_end, data, len; uint8_t os, comp; -#ifndef USE_HOSTCC - uint8_t os_arch; -#endif const char *prop_name; int ret; @@ -2103,8 +2100,12 @@ int fit_image_load(bootm_headers_t *images, ulong addr, } #ifndef USE_HOSTCC + { + uint8_t os_arch; + fit_image_get_arch(fit, noffset, &os_arch); images->os.arch = os_arch; + } #endif bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL); -- 2.33.0.685.g46640cef36-goog