From patchwork Thu Nov 11 15:59:49 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: 1554011 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=sc6x4LWW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4Hqmdp5tW9z9s1l for ; Fri, 12 Nov 2021 03:00:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2542D83A35; Thu, 11 Nov 2021 17:00:20 +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="sc6x4LWW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D05B83A61; Thu, 11 Nov 2021 17:00:12 +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 mail.kernel.org (mail.kernel.org [198.145.29.99]) (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 9C95483A35 for ; Thu, 11 Nov 2021 16:59: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=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 7E0586124D; Thu, 11 Nov 2021 15:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636646398; bh=8rCT4KWv0DH+y9TJIaY9G0+iIPzNpv5c0NoNN3FjWV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sc6x4LWWedSBcQ0o7zymU+/AMfC3bAPXDcfwyYhXL6A2yghuX3w6Vb8ToOsXxlQaf i7n3stJIaTYe4pF7Wm73hNfBS/gu32v4XZHVZIdsJKE3O14goxS5v/k6tZ5dH3oRhK vu+WHXXi2N2YcUxIzFpOTqyCRY8vFri+XTWPyI+1W/35l/VqnbC9HowA/iK57Dp7eu sHXT7m0bKAqT+7Q8CKAL9j1YeAE6rBN7sQtAQVjyQvginylKTTwrQhsdho3/yBBXim YeBeiF2hPKx0+WlowYJtakX5VCWPhsA+NgH7jFamFZgA6/BMeogw6BDChBSlHjE9oo Ztmbk6b8Yt8MA== 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 1/5] arm: mvebu: Check that kwbimage offset and blocksize are valid Date: Thu, 11 Nov 2021 16:59:49 +0100 Message-Id: <20211111155953.31526-2-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211111155953.31526-1-kabel@kernel.org> References: <20211111155953.31526-1-kabel@kernel.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.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 --- arch/arm/mach-mvebu/spl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 73c4b9af3e..71994e44f1 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -163,6 +163,16 @@ 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 in kwbimage\n"); + return -EINVAL; + } + + if (mhdr->blocksize <= 4 || mhdr->blocksize % 4 != 0) { + printf("ERROR: Wrong blocksize in kwbimage\n"); + return -EINVAL; + } + spl_image->size = mhdr->blocksize; spl_image->entry_point = mhdr->execaddr; spl_image->load_addr = mhdr->destaddr;