Menu

SBAT

nl6720
2021-06-10
2023-03-26
  • nl6720

    nl6720 - 2021-06-10

    shim 15.3 introduced and now mandates SBAT. This means that shim 15.3+ will not launch any EFI binaries without a .sbat section.

    To continue to work with shim, rEFInd needs to add .sbat sections to its binaries and provide a way to set the vendor* fields at build time.

     
  • Roderick W. Smith

    Thanks for the heads-up on this. Yet another Secure Boot hoop to jump through....

    I've found a binary build for openSUSE, so I'll start testing with that soon. The documentation for how to add the .sbat section seems a bit tedious and isn't 100% clear to me on a first read, but I expect that after poking around a bit I'll figure it out. It's also oriented toward a traditional Linux/GNU-EFI build process; I'm not sure how to integrate this into Tianocore builds. That could just end up motivating a shift to GNU-EFI as the primary build environment for rEFInd -- but maybe I'll figure out how to do this with the Tianocore EDK2.

     
  • nl6720

    nl6720 - 2021-06-22

    For testing, you can also use shim 15.4 from Fedora.

     
  • das menschy

    das menschy - 2022-10-13

    What's the progress on this issue? rEFInd still does not have any sbat section in its binary. Because rEFInd does not have a SBAT section, it doesn't work with shim, and doesn't work on OEM laptops with OEM/default secure boot keys enrolled.

    If rEFInd had an SBAT section, it would make setting up Secure Boot much easier: people would just have to enroll the MOK keys with MokManager (mmx64.efi) and would not have to replace the PK, KEK and DB keys with KeyTool/efi-updatevar/sbkeysync; ONLY to make rEFInd work.

    Replacing the Platform Key (PK), Key Exchange Keys (KEK) and Database Keys (DB) with your own keys is a big obstacle for many people.

    I found an example SBAT and script here, that describes how to add SBAT support to refind: https://github.com/rhboot/shim/issues/376#issuecomment-964137621

    The /usr/share/grub/sbat.csv file for the real GRUB on my Arch Linux looks like this:

    sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
    grub,1,Free Software Foundation,grub,2:2.06.r334.g340377470-1,https//www.gnu.org/software/grub/
    grub.arch,1,Arch Linux,grub,2:2.06.r334.g340377470-1,https://archlinux.org/packages/core/x86_64/grub/
    

    An updated version of the refind_sbat.csv file for REFIND could look like this:

    sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
    rEFInd,1,Roderick W. Smith,rEFInd,0.13.3,https://www.rodsbooks.com/refind
    

    A generalized version of the refind_sbat.csv file for REFIND could just take its data from the refind.spec file, which currently begins with:

     1 Summary: EFI boot manager software
     2 Name: refind
     3 Version: 0.13.3.1
     4 Release: 1%{?dist}
     5 Summary: EFI boot manager software
     6 License: GPLv3
     7 URL: http://www.rodsbooks.com/refind/
     8 Group: System Environment/Base
     9 Source: refind-src-%version.tar.gz
    10 Requires: efibootmgr gdisk mokutil
    11 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
    ...
    

    The build program could just generate the sbat.csv file with this information, replacing ${...} with the corresponding values in refind.spec:

    sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
    ${NAME_IN_LINE_2},1,Roderick W. Smith,${NAME_IN_LINE_2},${VERSION_IN_LINE_3},${URL_IN_LINE_7}
    

    The script to add this refind_sbat.csv file as .sbat section to the refind_x64.efi would look like this:

    objcopy --set-section-alignment '.sbat=512' --add-section .sbat=refind_x64.csv --adjust-section-vma .sbat+10000000 refind_x64.efi 
    
     
  • Roderick W. Smith

    I'm sorry it's taken so long to get to this; I've just been busy with other things. I've recently been making some changes to rEFInd, though, and I expect to make a new release in the next week or two. This includes .sbat support. I just uploaded it to the git repository, so you can download it and build it there; or you can try this binary:

    https://www.rodsbooks.com/refind-bin-0.13.3.6.zip

    I've tried to make this as seamless as possible; my own binaries should come with .sbat sections now; or they're added if you re-sign the binaries by installing an unsigned Debian package or running refind-install with the --localkeys option.

    This is still barely tested by me. So far it's worked for me, but there may yet be bugs or incompatibilities with certain computers or Shims. If you have any feedback, I'd appreciate hearing it.

     
  • nl6720

    nl6720 - 2023-02-22

    If I'm reading https://sourceforge.net/p/refind/code/ci/97998eacd72557f79664e16ce19af34128f40315/ correctly, then the .sbat section is added by refind-install.

    Would it be possible to do it in the build process, i.e. in the Makefile, instead? That way the EFI binaries could be used as-is.

     
    • Roderick W. Smith

      I thought it over, and that seems like a good suggestion, so the latest version (in git) does it this way.

      I plan to make a new release soon (this weekend), so if anybody cares to test this, now is the time!

       
      👍
      2
  • nl6720

    nl6720 - 2023-02-25

    Works for me™ in a virtual machine.

     
  • npg_

    npg_ - 2023-03-26

    Works for me on shim 15.6/refind 14.0.2.

     

Log in to post a comment.