From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jcajT-0000NF-Ah for mharc-grub-devel@gnu.org; Sat, 23 May 2020 16:26:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcajS-0000N5-6Q for grub-devel@gnu.org; Sat, 23 May 2020 16:26:58 -0400 Received: from mailout03.mx.bawue.net ([193.7.176.64]:53532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcajQ-0003zL-7Y for grub-devel@gnu.org; Sat, 23 May 2020 16:26:56 -0400 Received: from n-dimensional.de (p5b17584c.dip0.t-ipconnect.de [91.23.88.76]) (Authenticated sender: pdim@bawue.de) by smtp.bawue.net (Postfix) with ESMTPSA id 2431422611 for ; Sat, 23 May 2020 22:26:47 +0200 (CEST) Date: Sat, 23 May 2020 22:26:46 +0200 From: Hans Ulrich Niedermann To: grub-devel@gnu.org Subject: Re: Multiboot 2 Header Alignment: implementation contradicts specification Message-ID: <20200523222646.212cef79@n-dimensional.de> In-Reply-To: References: <20200523203317.491e85f8@n-dimensional.de> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanner: SAV Dynamic Interface 2.6.0, Engine: 3.77.1, SAV: 5.75 (F8623BC6) on relay01.mx.bawue.net using milter-sssp 0.1.0 X-Virus-Scan: Found to be clean. Received-SPF: pass client-ip=193.7.176.64; envelope-from=hun@n-dimensional.de; helo=mailout03.mx.bawue.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/23 16:19:33 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2020 20:26:58 -0000 On Sat, 23 May 2020 21:24:32 +0200 Jacob Paul via Grub-devel wrote: > On 2020-05-23 20:33, Hans Ulrich Niedermann wrote: > > The comment is valid for MB1, but not for MB2. Both regarding the > > alignment and regarding the size. And regarding the size, this > > actually means there is a bug in the code here: An MB2 header is at > > least 16 bytes for the header magic plus at least 8 bytes for the > > mb2 header termination tag. That adds up to 24 bytes for MB2, not > > 12 bytes as it did for MB1. > > I see, so there is at least that. Might be a good idea to fix it. See separate patch: Subject: [PATCH] mb2 loader: Fix header size, alignment for Multiboot 2 > > I fear you have missed that bytes and grub_uint32_t array elements > > are not the same size. > > I unfortunately did not notice the (grub_uint32_t *), I apologize for > assuming that it increments by 2 bytes and not u32's. Wouldn't it be > a lot cleaner if it just incremented it in bytes instead, since you > could then also remove the division by 4 and the cast? It wouldn't > make any difference runtime wise, just a bit easier to read. And it could be the same code as is in use elsewhere, namely in the Multiboot 1 loader. I have put that into a separate RFC patch: Subject: [PATCH RFC] mb2 loader: Use the same iteration code for MB2 as for MB1