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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73304C61DA4 for ; Thu, 2 Feb 2023 11:23:51 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.488748.756977 (Exim 4.92) (envelope-from ) id 1pNXgf-0004CQ-Fk; Thu, 02 Feb 2023 11:23:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 488748.756977; Thu, 02 Feb 2023 11:23:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pNXgf-0004CJ-Cq; Thu, 02 Feb 2023 11:23:29 +0000 Received: by outflank-mailman (input) for mailman id 488748; Thu, 02 Feb 2023 11:23:28 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pNXge-0004CD-41 for xen-devel@lists.xenproject.org; Thu, 02 Feb 2023 11:23:28 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pNXgd-0000po-L8; Thu, 02 Feb 2023 11:23:27 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=[192.168.13.48]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pNXgd-0000Vt-FR; Thu, 02 Feb 2023 11:23:27 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=x/EtjnLXPMVGOEp5mtmu9HbFmS/ExaZ1FcZQ0QFbics=; b=W1OVWcPb9l+azIY8WynzO2Xr7U GVAygdQ9FM90Af2Or2UXkPuNig6uqvURU8dmLlvlmCgnQnkMgmGLDNMvwA1DbkGqX0pET33ve39BM KloEsp4kzKOVT6qgIojEit41Jf+/zEf1MHgI7QHmeQFxahtVyG6JEemFAzmw7mZY9Y9Q=; Message-ID: Date: Thu, 2 Feb 2023 11:23:25 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v2 2/2] xen/arm: Add support for booting gzip compressed uImages Content-Language: en-US To: Michal Orzel , xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk , ayankuma@amd.com References: <20230202084905.6950-1-michal.orzel@amd.com> <20230202084905.6950-3-michal.orzel@amd.com> <3ef695c9-9b5e-3323-a901-d6daf030e07d@xen.org> From: Julien Grall In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02/02/2023 11:12, Michal Orzel wrote: > Hi Julien, Hi Michal, > > On 02/02/2023 12:01, Julien Grall wrote: >> >> >> Hi Michal, >> >> On 02/02/2023 08:49, Michal Orzel wrote: >>> @@ -265,11 +284,14 @@ static __init int kernel_decompress(struct bootmodule *mod) >>> #define IH_ARCH_ARM 2 /* ARM */ >>> #define IH_ARCH_ARM64 22 /* ARM64 */ >>> >>> +/* uImage Compression Types */ >>> +#define IH_COMP_GZIP 1 >>> + >>> /* >>> * Check if the image is a uImage and setup kernel_info >>> */ >>> static int __init kernel_uimage_probe(struct kernel_info *info, >>> - paddr_t addr, paddr_t size) >>> + struct bootmodule *mod) >>> { >>> struct { >>> __be32 magic; /* Image Header Magic Number */ >>> @@ -287,6 +309,8 @@ static int __init kernel_uimage_probe(struct kernel_info *info, >>> } uimage; >>> >>> uint32_t len; >>> + paddr_t addr = mod->start; >>> + paddr_t size = mod->size; >>> >>> if ( size < sizeof(uimage) ) >>> return -EINVAL; >> >> Shouldn't we return -ENOENT here? > Frankly speaking, I do not want to fall through in such a case. > If a kernel size is less than 64B, something is wrong, isn't it? I agree something is likely wrong but this should not be the job of kernel_uimage_probe() to enforce this for everyone. To give a concrete example, let's imagine we decide to re-order the call so kernel_uimage_probe() happens *after* an new header A than would require 128 bytes (the number is made up). It would be wrong for A to return -EINVAL because the other protocol may require a smaller size. The same goes here even at least for consistency. So if you really want to enforce a minimum size, then such check should be in the caller. Then each probe could return -ENOENT if the size is too small. > I am not sure if Xen would handle a kernel whose size is less than a page. I don't see any reason why it would not be. > > I do not like the whole falling through in kernel_probe even in case of obvious violations. > But this is something not related to this series so I added to my TODO to properly handle > the return types from kernel_probe path. If you really think, we should return -ENOENT here, > then ok (although I do not like it). Could this be done on commit if you insist on that? See above for an alternative proposal. Depending on the version we settle on I can do it on commit (but this is not going to happen today as OSSTEst is still blocked). Cheers, -- Julien Grall