Received: from list by lists.gnu.org with archive (Exim 4.71) id 1f60WL-00039G-Iv for mharc-grub-devel@gnu.org; Tue, 10 Apr 2018 17:09:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f60WJ-00037h-Ny for grub-devel@gnu.org; Tue, 10 Apr 2018 17:09:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f60WG-0006n3-HT for grub-devel@gnu.org; Tue, 10 Apr 2018 17:09:39 -0400 Received: from boksu.net-space.pl ([185.15.1.105]:37922) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.71) (envelope-from ) id 1f60WG-0006mE-6o for grub-devel@gnu.org; Tue, 10 Apr 2018 17:09:36 -0400 Received: (from localhost user: 'dkiper' uid#4000 fake: STDIN (dkiper@boksu.net-space.pl)) by router-fw-old.local.net-space.pl id S1835358AbeDJVJd (ORCPT ); Tue, 10 Apr 2018 23:09:33 +0200 Date: Tue, 10 Apr 2018 23:09:33 +0200 From: Daniel Kiper To: Kristian Amlie Cc: Daniel Kiper , grub-devel@gnu.org Subject: Re: Checksummed environments Message-ID: <20180410210933.GD25917@router-fw-old.local.net-space.pl> References: <20180406123535.GB22814@router-fw-old.local.net-space.pl> <0cb713c1-1605-eb86-8e48-86f900397394@northern.tech> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0cb713c1-1605-eb86-8e48-86f900397394@northern.tech> User-Agent: Mutt/1.3.28i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 185.15.1.105 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Apr 2018 21:09:41 -0000 On Fri, Apr 06, 2018 at 03:08:23PM +0200, Kristian Amlie wrote: > On 06/04/18 14:35, Daniel Kiper wrote: > > On Fri, Apr 06, 2018 at 11:25:22AM +0200, Kristian Amlie wrote: > >> Hey, I work for Northern.tech, developing update software for embedded > >> Linux devices. > >> > >> I have a question about GRUB's environment block: This block is not > > > > I am not sure what exactly you mean by "GRUB's environment block". > > Could you send me some references to the code? > > Of course, sorry if the context wasn't clear. I'm talking about the > environment block mentioned here: > https://www.gnu.org/software/grub/manual/grub/grub.html#Environment-block, > which is used to store information from one boot to the next, using > save_env and load_env. > > >> checksummed, and hence I reckon it can become corrupt if power is lost > >> in the middle of a write. > > > > What about the other blocks? > > In theory, there is only one block, because it is written in-place, > directly on disk, without changing any other filesystem blocks. Is that > what you meant by "other blocks"? > > >> This is an important safety criterion for us, so we've been thinking of > >> developing environment block checksumming as an extension to the > >> existing save_env and load_env commands. The most likely approach will > >> be to grab X amount of bytes at the end of the block and use these for > >> the checksum. > > > > Could you tell us more about that? > > The idea comes from U-Boot [1], which uses a dedicated block on a > storage device to store data, and uses a CRC32 checksum to make sure it > is consistent. The motivation is to be able to detect that the block is > corrupt, rather than accepting a block of data that may have incorrect > data in if a write was interrupted midway by a powerloss. You can read > more about it in the link. > > [2] https://www.denx.de/wiki/DULG/UBootEnvVariables I am OK with the idea. However, I think that the feature should have a kind of switch to turn it off/on. At first sight it looks that new environment variable is sufficient for it. Daniel