6005 bootadm update-archive should create/update archive sha-1 hash

Review Request #56 — Created June 6, 2015 and submitted

tsoome
illumos-gate
6005
6646d59...
general

6005 bootadm update-archive should create/update archive sha-1 hash

root@openindiana:/tmp# ./bootadm update-archive -f
updating //platform/i86pc/boot_archive
updating //platform/i86pc/amd64/boot_archive
root@openindiana:/tmp# more //platform/i86pc/boot_archive.hash
c5cc0f9801319b8a699656b5e3fbb0ee2e27ea47
root@openindiana:/tmp# more //platform/i86pc/amd64/boot_archive.hash
29c171b6a97422e4e0f2b3f47115d8117c80711e
root@openindiana:/tmp# digest -v -a sha1 /platform/i86pc/boot_archive
sha1 (/platform/i86pc/boot_archive) = c5cc0f9801319b8a699656b5e3fbb0ee2e27ea47
root@openindiana:/tmp# digest -v -a sha1 /platform/i86pc/amd64/boot_archive
sha1 (/platform/i86pc/amd64/boot_archive) = 29c171b6a97422e4e0f2b3f47115d8117c80711e

  • 0
  • 0
  • 8
  • 0
  • 8
Description From Last Updated
tsoome
andy_js
  1. It would be nice if there was some way to verify the boot_archive on boot using the hash file. Is that a planned feature?

    1. yes, see:
      https://www.illumos.org/issues/5886
      https://www.illumos.org/issues/5887
      https://us-east.manta.joyent.com/rmustacc/public/webrevs/5886/index.html (see dboot_startkern.c)

      the bootfs update also has update to verify the module hashes. As the 5886/5887 are in process to be reviewd, I did address this request to be request for comments in dev list - once bootfs will progress and people think this change is way to go, I'll file an RFE.

    2. Actually, verifying the hash is already present for the boot archive. That was integrated in https://www.illumos.org/issues/3364.

    3. How would I go about using that functionality?

    4. with current kernel and grub, it should be enough to add following line to specific menu entry, after boot_archive itself:
      module$ /platform/i86pc/$ISADIR/boot_archive.hash

      however, to actually see if the hash was checked, you need to add -B prom_debug=1 to kernel options, also it will help if you can direct console to serial port and capture - prom_debug will spit out a lot of data.

      a bit indirect way us to edit hash file and change hash value - if the hash is checked and it fails, you will get panic. with this strategy, the panic with bad hash will tell you that hash check indeed was performed.

  2. 
      
tsoome
andy_js
  1. Ship It!
  2. 
      
igork
  1. Ship It!
  2. 
      
tsoome
tsoome
tsoome
trisk
  1. Ship It!
  2. 
      
andy_js
  1. Ship It!
  2. 
      
yuripv
  1. 
      
  2. usr/src/cmd/boot/bootadm/bootadm.c (Diff revision 5)
     
     

    Use sizeof(archive_hash) instead of PATH_MAX.

    1. reworked to use asprintf() instead. if path is getting too long, fopen() will fail and error will be set.

  3. usr/src/cmd/boot/bootadm/bootadm.c (Diff revision 5)
     
     

    But you ARE in create_ramdisk(), do you mean the ksh script with the same name?

  4. The 'digest' name could easily create name collisions, beadm_digest() may be?

  5. The "please check" part sounds somewhat excessive :-)

    1. removed it; was carried over from digest source, but bootadm is run by admin, so this message is not needed.

  6. Why NULL_PTR? You are using standard malloc() after all.

    1. yes, carried over from digest command...

  7. Simple "out of memory" without assigning err=errno and using strerror() would be enough here, you aren't handling the EAGAIN anyway.

    Same for lines 202 and 231.

  8. Here and below - don't need the NULL checks, userland free() does that for you.

  9. 
      
tsoome
yuripv
  1. Ship It!
  2. 
      
tsoome
richlowe
  1. 
      
  2. Why is this checking down here, rather than right after the read loop?

    1. Right, this is oversighted leftover from digest. Since digest is processing multiple files, that code had to complete disgest update step. Since bootadm does not digest multiple files in same PKI session, we can return at once and close the session. Thanks for spotting this issue:)

  3. 
      
tsoome
richlowe
  1. Ship It!
  2. 
      
tsoome
Review request changed

Status: Closed (submitted)

Loading...