Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pyufo-0000J2-0I for mharc-grub-devel@gnu.org; Tue, 16 May 2023 09:25:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pyufi-0000I4-Aj for grub-devel@gnu.org; Tue, 16 May 2023 09:24:58 -0400 Received: from dibed.net-space.pl ([84.10.22.86]) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_3DES_EDE_CBC_SHA1:192) (Exim 4.90_1) (envelope-from ) id 1pyufg-0006xX-Nk for grub-devel@gnu.org; Tue, 16 May 2023 09:24:58 -0400 Received: from router-fw.i.net-space.pl ([192.168.52.1]:39782 "EHLO tomti.i.net-space.pl") by router-fw-old.i.net-space.pl with ESMTP id S2183917AbjEPNYa (ORCPT ); Tue, 16 May 2023 15:24:30 +0200 X-Comment: RFC 2476 MSA function at dibed.net-space.pl logged sender identity as: dkiper Date: Tue, 16 May 2023 15:24:25 +0200 From: Daniel Kiper To: Roger Pau Monne Cc: grub-devel@gnu.org, daniel.kiper@oracle.com, alexander.burmashev@oracle.com, phcoder@gmail.com Subject: Re: [PATCH v2] lib/relocator: always enforce the requested alignment in malloc_in_range() Message-ID: <20230516132425.btxhb6bbyeulximn@tomti.i.net-space.pl> References: <20230512073355.14322-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230512073355.14322-1-roger.pau@citrix.com> User-Agent: NeoMutt/20170113 (1.7.2) Received-SPF: pass client-ip=84.10.22.86; envelope-from=dkiper@net-space.pl; helo=dibed.net-space.pl X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 May 2023 13:24:58 -0000 On Fri, May 12, 2023 at 09:33:55AM +0200, Roger Pau Monne via Grub-devel wrote: > On failure to allocate from grub_relocator_firmware_alloc_region() in > malloc_in_range() the function would stop enforcing the alignment, and > the following was returned: > > lib/relocator.c:431: trying to allocate in 0x200000-0xffbf9fff aligned 0x200000 size 0x406000 > lib/relocator.c:1197: allocated: 0x74de2000+0x406000 > lib/relocator.c:1407: allocated 0x74de2000/0x74de2000 > > Fix this by making sure that target always contains a suitably aligned > address. After the change the return from the function is: > > lib/relocator.c:431: trying to allocate in 0x200000-0xffb87fff aligned 0x200000 size 0x478000 > lib/relocator.c:1204: allocated: 0x74c00000+0x478000 > lib/relocator.c:1414: allocated 0x74c00000/0x74c00000 > > Fixes: 3a5768645c05 ('First version of allocation from firmware') > Signed-off-by: Roger Pau Monné Reviewed-by: Daniel Kiper Daniel