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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BE9ECC433F5 for ; Wed, 12 Jan 2022 17:23:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EAEA083282; Wed, 12 Jan 2022 18:22:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="pViqchDM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D7CCC832DD; Wed, 12 Jan 2022 18:21:58 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 74E39831EF for ; Wed, 12 Jan 2022 18:21:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 250D8B8200F; Wed, 12 Jan 2022 17:21:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A417FC36AF3; Wed, 12 Jan 2022 17:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642008105; bh=6QR0nCQdv0paLr3/lNsxDt2YMYryoxG87B9yNmnqtyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pViqchDMAdST4xVmbTpPrURk7MRembP46ftx28zwgZyYajzHfT7gprnK17u/EbZ3P qQCMWpBK6zgiMMwnuaHsS8kx1hxW5wSljwbhGBamMtFlgPgSlLFjlIfx0KSiNl4f09 8P95Bbo6sok8sqCaroRYYZESGYRc3RGSG8KbumvyZoTdBxf1aNaIy73l3T0QdLT+Ft zXB/c0TYt67J/1YHa8rjkGobAq+Lsvi2AV7EJ4QJmEApeZEr7rpuKG8SiAVVUKr6ee VOnC52aKUfJtS2cnWGdnJuQrWKGtOYrQK75zD4YQDiTR5dcECFBCU6ODyb+FhJKTzw K+CzMukaNKmUQ== Received: by pali.im (Postfix) id 5A06C768; Wed, 12 Jan 2022 18:21:45 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Chris Packham Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell v2 09/20] tools: kwbimage: Check for maximal kwbimage header size Date: Wed, 12 Jan 2022 18:20:43 +0100 Message-Id: <20220112172054.5961-10-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220112172054.5961-1-pali@kernel.org> References: <20211221155416.8557-1-pali@kernel.org> <20220112172054.5961-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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 BootROM loads kwbimage header to L2-SRAM and BootROM reserve only 192 kB for it. Signed-off-by: Pali Rohár --- tools/kwbimage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index a5b518f60bc8..ce053a4a5a78 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -2033,6 +2033,11 @@ static int kwbimage_generate(struct image_tool_params *params, free(image_cfg); exit(EXIT_FAILURE); } + if (alloc_len > 192*1024) { + fprintf(stderr, "Header is too big (%u bytes), maximal kwbimage header size is %u bytes\n", alloc_len, 192*1024); + free(image_cfg); + exit(EXIT_FAILURE); + } break; default: -- 2.20.1