From patchwork Mon May 3 23:11:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1473537 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DsfQR5Nv; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FYzXg5vwzz9sCD for ; Tue, 4 May 2021 09:22:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AFD1C82B01; Tue, 4 May 2021 01:22:40 +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="DsfQR5Nv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D52CE82B5E; Tue, 4 May 2021 01:22:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 8F15282D4B for ; Tue, 4 May 2021 01:12:37 +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-il1-x12b.google.com with SMTP id l19so4882536ilk.13 for ; Mon, 03 May 2021 16:12:37 -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=2hs43t5Xc/rqQ3nOoeb+KDwcFXzS3U+xAjH8KGmvFWc=; b=DsfQR5NvsHDCNz8WRzZxr3zrqLD1/6nUrg/AbqYZAIyuwW+kwyhZVwqVTwuooKZ7R+ SQKb/kvEdfEfxPeeMo4kMlZAWFpOV0/gLB7AUiZzjGigOdbw3GzUMIx+t14JgZ5jttLu u3i9wbIRdDk2j6OAELg0LvFpQwi6r5FRkaDrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2hs43t5Xc/rqQ3nOoeb+KDwcFXzS3U+xAjH8KGmvFWc=; b=RjhRNjyHADX/cFU2zu+4LXp5CWzWkDQG3weGO+XNK6duBZkvR7AHFyW1DzPt/yPeMt n7BUcvdvtivehzGCntALAEhkxPlTbxm/ONN+hj6ap1yBJOR9cgmh9t9hWOzYUQYv3/XB hEfXALKG5unKQB7raYJflX/Qv0mBSQ0py8WM/Tp/Vp2jYvpNHaweqW6PFQOMxh0O1o6g sJt05V6/v4drAasxCKZWg+kr2GCVqjEv4C4P8n91PLmY2h5rM+UF9vagSTKH69mCxlZq RDYQdDudQz7CQeeMzAIeEoEj0xAGPL7aTvVb3dW9wb1gO7LirT9Uztgwzgsf4PAmPGxS S5LQ== X-Gm-Message-State: AOAM530lLaCY+v8t51g6Y99spa2XT+ACunclS7fM/kOsXV6im8mlI/CX leLa4Jz0LNfvTDyp0Ra8wbd8XSAyw4f0qQ== X-Google-Smtp-Source: ABdhPJzPJmY8UncUQIa3eTFMeu+iE7a3G8GjD8K9ih9K8wRSG7zEzZ0dmKumG1DCium5msdvAKOhoQ== X-Received: by 2002:a05:6e02:1ba5:: with SMTP id n5mr17393792ili.45.1620083556192; Mon, 03 May 2021 16:12:36 -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 o6sm422727ioa.21.2021.05.03.16.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 16:12:35 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Bin Meng , Robert Marko , Andre Przywara , Masahiro Yamada , Simon Glass , Alexandru Gagniuc , Joe Hershberger , Joel Peshkin , Joel Stanley , Klaus Heinrich Kiwi , Marek Vasut , Michal Simek , Patrick Delaunay , Sebastian Reichel , Siew Chin Lim , Thirupathaiah Annapureddy Subject: [PATCH 46/49] image: Remove some #ifdefs from image-fit and image-fit-sig Date: Mon, 3 May 2021 17:11:33 -0600 Message-Id: <20210503231136.744283-19-sjg@chromium.org> X-Mailer: git-send-email 2.31.1.527.g47e6f16901-goog In-Reply-To: <20210503231136.744283-1-sjg@chromium.org> References: <20210503231136.744283-1-sjg@chromium.org> MIME-Version: 1.0 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.102.4 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 03a6e6f214f..a31d9847124 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -191,6 +191,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 12a6745c642..22f89861048 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 f8aa61fc99d..882e872144f 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1993,9 +1993,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; @@ -2087,8 +2084,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);