Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shim 15.7 for EuroLinux 9 #327

Closed
8 tasks done
aronowski opened this issue Mar 23, 2023 · 21 comments
Closed
8 tasks done

Shim 15.7 for EuroLinux 9 #327

aronowski opened this issue Mar 23, 2023 · 21 comments
Labels
accepted Submission is ready for sysdev superseded Vendor has added a new review which makes this obsolete

Comments

@aronowski
Copy link
Collaborator

aronowski commented Mar 23, 2023

Confirm the following are included in your repo, checking each box:

  • completed README.md file with the necessary information
  • shim.efi to be signed
  • public portion of your certificate(s) embedded in shim (the file passed to VENDOR_CERT_FILE)
  • binaries, for which hashes are added to vendor_db ( if you use vendor_db and have hashes allow-listed )
  • any extra patches to shim via your own git tree or as files
  • any extra patches to grub via your own git tree or as files
  • build logs
  • a Dockerfile to reproduce the build of the provided shim EFI binaries

What is the link to your tag in a repo cloned from rhboot/shim-review?


https://github.com/EuroLinux/shim-review/tree/eurolinux-shim-x86_64-20230517


What is the SHA256 hash of your final SHIM binary?


c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b


What is the link to your previous shim review request (if any, otherwise N/A)?


#258

@frozencemetery frozencemetery added the new vendor This is a new vendor label Mar 23, 2023
@ClaudioGranatiero-10zig
Copy link

I'm not an authorized reviewer, I'm just trying to help and learn.

  • build is reproducible, sha256 is confirmed:
c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  shimx64.efi
  • SBAT seems ok to me:
himx64.efi:     file format pei-x86-64

Contents of section .sbat:
 d2000 73626174 2c312c53 42415420 56657273  sbat,1,SBAT Vers
 d2010 696f6e2c 73626174 2c312c68 74747073  ion,sbat,1,https
 d2020 3a2f2f67 69746875 622e636f 6d2f7268  ://github.com/rh
 d2030 626f6f74 2f736869 6d2f626c 6f622f6d  boot/shim/blob/m
 d2040 61696e2f 53424154 2e6d640a 7368696d  ain/SBAT.md.shim
 d2050 2c332c55 45464920 7368696d 2c736869  ,3,UEFI shim,shi
 d2060 6d2c312c 68747470 733a2f2f 67697468  m,1,https://gith
 d2070 75622e63 6f6d2f72 68626f6f 742f7368  ub.com/rhboot/sh
 d2080 696d0a73 68696d2e 6575726f 6c696e75  im.shim.eurolinu
 d2090 782c312c 4575726f 4c696e75 782c7368  x,1,EuroLinux,sh
 d20a0 696d2c31 352e372c 73656375 72697479  im,15.7,security
 d20b0 40657572 6f2d6c69 6e75782e 636f6d0a  @euro-linux.com.

shimx64.efi:     file format pei-x86-64

Contents of section .sbatlevel:
 85000 00000000 08000000 22000000 73626174  ........"...sbat
 85010 2c312c32 30323230 35323430 300a6772  ,1,2022052400.gr
 85020 75622c32 0a007362 61742c31 2c323032  ub,2..sbat,1,202
 85030 32313131 3530300a 7368696d 2c320a67  2111500.shim,2.g
 85040 7275622c 330a00                      rub,3..         
  • Certificate seems ok:
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            2b:08:6d:be:fc:95:93:e8:a4:e7:d1:db:39:1a:f9:79:e8:84:85:5f
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = PL, ST = Poland, L = Cracow, O = EuroLinux Sp. z o.o., CN = EuroLinux Secure Boot CA
        Validity
            Not Before: Feb 11 13:32:30 2022 GMT
            Not After : Oct 29 13:32:30 2041 GMT
        Subject: C = PL, ST = Poland, L = Cracow, O = EuroLinux Sp. z o.o., CN = EuroLinux Secure Boot CA

Only a warning: here seems that the general consensus about a certificate validity is around 10 years, I see yours is set to 18 years from now. No problem for me (Secure Boot doesn't check the validity), but maybe the official reviewer will want to check that.

  • Alignment is ok:
bj Alignment:
SectionAlignment        00001000
DllCharacteristics      00000100
  • NX_COMPAT is enabled:
DllCharacteristics:
            DllCharacteristics:        256         0x100  NX_COMPAT
  • Section Code is not Writable (OK):

=== SECTIONS ===

  NAME          RVA      VSZ   RAW_SZ  RAW_PTR  nREL  REL_PTR nLINE LINE_PTR     FLAGS
  "/4"         5000    1db34    1dc00      400     0        0     0        0  40400040  R-- IDATA
  .text       23000    5e715    5e800    1e000     0        0     0        0  60300020  R-X CODE
  .reloc      82000        a      200    7c800     0        0     0        0  42100040  R-- IDATA DISCARDABLE
  "/14"       84000       49      200    7ca00     0        0     0        0  c0600040  RW- IDATA
  "/26"       85000       47      200    7cc00     0        0     0        0  40300040  R-- IDATA
  .data       86000    2d5b4    2d600    7ce00     0        0     0        0  c0600040  RW- IDATA
  "/37"       b4000      40f      600    aa400     0        0     0        0  40300040  R-- IDATA
  .dynamic    b5000       f0      200    aaa00     0        0     0        0  c0400040  RW- IDATA
  .rela       b6000    1b468    1b600    aac00     0        0     0        0  40400040  R-- IDATA
  .sbat       d2000       c0      200    c6200     0        0     0        0  40100040  R-- IDATA

@aronowski
Copy link
Collaborator Author

Thanks for the review.

Regarding the certificate validity curiosity, this was done according to the reviewer guidelines.

Does the submitter’s embedded certificate have a reasonable validity period? For a straight certificate, 1 to 5 years is probably sensible. For an embedded CA cert, longer is fine (20 years?)

@keithdlopresto
Copy link

I'm not an authorized reviewer, I'm just trying to help and learn.

  • build is reproducible, checksums match
#24 0.587 c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  /usr/share/shim/15.7-1.el9/x64/shimx64.efi
#24 0.590 c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  /shimx64.efi
  • SBAT contents seems good
contents of .sbat section

000c6200  73 62 61 74 2c 31 2c 53  42 41 54 20 56 65 72 73  |sbat,1,SBAT Vers|
000c6210  69 6f 6e 2c 73 62 61 74  2c 31 2c 68 74 74 70 73  |ion,sbat,1,https|
000c6220  3a 2f 2f 67 69 74 68 75  62 2e 63 6f 6d 2f 72 68  |://github.com/rh|
000c6230  62 6f 6f 74 2f 73 68 69  6d 2f 62 6c 6f 62 2f 6d  |boot/shim/blob/m|
000c6240  61 69 6e 2f 53 42 41 54  2e 6d 64 0a 73 68 69 6d  |ain/SBAT.md.shim|
000c6250  2c 33 2c 55 45 46 49 20  73 68 69 6d 2c 73 68 69  |,3,UEFI shim,shi|
000c6260  6d 2c 31 2c 68 74 74 70  73 3a 2f 2f 67 69 74 68  |m,1,https://gith|
000c6270  75 62 2e 63 6f 6d 2f 72  68 62 6f 6f 74 2f 73 68  |ub.com/rhboot/sh|
000c6280  69 6d 0a 73 68 69 6d 2e  65 75 72 6f 6c 69 6e 75  |im.shim.eurolinu|
000c6290  78 2c 31 2c 45 75 72 6f  4c 69 6e 75 78 2c 73 68  |x,1,EuroLinux,sh|
000c62a0  69 6d 2c 31 35 2e 37 2c  73 65 63 75 72 69 74 79  |im,15.7,security|
000c62b0  40 65 75 72 6f 2d 6c 69  6e 75 78 2e 63 6f 6d 0a  |@euro-linux.com.|
000c62c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

----

contents of .sbatlevel section

0007cc00  00 00 00 00 08 00 00 00  22 00 00 00 73 62 61 74  |........"...sbat|
0007cc10  2c 31 2c 32 30 32 32 30  35 32 34 30 30 0a 67 72  |,1,2022052400.gr|
0007cc20  75 62 2c 32 0a 00 73 62  61 74 2c 31 2c 32 30 32  |ub,2..sbat,1,202|
0007cc30  32 31 31 31 35 30 30 0a  73 68 69 6d 2c 32 0a 67  |2111500.shim,2.g|
0007cc40  72 75 62 2c 33 0a 00 00  00 00 00 00 00 00 00 00  |rub,3...........|
0007cc50  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

  • Certificate appears valid - 20 years

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            2b:08:6d:be:fc:95:93:e8:a4:e7:d1:db:39:1a:f9:79:e8:84:85:5f
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = PL, ST = Poland, L = Cracow, O = EuroLinux Sp. z o.o., CN = EuroLinux Secure Boot CA
        Validity
            Not Before: Feb 11 13:32:30 2022 GMT
            Not After : Oct 29 13:32:30 2041 GMT
        Subject: C = PL, ST = Poland, L = Cracow, O = EuroLinux Sp. z o.o., CN = EuroLinux Secure Boot CA
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                RSA Public-Key: (2048 bit)

@aronowski
Copy link
Collaborator Author

Hello people!

First of all I'd like to thank @keithdlopresto and @ClaudioGranatiero-10zig for reviewing my issue.

Partaking in Open Source projects requires effort indeed. It's vital that a strong community work together in order to achieve great things. Without it, we wouldn't have the systems we have today.

The same is applicable when it comes to reviewing shims. Robbie suggested it should all be peer review in here:

shim-review is meant to be distros reviewing each other

I suggest reading the whole conversation in this pull request and the proposals I provided in my comment there to help the peer review idea become a thing and make it easier for people to get into this.

So for this to happen I'd like to ping all the people I've had interactions with to help me out with this:

  • I reviewed your reviews. Please, give me a token of appreciation and review mine.
  • I suggested the aforementioned proposals as part of Robbie's PR. Please post a comment there, what do you think about the peer review idea and its implementation as of now.

Go ahead @Fabian-Gruenbichler, @MuthuvelKuppusamy, @amzdev0401, @joseph-zeronsoftn, @jsegitz, @mheese, @nicholasbishop, @ozun215, @parheliamm, @rehakp, @uibmz, @vden-irm, help me out with this. Thanks in advance!

@amzdev0401
Copy link

amzdev0401 commented May 12, 2023

I will review your SHIM submission completely.

The first thing I noticed, SHIM code needs to be forked from the following branch.
forked from https://github.com/rhboot/shim-review

@aronowski
Copy link
Collaborator Author

As far as I could see back then and can see now, forking this repository is not required. Just cloning it and uploading to a new remote.

Historically Red Hat, Inc. did so and everything is alright.

@mheese
Copy link

mheese commented May 17, 2023

I'm not an official reviewer, I'm just peer reviewing this as @aronowski peer reviewed mine and asked me/us to do the same.

Here are my findings that check all the boxes:

  • the SHA-256 checksum matches with the file in the repository.
$ sha256sum shimx64.efi 
c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  shimx64.efi
  • the .sbat sections looks okay and has the right format (ergo the potential build issue with older binutils can not be found)
  • SBAT versioning looks okay as well, as this is the first submission shim.eurolinux has 1 set correctly
$ pedump --extract section:.sbat shimx64.efi 
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
shim,3,UEFI shim,shim,1,https://github.com/rhboot/shim
shim.eurolinux,1,EuroLinux,shim,15.7,[email protected]
  • no code sections are writable
  • no section has write and execute bits set
  • DllCharacteristics include NX_COMPAT
  • section alignment is on page size (for x86_64)
❯ pedump shimx64.efi 

...

=== PE Header ===

                     signature:             "PE\x00\x00"

# IMAGE_FILE_HEADER:
                       Machine:      34404        0x8664  x64
              NumberOfSections:         10           0xa
                 TimeDateStamp:    "1970-01-01 00:00:00"
          PointerToSymbolTable:     812032       0xc6400
               NumberOfSymbols:       3664         0xe50
          SizeOfOptionalHeader:        240          0xf0
               Characteristics:        518         0x206  EXECUTABLE_IMAGE, LINE_NUMS_STRIPPED
                                                          DEBUG_STRIPPED

# IMAGE_OPTIONAL_HEADER64:
                         Magic:        523         0x20b  64-bit executable
                 LinkerVersion:                     2.35
...
              SectionAlignment:       4096        0x1000
                 FileAlignment:        512         0x200
...
                     Subsystem:         10           0xa  EFI_APPLICATION
            DllCharacteristics:        256         0x100  NX_COMPAT
...

...

=== SECTIONS ===

  NAME          RVA      VSZ   RAW_SZ  RAW_PTR  nREL  REL_PTR nLINE LINE_PTR     FLAGS
  "/4"         5000    1db34    1dc00      400     0        0     0        0  40400040  R-- IDATA
  .text       23000    5e715    5e800    1e000     0        0     0        0  60300020  R-X CODE
  .reloc      82000        a      200    7c800     0        0     0        0  42100040  R-- IDATA DISCARDABLE
  "/14"       84000       49      200    7ca00     0        0     0        0  c0600040  RW- IDATA
  "/26"       85000       47      200    7cc00     0        0     0        0  40300040  R-- IDATA
  .data       86000    2d5b4    2d600    7ce00     0        0     0        0  c0600040  RW- IDATA
  "/37"       b4000      40f      600    aa400     0        0     0        0  40300040  R-- IDATA
  .dynamic    b5000       f0      200    aaa00     0        0     0        0  c0400040  RW- IDATA
  .rela       b6000    1b468    1b600    aac00     0        0     0        0  40400040  R-- IDATA
  .sbat       d2000       c0      200    c6200     0        0     0        0  40100040  R-- IDATA
  • certificate is valid
❯ openssl x509 -text -noout -inform DER -in eurolinuxCA.cer 
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            2b:08:6d:be:fc:95:93:e8:a4:e7:d1:db:39:1a:f9:79:e8:84:85:5f
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = PL, ST = Poland, L = Cracow, O = EuroLinux Sp. z o.o., CN = EuroLinux Secure Boot CA
        Validity
            Not Before: Feb 11 13:32:30 2022 GMT
            Not After : Oct 29 13:32:30 2041 GMT
        Subject: C = PL, ST = Poland, L = Cracow, O = EuroLinux Sp. z o.o., CN = EuroLinux Secure Boot CA
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                RSA Public-Key: (2048 bit)
                Modulus:
                    00:d8:5d:79:7e:fc:d0:7d:8d:08:de:4d:77:74:07:
                    5b:85:74:44:49:50:6d:61:b6:b3:14:b0:ff:2b:06:
                    7b:3b:a7:40:67:f8:50:07:60:cf:81:5f:b7:dc:da:
                    19:93:21:e2:52:44:40:e0:11:64:3f:3c:83:6b:bd:
                    dd:cd:dc:24:7f:7a:91:53:95:7c:14:57:f0:78:49:
                    4f:6d:2c:de:a8:cc:85:2e:93:2e:f1:6a:a1:65:53:
                    ad:99:46:18:e8:87:7b:b9:b0:e7:e0:c7:9c:50:78:
                    74:e3:3d:dd:e7:16:79:8b:69:3d:52:51:18:5a:88:
                    31:08:0a:64:c2:97:ff:b5:15:39:45:dc:4b:f7:29:
                    30:65:67:aa:4b:93:1b:d3:1a:b9:af:ad:c1:c2:ea:
                    74:7b:cc:1f:ae:4e:ef:99:35:9b:7f:ff:26:55:8d:
                    a3:93:1c:71:79:52:21:df:15:41:78:a6:d8:a2:4c:
                    4b:54:24:74:29:6a:56:bc:d4:d2:17:04:10:97:23:
                    97:eb:a3:7d:19:80:85:ff:e4:c6:da:6d:af:51:6c:
                    1c:ce:0c:21:4e:35:d0:e8:9d:e8:90:61:95:62:3a:
                    62:48:dd:cb:cc:f7:d1:7a:77:eb:f8:9c:1a:45:ef:
                    bf:fb:8e:c0:5e:49:e9:79:b6:c8:1e:05:25:45:4e:
                    e8:a7
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                F3:5C:51:DD:7A:39:F5:95:30:39:EE:51:87:3C:9C:D6:4D:06:43:EB
            X509v3 Authority Key Identifier: 
                F3:5C:51:DD:7A:39:F5:95:30:39:EE:51:87:3C:9C:D6:4D:06:43:EB
            X509v3 Key Usage: 
                Digital Signature, Non Repudiation, Key Encipherment, Data Encipherment, Key Agreement, Certificate Sign, CRL Sign
            X509v3 Basic Constraints: critical
                CA:TRUE
            Netscape Comment: 
                EuroLinux Secure Boot CA
    Signature Algorithm: sha256WithRSAEncryption
    Signature Value:
        26:a5:8c:fe:f8:18:70:54:19:e6:52:a2:53:d4:4c:e3:b4:5e:
        5a:52:ae:c1:ec:a5:db:a9:bf:8d:ef:a0:5d:cb:43:a2:be:88:
        d0:08:24:4d:2e:9d:a9:bc:dc:b6:f6:24:6d:51:c8:d9:8e:2b:
        56:aa:da:32:0d:b2:d2:1d:67:f6:2d:e6:63:a0:8d:3a:6b:04:
        ae:cd:a3:0a:49:e7:49:49:ea:21:4a:0c:fe:49:e5:75:57:3b:
        0b:40:dd:26:10:b9:75:dd:ce:cd:3f:0d:5c:3f:64:16:2b:e5:
        98:3d:7e:87:06:25:bb:08:8b:32:0c:bc:1c:83:be:7f:ff:46:
        79:51:1b:d6:78:a3:df:7b:fb:f6:dc:1d:2b:af:b4:3a:91:e5:
        a8:64:bf:1e:a8:af:b6:da:ae:15:ef:aa:13:66:ad:b4:10:6d:
        f8:db:a8:42:e4:d9:20:47:c5:b9:0a:4e:bf:f4:60:75:e3:9d:
        02:ec:0b:b5:5b:cc:f7:41:d2:d3:17:f6:12:e6:e3:a5:1b:7d:
        ec:0d:82:72:69:b4:b3:19:89:46:1a:12:fc:4d:85:74:ec:0b:
        e4:28:2b:53:ed:f2:0e:c9:2c:6d:5c:a1:f7:17:6f:42:e4:86:
        13:4b:4c:b3:87:e3:6e:dd:15:a8:93:23:4f:f8:c0:95:89:d5:
        24:92:fe:50

And here are the potential problems/issues that I have found:

  1. Most importantly, I cannot reproduce the build with the included Dockerfile. I'm trying to build it with docker build --no-cache -t eurolinux-shim-review . 2>&1 | tee docker.log. I'm uploading the docker.log here as well.

  2. Kind of a nitpick, and not sure that this would be a problem, but the SBAT entry for the shim is the following:

shim.eurolinux,1,EuroLinux,shim,15.7,[email protected]

The last field is supposed to be a URL. [email protected] is technically not a valid URL. mail:[email protected] or mailto:[email protected] would be a valid URL. Also, interestingly the entries for grub and fwupd have mail: and mailto: prefixes (also not consistently).

  1. Again, this might not be an issue at all. However, the review process is asking that the reproducible builds are done from a tar ball of the release which then gets patches applied. You seem to be using a source RPM package. You might need to prove/explain how that source package was built so that it can be ensured that this was truly done from the right sources (and does not include anything else).

TBH, this bothers me in general about this process: we are asked to do that, but there are no checksums or signatures for tarballs released, so it's kind of problematic to begin with.

Also in general, I love how detailed the submission is: it includes detailed explanations on how the whole boot chain includes NX compatibility, including references to patches etc.

@aronowski, I hope this peer review helps you, and thanks again so much for peer reviewing my submission as well!

@aronowski
Copy link
Collaborator Author

aronowski commented May 17, 2023

@mheese, thanks for pointing the things out. That's the way it should be!

  1. The build should reproduce fine from now on. I made sure that fixed package versions are used - the same that were in use when I posted this issue, those from Enterprise Linuxes 9.1.

Edit: just to clarify: I've only changed the contents of Dockerfile, switching to a fixed version of EuroLinux 9.1, leaving everything else as it was, e.g. the build logs, which mention Oracle Linux 9.1. Since the systems from the Enterprise Linux family are 1:1 binary compatible, the final artifact is the exact same too.

  1. You're right when it comes to the inconsistencies. With shim I just used the format that RHEL was using, that is shim.redhat,1,Red Hat Inc,shim,15.5,[email protected].

  2. Number 3 is skipped because your answer skipped it too ;-)

  3. I agree that this process might be unintuitive for people who work with distros from families other than the Enterprise Linux one and I didn't account for that. But since RHEL had the same thing, I suppose this is not an issue.

The answer sure helped. I owe you a big one!

@mheese
Copy link

mheese commented May 18, 2023

@mheese, thanks for pointing the things out. That's the way it should be!

1. The build should reproduce fine from now on. I made sure that fixed package versions are used - the same that were in use when I posted this issue, those from Enterprise Linuxes 9.1.

Edit: just to clarify: I've only changed the contents of Dockerfile, switching to a fixed version of EuroLinux 9.1, leaving everything else as it was, e.g. the build logs, which mention Oracle Linux 9.1. Since the systems from the Enterprise Linux family are 1:1 binary compatible, the final artifact is the exact same too.

Yes, the build reproduces fine now! Kind of plays into my point (4) ;)

2. You're right when it comes to the inconsistencies. With shim I just used the format that [RHEL was using](https://github.com/vathpela/shim-review/tree/rhel-9.1-20220601#where-your-code-is-only-slightly-modified-from-an-upstream-vendors-please-also-preserve-their-sbat-entries-to-simplify-revocation), that is `shim.redhat,1,Red Hat Inc,shim,15.5,[email protected]`.

As I was saying, this is probably nitpicking :) ... although technically this is even something which would need to be fixed in RHEL. It doesn't parse as a URL.

3. Number 3 is skipped because your answer skipped it too ;-)

Yeah, no idea why github markdown skipped one number :)

4. I agree that this process might be unintuitive for people who work with distros from families other than the Enterprise Linux one and I didn't account for that. But since [RHEL had the same thing](https://github.com/vathpela/shim-review/blob/rhel-7-shim-20221116/Dockerfile), I suppose this is not an issue.

I don't really have an issue with source RPMs personally, just trying to point out that it might be harder to proof that this is indeed coming from a 15.7 tarball. As your distro is sort of RHEL clone, and RHEL is doing it the same way, it probably isn't a problem at all. This is definitely a problem for the review process though. For example, I did not go through the trouble to see if this source RPM is truly from a clean 15.7 source tree.

The answer sure helped. I owe you a big one!

Glad this was helpful! And let's hope by doing peer reviews this sends the right message to the official reviewers that we are all willing to help/participate as best as we can.

@rehakp
Copy link

rehakp commented May 29, 2023

I am not the official reviewer. I am just peer-reviewing as requested
and trying to help and learn.

---

Justification and the inability to reuse another shim are valid. The
company provides its own builds and customizations.

---

SRPM contains the exact 15.7 shim
release tar file - binary compared to
https://github.com/rhboot/shim/releases/download/15.7/shim-15.7.tar.bz2.

---

Even though NX support could have been implemented by using a different
flag with post-process-pe during the build process, a patch that makes
it the default option is fine.

---

This is the first time I have seen NX enabled in the kernel image. Nice
work!

---

Shim building reproduces fine with current Dockerfile. This one with
EuroLinux 9.1 repositories. SHA256 hash matches.

---

Private key security is satisfied. I am not even sure if this module
allows any extraction of keys from it for additional security.

---

SBAT looks OK and the .sbatlevel section is good. No bugs related to
binutils.

---

GRUB modules confirmed through the spec file in the attached source RPM.

---

GRUB is NX compatible thanks to included
patches - probably the first I've seen!

---

So to summarize the review looks great especially with the explanations
of all the mechanics happening behind the scenes like Microsoft
requirements at the very end. At the same time there are no
overcomplications like describing how exactly the shim protocol works
with GRUB verifying signatures on booted kernels because the developers
already know it.

I could not see any issues, good job!

@THS-on
Copy link
Collaborator

THS-on commented Oct 3, 2023

Review for eurolinux-shim-x86_64-20230517

  • EuroLinux is a new vendor

  • Shim is required because they are a RHEL source based distribution, with own kernel and GRUB builds

  • Security contacts are the same since last submission (was not accepted, but security contacts were verified, Shim 15.6 for EuroLinux 8 #258)

    • Jarosław Mazurkiewicz [email protected] (B556 5E94 789A 8E43 318A 517B 0C83 B15E 33E3 1BCC)
    • Kamil Aronowski [email protected] (B761 A3E6 6292 3749 3C0A 6B4E FD76 C457 54FA DC09)
  • Shim is reproducible using the Dockerfile

Hashes

#24 [20/20] RUN sha256sum /usr/share/shim/15*.el9/x64/shimx64.efi /shimx64.efi
#24 0.331 c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  /usr/share/shim/15.7-1.el9/x64/shimx64.efi
#24 0.338 c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  /shimx64.efi
#24 DONE 0.4s

SBAT

sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
shim,3,UEFI shim,shim,1,https://github.com/rhboot/shim
shim.eurolinux,1,EuroLinux,shim,15.7,[email protected]
  • SBAT component name shim.eurolinux works
  • Upstream shim 15.7 is used with NX enabled
    • buggy-binutils.patch : matches rhboot/shim@657b248 (modulo some diff context)
    • nx-compat.patch: enables NX flag by default
  • Certificate matches organization
    • Serial: 2b:08:6d:be:fc:95:93:e8:a4:e7:d1:db:39:1a:f9:79:e8:84:85:5f
    • Subject: C = PL, ST = Poland, L = Cracow, O = EuroLinux Sp. z o.o., CN = EuroLinux Secure Boot CA
    • Valid till: Oct 29 13:32:30 2041 GMT (20 years)
    • Is a CA certificate KeyUsage/DigitalSignature is set, ExtKeyUsage/CodeSigning is not
  • The keys are stored on a FIPS 140-2 certified HSM
  • Shim launches GRUB2 and fwupd
    • GRUB2
      • SBAT for GRUB2 looks good, Red Hat's SBAT entry is included
      • Module list looks fine: all_video boot blscfg cat configfile cryptodisk echo ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt http increment iso9660 jpeg loadenv loopback linux lvm luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp version video xfs zstd
    • fwupd
      • Does not contain Red Hat's SBAT. Is there a reason for that?
  • Kernel is based on 5.14.0-162.18.1 from RHEL

Notes and questions

  • CA certificate has not ExtKeyUsage/CodeSigning set. Do you want to update that? Keeping should also be fine
  • fwupd does not contain the SBAT from the Red Hat which I assume is the upstream. If there are no custom patches to fwupd this is fine.
  • Setting only the NX flag for the kernel is likely not enough
  • How do you sign the kernel modules? Is an ephemeral key used? (1f85d85)

Once those questions are clarified this LGTM! This also already got a lot of reviews (thank you @mheese, @rehakp, @keithdlopresto and @ClaudioGranatiero-10zig). I would like to see at least one more official review before accepting.

@THS-on THS-on added the question Reviewer(s) waiting on response label Oct 3, 2023
@aronowski
Copy link
Collaborator Author

Thank you for the review, Thore! Appreciate it!

CA certificate has not ExtKeyUsage/CodeSigning set. Do you want to update that? Keeping should also be fine

The ExtKeyUsage/CodeSigning value in the root certificate is an optional value. In many cases, the absence of this extension in the root certificate does not interfere with code signing or other operations that require this certificate. Therefore, I don't think there's a need to intervene, especially as we already have a working stack.


fwupd does not contain the SBAT from the Red Hat which I assume is the upstream. If there are no custom patches to fwupd this is fine.

That's right.


Setting the NX flag is likely not enough. You probably also need to backport this patch set and maybe some more: https://lore.kernel.org/all/[email protected]/

For context, I introduced the kernel NX-related entries once I was about to publish the initial application for a Shim review, i.e. with the commit 2e063892066532cc4f80eecbc1ef5b5743f32f16:

$ git log --oneline  -- assets/kernel-5.14.0-162.18.1.el9_1/nx-compat.patch
2e06389 (tag: eurolinux-shim-x86_64-20230323, origin/main, origin/HEAD, main) EuroLinux 9 Shim 15.7 as of 2023.03.23

$ git blame README.md | grep nx-compat
2e063892 (Kamil Aronowski     2023-03-23 13:35:44 +0100 168) There's the [nx-compat.patch](assets/kernel-5.14.0-162.18.1.el9_1/nx-compat.patch) which makes the `vmlinuz` PE binary have the `Image is NX compatible` DllCharacteristic according to the Microsoft requirements mentioned [here](https://github.com/rhboot/shim-review/issues/307):
2e063892 (Kamil Aronowski     2023-03-23 13:35:44 +0100 294) RHEL version of Linux kernel `kernel-5.14.0-162.18.1.el9_1`. RHEL patches only for Secure Boot support and (as mentioned earlier in this review) the [nx-compat.patch](assets/kernel-5.14.0-162.18.1.el9_1/nx-compat.patch) which makes the `vmlinuz` PE binary have the `Image is NX compatible` DllCharacteristic according to the Microsoft requirements mentioned [here](https://github.com/rhboot/shim-review/issues/307):

After this application got published, and I made several reviews, then I got this tip from Julian on the required patchset.

There are several things I'd like to address here:

Back then (when publishing the application) I interpreted the Microsoft requirements as having only the NX bit set in a PE/COFF binary being satisfactory.

Once I got a tip from Julian, I researched this a bit more and came to the conclusions that, apart from patching, a thorough research and a laboratory setting would be needed to ensure all this works correctly.
More on this in a minute.

I found this Microsoft's article that may shed some light on the matter. To quote them:

Since No Execute (NX) compliance can't be detected statically, firmware that sets `IMAGE_DLLCHARACTERISTICS_NX_COMPAT` should follow these steps to ensure that the firmware image can operate correctly with NX protections applied.
  1. The code module must not execute self-modifying code; meaning that the code sections of the application must not have
    the write attribute. Any attempt to change values within the memory range will cause an execution fault.

  2. If the code module attempts to load any internal code into memory for execution, or if it provides support for
    an external loader, then it must use the EFI_MEMORY_ATTRIBUTE_PROTOCOL appropriately. This optional protocol
    allows the caller to get, set, and clear the read, write, and execute attributes of a well-defined memory range.

    • Internal code loaded into memory must maintain WRITE and EXECUTE exclusivity. The attributes must also be
      changed after loading the code to allow execution.
    • External loaders must support EFI_MEMORY_ATTRIBUTE_PROTOCOL if available on the system. The loader must not
      assume newly allocated memory allows code execution (even of code types).
  3. The application must not assume all memory ranges are valid; specifically, page 0 (typically at physical address
    0 to 4 KB).

  4. Stack space can't be used for code execution.

So, if I'm understanding this correctly, we could prove that NX is not properly implemented if we could achieve at least one of the forbidden entries listed via either exploiting the kernel somehow or compiling a custom one, which can trigger something listed above, e.g., via a hotkey.

Am I right? Am I wrong? I don't know - I'm not a kernel developer, low level programmer or a malware analyst.

Recently I shared some thoughts publicly as part of this comment and as said there, I'd like an expert like Peter to confirm, what's there already and what needs to be ported.

Now, in regard to this patchset, it has not been ported as I really don't want to accidentally cause incompatibilities or even additional security issues, if it has not been approved in the RHEL kernel ours is based on.

As far as I'm concerned, the one in RHEL doesn't have this yet, but got approved, so, if this assumption is right, then we can well wait for a proper port once Microsoft demands it being right there.
I'll be glad to help with this and collaborate on testing the complete stack out in a laboratory I'd help to set up, but I need to know

  • if the current or former developers at Red Hat are interested in this
  • do the managers at Red Hat allow this or if there are other priorities
  • how to contact them? Via email? Via IRC? Meeting them on Flock, FOSDEM, CCCamp, or other conference?

So, just as I said that we can wait for a proper port, this is in alignment with another post by Julian:

Hence please don't submit shims for review if you don't have working NX stack or at least prepped the shim for NX (I mean you can continue working on the rest in the meantime).

We already have a proven one in Shim, as well as in GRUB2. Once a well-respected entity like Red Hat, Inc. has it in their kernel, I'll be sure it's a proven one, and in the meantime I'll be happy to assist in its development and integration, if I'm allowed to.


How do you sign the kernel modules? Is an ephemeral key used?

Yes, the appropriate x509.genkey.rhel asset has been added to our application.

It normally resides inside a kernel's Source RPM and is used as part of the build process when rpmbuild is invoked.

@THS-on THS-on added extra review wanted Initial review(s) look good, another review desired and removed question Reviewer(s) waiting on response labels Oct 3, 2023
@THS-on
Copy link
Collaborator

THS-on commented Oct 3, 2023

@aronowski thanks for answering the questions, now LGTM!

Regarding NX kernel support on RHEL based distributions. As far as I can see the last submissions were done still before the NX deadline or submitted with some exemption (#305, #304).
For now I think it is fine to have it only for the shim and GRUB2. It just might cause some boot issues on hardware that enforces NX when it encounters that flag set.

@aronowski
Copy link
Collaborator Author

@THS-on,

For now I think it is fine to have it only for the shim and GRUB2. It just might cause some boot issues on hardware that enforces NX when it encounters that flag set.

That's right. Looking back, I think that if there's a need for the proper port I mentioned in my earlier comment, I'd just consult with the people involved in it, if that's a possibility. If not, I'd stick to the implementation provided by RHEL.

Now, my way of "NX enablement" was just to change one 0 to 0x0100, so I can leave that simple patch out of future kernel builds once there's a valid need for this, like the aforementioned potential boot issues.
Even if this patch goes unused, I still think of the whole involvement I made from an educational point of view - as proof that I can indeed dive deep enough into the kernel's sources to find what I need to find. ;-)

@jaromaz
Copy link

jaromaz commented Oct 17, 2023

We've been waiting a long time and I'd like someone from the committee to help us out.
We already have many reviews and just need final accept.
Maybe someone from those, who got recently promoted? @dennis-tseng99 , @ecos-platypus , @tSU-RooT : can you help us out?

@dennis-tseng99
Copy link
Collaborator

dennis-tseng99 commented Oct 22, 2023

I just ran Dockerfile by sudo docker build . Here is the result:

  • code can be reproducible:
objcopy -D -j .text -j .sdata -j .data -j .data.ident \
        -j .dynamic -j .rodata -j .rel* \
        -j .rela* -j .dyn -j .reloc -j .eh_frame \
        -j .vendor_cert -j .sbat -j .sbatlevel \
        --target efi-app-x86_64 shimx64.so shimx64.efi
./post-process-pe -vv shimx64.efi
set_dll_characteristics():354: Updating DLL Characteristics from 0x0000 to 0x0100
  • DLL Characteristics has been set:
    I made use of your Dockerfile to dump a build out shimx64.efi to prove its DllCharacteristics=0x0100
Step 13/21 : RUN ls -l ./usr/share/shim/15*.el9/*/shim*.efi &&     hexdump -n 0x0120 -C ./usr/share/shim/15.7-1.el9/x64/shimx64.efi
 ---> Running in a5303436c11c
-rw-r--r-- 1 root root 938308 Oct 22 01:36 ./usr/share/shim/15.7-1.el9/x64/shimx64.efi
00000000  4d 5a 90 00 03 00 00 00  04 00 00 00 ff ff 00 00  |MZ..............|
00000010  b8 00 00 00 00 00 00 00  40 00 00 00 00 00 00 00  |........@.......|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 80 00 00 00  |................|
00000040  0e 1f ba 0e 00 b4 09 cd  21 b8 01 4c cd 21 54 68  |........!..L.!Th|
00000050  69 73 20 70 72 6f 67 72  61 6d 20 63 61 6e 6e 6f  |is program canno|
00000060  74 20 62 65 20 72 75 6e  20 69 6e 20 44 4f 53 20  |t be run in DOS |
00000070  6d 6f 64 65 2e 0d 0d 0a  24 00 00 00 00 00 00 00  |mode....$.......|
00000080  50 45 00 00 64 86 0a 00  00 00 00 00 00 64 0c 00  |PE..d........d..|
00000090  50 0e 00 00 f0 00 06 02  0b 02 02 23 00 e8 05 00  |P..........#....|
000000a0  00 78 06 00 00 00 00 00  00 30 02 00 00 30 02 00  |.x.......0...0..|
000000b0  00 00 00 00 00 00 00 00  00 10 00 00 00 02 00 00  |................| <-- SectAlig=0x00001000=4096 (4K alignment)
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 30 0d 00 00 04 00 00  d7 53 0e 00 0a 00 00 01  |.0.......S......| <-- DllCharacteristics=0x0100 (the value of last 2 bytes)
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000100  00 00 00 00 10 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120
  • 4K alignment, Wr-Exec check:
    In Dockerfile, I copied shimx64.efi to / and then
./post-process-pe -vv shimx64.efi
ms_validation():370: NX-Compat-Flag: PASS
ms_validation():375:   4K-Alignment: PASS
ms_validation():387: Section-Wr-Exe: PASS
  • Hash values are matched:
Step 20/20 : RUN sha256sum /usr/share/shim/15*.el9/x64/shimx64.efi /shimx64.efi
 ---> Running in 32b3e06e9f0e
c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  /usr/share/shim/15.7-1.el9/x64/shimx64.efi
c1c4b58a3cd11df0fa9af88ea13591dee6525362d100ab4846e7a3a798afaa5b  /shimx64.efi
  • sbat seems good to me:
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
shim,3,UEFI shim,shim,1,https://github.com/rhboot/shim
shim.eurolinux,1,EuroLinux,shim,15.7,[email protected]
objdump -s -j .sbatlevel shimx64.efi
.sbatlevel section:
 00000000 08000000 22000000 73626174  ........"...sbat
 2c312c32 30323230 35323430 300a6772  ,1,2022052400.gr
 75622c32 0a007362 61742c31 2c323032  ub,2..sbat,1,202
 32313131 3530300a 7368696d 2c320a67  2111500.shim,2.g
 7275622c 330a00                      rub,3.. 
  • CA Key validity length is acceptable
Validity
            Not Before: Feb 11 13:32:30 2022 GMT
            Not After : Oct 29 13:32:30 2041 GMT
  • Conclusion: it is acceptable to me. It will be appreciated if more comments are added, otherwise I will put an accepted tag on it in the next couple of days.

@dennis-tseng99
Copy link
Collaborator

This reviewed issue opened by @aronowski has been reviewed by many experts, including @ClaudioGranatiero-10zig, @keithdlopresto, @amzdev0401(even not comment here), @mheese, @rehakp, and @THS-on since Mar 23 of this year. All questions were answered. Let's put "accepted" tag on it.

@dennis-tseng99 dennis-tseng99 added accepted Submission is ready for sysdev and removed extra review wanted Initial review(s) look good, another review desired new vendor This is a new vendor labels Oct 29, 2023
@aronowski
Copy link
Collaborator Author

@dennis-tseng99, thank you for the acceptance.

Furthermore, I'd also like to thank everyone involved in helping to make this application as good as possible.
I appreciate your input and will make a toast for all of you. :-)

@THS-on
Copy link
Collaborator

THS-on commented Feb 5, 2024

What is the status of this @aronowski? Did you get a shim back or are you creating a new submission for 15.8?

@aronowski
Copy link
Collaborator Author

@THS-on, we'll create an update regarding 15.8 as we do not have a signed 15.7 binary.

There are ongoing discussions, if it's better to update this application or to create a new one.

@aronowski aronowski mentioned this issue Feb 9, 2024
8 tasks
@aronowski
Copy link
Collaborator Author

Superseded by #375

@aronowski aronowski added the superseded Vendor has added a new review which makes this obsolete label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Submission is ready for sysdev superseded Vendor has added a new review which makes this obsolete
Projects
None yet
Development

No branches or pull requests

10 participants