Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaPjE-0000bF-MF for mharc-grub-devel@gnu.org; Fri, 11 Sep 2015 10:55:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaPjB-0000Vi-Uv for grub-devel@gnu.org; Fri, 11 Sep 2015 10:55:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaPj8-0003xs-PZ for grub-devel@gnu.org; Fri, 11 Sep 2015 10:55:01 -0400 Received: from yes.iam.tj ([109.74.197.121]:56640 helo=iam.tj) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaPj8-0003w9-HF for grub-devel@gnu.org; Fri, 11 Sep 2015 10:54:58 -0400 Received: by iam.tj (Postfix, from userid 1013) id AFF4D34107; Fri, 11 Sep 2015 15:54:56 +0100 (BST) To: grub-devel@gnu.org Subject: Re: cryptodisk: teach =?UTF-8?Q?grub=5Fcryptodisk=5Finsert=28=29?= =?UTF-8?Q?=20about=20partitions=20=28bug=20=23=34=35=38=38=39=29?= X-PHP-Originating-Script: 1013:rcmail.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Date: Fri, 11 Sep 2015 15:54:56 +0100 From: TJ In-Reply-To: <55F2E119.8020302@gmail.com> References: <55EF0EFB.5060103@gmail.com> <55F2E119.8020302@gmail.com> Message-ID: <1bdb53606c12c9360f05ba5995791018@iam.tj> X-Sender: grub-devel@iam.tj User-Agent: Roundcube Webmail/RCMAIL_VERSION X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 109.74.197.121 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 14:55:03 -0000 On 11-09-2015 15:11, Andrei Borzenkov wrote: > 09.09.2015 04:18, TJ =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> On 08-09-2015 17:38, Vladimir '=CF=86-coder/phcoder' Serbinenko wrote: >>> On 06.09.2015 21:10, TJ wrote: >>>> https://savannah.gnu.org/bugs/index.php?45889 >>>> + if ((disk->partition && disk->partition->number =3D=3D >>>> dev->partition_number) || >>>> + (!disk->partition && dev->partition_number =3D=3D 0)) >>>> + return dev; >>> Please store and compare partition start, not parition number as the >>> same partition can be available several times through different=20 >>> partiton >>> schemes under different numbers. Additionally this allows to use >>> get_partition_start which already has the logic of handling empty >>> partitions >>=20 >> Done and tested. Works perfectly. >>=20 >=20 > Well, should not it also compare disk sizes (grub_disk_get_size)? > Also grub_partition_get_start cannot differentiate between full disk > (start =3D=3D 0) and partition that starts at offset 0. My original patch differentiated based on partition_number =3D=3D 0=20 indicating a non-partitioned disk (assuming 1-based partition numbers). Vladimir asked me to use grub_partition_get_start() due to multiple=20 partitioning schemes. I was concerned the function has no concept of an=20 error indicator but as it returns 0 when no partitions are found that is=20 equivalent (although it could be argued it has dual-use if it is=20 possible for a partition to start at sector 0). In grub_cryptodisk_insert() partition_start =3D=3D 0 means it is a whole=20 disk. In this if() clause the disk has already been confirmed identical and=20 so the only question is whether the cryptodisk is a whole-disk or a=20 partition, and if so which partition. As the starting sector is being stored and that is a unique value=20 per-disk, regardless of if there are multiple partition schemes (e.g.=20 GPT + Hybrid MBR) the starting sectors will be identical. If the partition lengths are different (in the multiple partition=20 schemes) isn't that a bug in the partitioning and something grub doesn't=20 need to concern itself about? In the event of the partition matching failing the function behaves as=20 it has done previously, returning the whole device.