From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1o5SSL-0006mY-GB for mharc-grub-devel@gnu.org; Sun, 26 Jun 2022 09:37:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5SSJ-0006mM-UO for grub-devel@gnu.org; Sun, 26 Jun 2022 09:37:39 -0400 Received: from mail-4323.proton.ch ([185.70.43.23]:39783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5SSF-00065Q-Vh for grub-devel@gnu.org; Sun, 26 Jun 2022 09:37:39 -0400 Date: Sun, 26 Jun 2022 13:37:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomin.one; s=protonmail; t=1656250630; x=1656509830; bh=budV5CS4LJ7zOOp3BSCOt3erI3u9sDyX0hhnJsLu6ek=; h=Date:To:From:Reply-To:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=PR84DPB4Wr+x9KASIpcm3H1ssswbbYlruTa2yegmuxBBkE2HdXundcuwXhzYzJLwC x/pJlWQXEk3U5i3rhMFjlCu/DSoYrHthYfR01oYi/6B8ohC2PqIcpDsv7hE5tLphVC ViGaXLKKV+5+cdM7ZsG3TJhs8X0MPRAz+5DlhfqKNE+GLivVEFYWaLrmUTTZjG0vcy bQg+QEErjurjrsHl7kCm+3CjFEuLvZRv/cKMbHFAC4JNWdV0oqJLF6VG7jLWoH2qAd jxlSutMCfZsVn9aK2XF9r4sPbJAAdqRR9i3HXx9NIOcH56xLdXkqU0N2UDSMXnM0Py LpawBPi+8qDlQ== To: development@efficientek.com, "grub-devel@gnu.org" From: Maxim Fomin Reply-To: Maxim Fomin Subject: Re: [PATCH v3 1/1] plainmount: Support plain encryption mode. Message-ID: In-Reply-To: <20220624195541.1bf8fd17@crass-HP-ZBook-15-G2> References: <20220624195541.1bf8fd17@crass-HP-ZBook-15-G2> Feedback-ID: 10594471:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.43.23; envelope-from=maxim@fomin.one; helo=mail-4323.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, 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: Sun, 26 Jun 2022 13:37:40 -0000 ------- Original Message ------- On Saturday, June 25th, 2022 at 12:55 AM, Glenn Washburn wrote: > > Hmm, I wasn't suggesting this be added. I hope you didn't think I was > suggesting this. What I was suggesting was that the block list syntax > already supported in GRUB for device paths be used, not creating a new > block list syntax just for this command. You shouldn't need to add any > new code for what I was suggesting. > > For instance, if you know that your plain mount volume is on device > (hd0) at offset 1M and have a keyfile at (hd1)/path/to/keyfile where > the key material is offset 35235 bytes into that file you would use: > > loopback cplain0 (hd0)2048+ > plainmount -c ... -s ... -d (hd1)/path/to/keyfile -O 35235 (cplain0) > > If the keyfile data is on disk (hd1) at offset 16708 (16*1024 + 324), > then use: > > plainmount -c ... -s ... -d (hd1)32+ -O 324 (cplain0) > > or > > plainmount -c ... -s ... -d (hd1)+ -O 16708 (cplain0) > > Here the '+' is needed after (hd1) to turn it into a file because -d > should only take a file. It would be nice to have (hd1) be treated as > (hd1)+ when used as a file, but that would be a different patch. > > The drawback to what I'm suggesting is that you can't do "-d > (hd1)16K+". This could be something interesting to add to GRUB > blocklist syntax, but as a separate patch. > > I believe there's also a confusion here on the usage of blocklist > syntax. Blocklist syntax is about specifying a range of blocks, not an > offset or specific block number. So for instance, "(hd1)+16" means > blocks 0-15, a total of 8K bytes, so bytes past 8K are unreadable. On > the other hand, "(hd1)16+" means blocks 16 to end of device. I think the > latter is what you want. > ... > > +/ Read keyfile as a disk segment */ > > +static grub_err_t > > +plainmount_configure_keydisk (grub_cryptodisk_t dev, char *keyfile, gr= ub_uint8_t *key_data, > > + grub_size_t key_size, grub_size_t keyfile_offset) > > > I don't think this function should exist either. Using GRUB's already > existing blocklist syntax (see example above) and with -O for > specifying keyfile offset, we don't need this. > ... > > + / Configure keyfile/keydisk/password */ > > + if (cargs.keyfile) > > + if (cargs.keyfile[0] =3D=3D '/' || > > + (grub_strchr (cargs.keyfile, ')') < grub_strrchr(cargs.keyfile,'/'))) > > + err =3D plainmount_configure_keyfile (dev, cargs.keyfile, cargs.key_d= ata, > > + cargs.key_size, cargs.keyfile_offset); > > + else > > + err =3D plainmount_configure_keydisk (dev, cargs.keyfile, cargs.key_d= ata, > > + cargs.key_size, cargs.keyfile_offset); > > > We shouldn't support sending a device as a keyfile and only support > files. As noted above, if the keyfile data is only accessibly via some > blocks on a disk device, then use the builtin blocklist syntax > potentially with the -O keyfile offset. > > > Glenn I don't quite understand this. Irrespective of how device argument is sent = (and syntax used), processing device blocks in 'configure_keyfile()' differes from processing = a file. I tested grub_file_open() on a loopback device and it does not work. It makes sense,= because neither '(hdx,gpty)NNN+' nor a loopback node on top of it is a file. So, I think th= at supporting blocks on disk requires some additional code in 'configure_keyfile()'. Perh= aps you mean moving 'configure_keydisk()' code inside 'plainmount_configure_keyfile()' and remo= ving it definition? Or I am missing something? Best regards, Maxim Fomin