New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 845698 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Email to this user bounced
Closed: Aug 15
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug

Blocking:
issue 845589
issue 847668



Sign in to add a comment

Pre-populate a file in the stateful partition to act as a placeholder for USB-enrollment data

Project Member Reported by ahass...@chromium.org, May 22 2018

Issue description

Short background:
   Currently, when admins go through a recovery procedure (oftentimes yearly), they have to go through a tedious process of selecting the same options (WiFi, EULA acceptance, enterprise enrollment, etc.) on dozens of Chromebooks. We can add these options into some form of the USB recovery media creation tool, and insert them into the pre-built recovery image. Then, we can have the recovery procedure skip over the respective OOBE screens.

   For this, we need a file in the stateful partition of USB recovery images that the USB media creation tool can modify to include user-specific information. Since we cannot mount the stateful partition in the tool, an alternative is to pre-allocate a file of fixed length containing a random string during the recovery image building procedure, then scan for and replace the corresponding bytes in the recovery media creation tool (without having to mount the partition).

Design doc: https://docs.google.com/document/d/15STe5urdjWCONYE7ivmXxNlTKAtH0gqvAnoT1YZ2kII/edit#

Details to consider:
- The pattern cannot change in the future.

- The pattern cannot be stored as a constant.
  Apart from being clunky, it could end up in the image as part of e.g. Chrome, causing false positives when scanning the disk image. If it's generated at runtime through some seeded PRNG, this detail is taken care of. The chance of a collision on a 4K random string is very small.

- The pattern should be deterministic and re-createable from any programming language.
  We can't use any built-in random utility since ensuring the underlying algorithm never changes across different languages and runtime versions is impractical. A straightforward solution is to implement a simple linear congruential generator inline, and use the same starting parameters in all implementations.

- The process should consider the block size of the filesystem.
  It looks like all(?) the images we produce use a 4K block size for the stateful partition, but it's probably not a good idea to rely on this. Furthermore, the file we are allocating is larger (16K) than a single block, so it will span multiple, possibly non-contiguous blocks (in some tests, it appears ext4 always places the blocks beside each other, but again it's probably not a good idea to rely on this).

   We can get around this by creating a random string of length $block_size - 4 (e.g. 4092), and for each block, writing the string, followed by an incrementing block number in the last 4 bytes. For a 16K file, the data might look something like:

   0x0000: [ 4092 random bytes ][1]
   0x1000: [ same random bytes ][2]
   0x4000: [ same random bytes ][3]
   0x7000: [ same random bytes ][4]

   So, any code patching the image later can search for the random string, then use the following 4 bytes to determine which part of the file that block belongs to.

   It's possible that for some disk layouts we'll be generating less than 4K bytes of randomness, but even e.g. 512 bytes should be sufficiently random to not collide with random compiled code.
 

Comment 1 by vapier@chromium.org, May 23 2018

Cc: vapier@chromium.org
sorry, but there isn't a whole lot of information here as to goals or even what "USB-enrollment" means.  do you have any design docs ?

without these details, it's impossible to properly review CLs.

Comment 2 Deleted

Description: Show this description
Sorry about that, I've added a more descriptive issue body, as well as linked the design doc for the feature.
Description: Show this description
Blocking: 847668
Mike, I think the reason we decided to pre-populate the file like this is to be able to dump the config file without file system intervention (mounting, etc). Even for this solution, currently there is no API we can write to USB drive through a web app. We only can do through our private API for the recovery utility (a Chrome App). It would be great if we could keep support for mac and windows as is and don't add any new API if not necessary. I think the easiest path forward would be to modify the recovery utility to add the config file as is. The other path as you mentioned in the doc is to have chrome OS only solution for this, which is fine, but there is potentially no difference except that we can only do this for Chrome OS. Do you have any strong opinion one way or another? Any other idea how we do this?
Status: WontFix (was: Assigned)

Sign in to add a comment