From patchwork Mon Oct 19 02:41:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1383975 X-Patchwork-Delegate: sjg@chromium.org 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; dmarc=pass (p=none dis=none) header.from=chromium.org 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=aV5bq5Ik; 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 4CF1NR3Ss0z9sSG for ; Mon, 19 Oct 2020 13:46:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DDA66824B7; Mon, 19 Oct 2020 04:42:35 +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="aV5bq5Ik"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 890B48243E; Mon, 19 Oct 2020 04:42:09 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 3E32182432 for ; Mon, 19 Oct 2020 04:42:05 +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-io1-xd42.google.com with SMTP id u19so11335156ion.3 for ; Sun, 18 Oct 2020 19:42:05 -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=EmfJ8rm8w0Uen+uKLa6VBKVEeOd/hggH3awg/OognHo=; b=aV5bq5IkTHmFEGNrYITdN5GTuwwaItsPqqhekFcIzkF9pVJvd1yk0cUmdysqqiPsem vot45U5EFzOsCpLFpK1GdAZse/7mVLEZyJgrvTmV54lwwbmI9OSphVVfDb1Ca7rOPSjR jB5gBiSWta6dM6quFZnnPijduMtPxF4fGsKWA= 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=EmfJ8rm8w0Uen+uKLa6VBKVEeOd/hggH3awg/OognHo=; b=qi4+BjLLUJbd46/SA1nG5jl1bnTRcwMshYwfaO6FELTXYdd1Ket7XV+jkfv6ZQquv/ SyMLXT0VAA8zFwcR2cxw8N7biLNphnluXew/tXetGXdt6h9xt4ZGopUCMRyKz2+73xLX GQoIBFJWZ+0muGHfcVCKbZord20CpiFCIkaAOc9Zl8WxzRixMIjvL8fYyvCueIP1rA+Y RC5YmPPzt2Sll+9zpXZ3zZS81QxPZYupjK8jvfGMNbKSN/K8PYOPWyqZIuyJDidGDN/C u0VdTmcWWJ7L9xjRAi03zVove/yW+6Xlt0ECRJU0rsZAg4nK7fICmGVbrT6cpx5x816N Iv2Q== X-Gm-Message-State: AOAM530XXNW8+M0laQ4hDkmqGMYBDwCzXvfttsqRMyPZeV3TDmNQJGUZ SXb3RLnx+W+sLaL46OipIqlmdH4nvlkn8cvN X-Google-Smtp-Source: ABdhPJz43tOGv5yhP3vXxA6AR1KOBoZ2D1F6t6nYwKI2/VyEkyDCJ24/G1SkQYCEwKM50wEmNGLUBg== X-Received: by 2002:a02:3b57:: with SMTP id i23mr10262313jaf.110.1603075324068; Sun, 18 Oct 2020 19:42:04 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id g185sm9750871ilh.35.2020.10.18.19.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2020 19:42:03 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alper Nebi Yasak , Bin Meng Subject: [PATCH 22/25] binman: Update CheckEntries() for compressed sections Date: Sun, 18 Oct 2020 20:41:35 -0600 Message-Id: <20201019024138.3804540-22-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201019024138.3804540-1-sjg@chromium.org> References: <20201019024138.3804540-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.3 at phobos.denx.de X-Virus-Status: Clean At present this function assumes that the size of a section is at least as large as its contents. With compression this is often not the case. Relax this constraint by using the uncompressed size, if available. Signed-off-by: Simon Glass --- tools/binman/etype/section.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 1618bebe4be..b146239b779 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -299,19 +299,21 @@ class Entry_section(Entry): def CheckEntries(self): """Check that entries do not overlap or extend outside the section""" + max_size = self.size if self.uncomp_size is None else self.uncomp_size + offset = 0 prev_name = 'None' for entry in self._entries.values(): entry.CheckEntries() if (entry.offset < self._skip_at_start or entry.offset + entry.size > self._skip_at_start + - self.size): + max_size): entry.Raise('Offset %#x (%d) size %#x (%d) is outside the ' "section '%s' starting at %#x (%d) " 'of size %#x (%d)' % (entry.offset, entry.offset, entry.size, entry.size, self._node.path, self._skip_at_start, - self._skip_at_start, self.size, self.size)) + self._skip_at_start, max_size, max_size)) if entry.offset < offset and entry.size: entry.Raise("Offset %#x (%d) overlaps with previous entry '%s' " "ending at %#x (%d)" %