From patchwork Fri Nov 26 14:37:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1560167 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Sx7iccTR; dkim-atps=neutral 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4J0y5t3c1Bz9t2p for ; Sat, 27 Nov 2021 01:38:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C867F836C5; Fri, 26 Nov 2021 15:37:59 +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="Sx7iccTR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5581A8371B; Fri, 26 Nov 2021 15:37:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (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 6B0D682FE1 for ; Fri, 26 Nov 2021 15:37:47 +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=kabel@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 dfw.source.kernel.org (Postfix) with ESMTPS id C89D26227B; Fri, 26 Nov 2021 14:37:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F55CC004E1; Fri, 26 Nov 2021 14:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637937465; bh=DYF3PCs1Q0YcE2xx7Cj5wDIchopXIqb5ZIOLp8BJ+Zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sx7iccTRWE5Vv1ij3eSVQEzRJVzGFsz5A4rBy/ucW6EzLfDWfH+4j01Wi36CNruFx HYw+54JgsguuscDzdbJOjebGI13MEvK3FQFLfN+7gdQViv/fyxmgD3FIEqhLZGI7eK ak2//6McwYUDRCZJVRsgWREz15AdtF76ta2C+DyDdlNfRY9zn+TJX8ekZmUvBX6NpW RS01QePJ3YjzQOqhEx0LM8zkWw4tx18BQXBkpNHOoqEfLIPOaJ+LO/OVT2t48lLl7W g8X8lWpqN0YbbyHUXxtNJB3Xv3HSToHpD7AKr+JA8I0VCMhPSfG8Y8poIGGB7v43Ye 4Wi7dQadkZ/HA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-marvell v2 1/9] arm: mvebu: Check that kwbimage offset and blocksize are valid Date: Fri, 26 Nov 2021 15:37:30 +0100 Message-Id: <20211126143738.23830-2-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211126143738.23830-1-kabel@kernel.org> References: <20211126143738.23830-1-kabel@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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 From: Pali Rohár There are certain restrictions for kwbimage offset and blocksize. Validate them. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Reviewed-by: Stefan Roese --- Changes since v1: - updated error messages as requested by Stefan --- arch/arm/mach-mvebu/spl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 73c4b9af3e..a6ed4367dd 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -163,6 +163,18 @@ int spl_parse_board_header(struct spl_image_info *spl_image, spl_image->offset *= 512; #endif + if (spl_image->offset % 4 != 0) { + printf("ERROR: Wrong srcaddr (%u) in kwbimage\n", + spl_image->offset); + return -EINVAL; + } + + if (mhdr->blocksize <= 4 || mhdr->blocksize % 4 != 0) { + printf("ERROR: Wrong blocksize (%u) in kwbimage\n", + mhdr->blocksize); + return -EINVAL; + } + spl_image->size = mhdr->blocksize; spl_image->entry_point = mhdr->execaddr; spl_image->load_addr = mhdr->destaddr;