Skip to contentSkip to conversation

Checksummed environments

DISCUSSION Kristian Amlie 2 participants 8 messages Apr 6, 2018 – Apr 12, 2018

lore
Share & tools
lore
#0 lore raw

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 checksummed, and hence I reckon it can become corrupt if power is lost in the middle of a write.

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.

This would also allow us to fall back to an earlier environment file if the current one is corrupt, hence implementing redundancy.

Is this something that the GRUB project would be interested in? We want to upstream this if possible, since we think many people may benefit from this.

Signature · 1 line
Kristian
#1 lore raw
Quoted 4 lines · Kristian Amlie

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?

Quoted 2 lines

checksummed, and hence I reckon it can become corrupt if power is lost in the middle of a write.

What about the other blocks?

Quoted 5 lines

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?

Quoted 6 lines

This would also allow us to fall back to an earlier environment file if the current one is corrupt, hence implementing redundancy.

Is this something that the GRUB project would be interested in? We want to upstream this if possible, since we think many people may benefit from this.

Great! However, first of all we need some more info about that.

Daniel

#2 lore raw
Quoted 8 lines · Daniel Kiper
Quoted 4 lines · Kristian Amlie

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.

Quoted 4 lines
Quoted 2 lines

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"?

Quoted 7 lines
Quoted 5 lines

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

Signature · 1 line
Kristian
Quoted 12 lines
Quoted 7 lines

This would also allow us to fall back to an earlier environment file if the current one is corrupt, hence implementing redundancy.

Is this something that the GRUB project would be interested in? We want to upstream this if possible, since we think many people may benefit from this.

Great! However, first of all we need some more info about that.

Daniel

#3 lore raw
Quoted 33 lines · Kristian Amlie
Quoted 8 lines · Daniel Kiper
Quoted 4 lines · Kristian Amlie

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.

Quoted 4 lines
Quoted 2 lines

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"?

Quoted 7 lines
Quoted 5 lines

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?

Quoted 8 lines

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

#4 lore raw
Quoted 41 lines · Daniel Kiper
Quoted 40 lines · Kristian Amlie
Quoted 8 lines · Daniel Kiper
Quoted 4 lines · Kristian Amlie

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.

Quoted 4 lines
Quoted 2 lines

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"?

Quoted 7 lines
Quoted 5 lines

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.

Quoted 5 lines
Quoted 1 line

[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.

And/Or an argument for save_env/load_env...

Daniel

#5 lore raw
Quoted 42 lines · Daniel Kiper
Quoted 41 lines · Daniel Kiper
Quoted 40 lines · Kristian Amlie
Quoted 8 lines · Daniel Kiper
Quoted 4 lines · Kristian Amlie

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.

Quoted 4 lines
Quoted 2 lines

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"?

Quoted 7 lines
Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

[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.

And/Or an argument for save_env/load_env...

Yes, I'm fine with either. How about a variable that determines the default, and you can override it with flags?

Signature · 1 line
Kristian
#6 lore raw
Quoted 45 lines · Kristian Amlie
Quoted 44 lines · Daniel Kiper
Quoted 43 lines · Daniel Kiper
Quoted 41 lines · Kristian Amlie
Quoted 8 lines · Daniel Kiper
Quoted 4 lines · Kristian Amlie

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.

Quoted 4 lines
Quoted 2 lines

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"?

Quoted 7 lines
Quoted 5 lines

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

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

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.

And/Or an argument for save_env/load_env...

Yes, I'm fine with either. How about a variable that determines the default, and you can override it with flags?

Works for me. However, I would assume that this feature is by default off.

Daniel

#7 lore raw
Quoted 27 lines · Daniel Kiper
Quoted 26 lines · Kristian Amlie
Quoted 25 lines · Daniel Kiper
Quoted 23 lines · Daniel Kiper
Quoted 10 lines · Kristian Amlie
Quoted 8 lines · Daniel Kiper
Quoted 5 lines · Kristian Amlie

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?

Quoted 8 lines

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.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

And/Or an argument for save_env/load_env...

Yes, I'm fine with either. How about a variable that determines the default, and you can override it with flags?

Works for me. However, I would assume that this feature is by default off.

Of course, we need to maintain full backwards compatibility! :-)

Signature · 1 line
Kristian