-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Ivy/sandy/haswell platform locking (SMI finalizing chipset : io386 refresh for maximized boards) #1373
Conversation
d0e324f
to
ac03a63
Compare
On some newer platforms of intel (confirmed on nehalem, sandy/ivy bridge), coreboot after commit [2ac149d294af795710eb4bb20f093e9920604abd](https://review.coreboot.org/cgit/coreboot.git/commit/?id=2ac149d294af795710eb4bb20f093e9920604abd) registers an SMI to lockdown some registers on the chipset, as well as access to the SPI flash, optionally. The SMI will always be triggered by coreboot during S3 resume, but can be triggered by either coreboot or the payload during normal boot path. Enabling lockdown access to SPI flash will effectly write-protect it, but there is no runtime option for coreboot to control it, so letting coreboot to trigger such SMI will leave the owner of the machine lost any possibility to program the SPI flash with its own OS, and becomes a nightmare if the machine is uneasy to disassemble, so a scheme could be implement, in which the SMI to lockdown chipset and SPI flash is left for a payload to trigger, and temporarily disabling such triggering in order to program the SPI flash needs authentication. I have implemented a passcode-protected runtime-disableable lockdown with grub, described [here](https://github.com/hardenedlinux/Debian-GNU-Linux-Profiles/blob/master/docs/hardened_boot/grub-for-coreboot.md#update-for-coreboot-after-commit-2ac149d294af795710eb4bb20f093e9920604abd). In order to implement a similar scheme for Heads, I wrote [io386](https://github.com/hardenedlinux/io386). With this commit, io386 will be called before entering boot routine to trigger the SMI to finalize the chipset and write protect the SPI flash at the same time. Entering recovery shell will leave the flash writable. (The authentication routine implemented in previous revisions has been split as an independent commit.) Originally proposed under PR#326
Simple testcase from a current flashed maximized rom.
Alternatively, you can boot in unsafe mode and see "Finalize chipset" just before the final kexec call to OS and fiddle around trying to write to SPI with |
…all from kexec-boot prior of real kexec
Inclusion of io386 binary increased payload footprint compared to master from
to:
For a total increase in payload size of: |
tested t430-maximized works as described in the testcase |
Sorry to ping you again, but those are the ones needing at least on confirmation since other chipset:
@alexmaloteaux @natterangell @akfhasodh @doob85 @Thrilleratplay @BlackMaria @srgrint @ThePlexus @srgrint @akunterkontrolle @rbreslow : please test! |
Hi, Before I test this, I should mention I use an Ivy Bridge CPU in my T420, even though it shipped with Sandy Bridge. Coreboot supports this. Will chipset locking be a problem? I won't be able to refresh externally at the moment, so I'd rather nok bork the machine. |
Should not be a problem, my understanding is that coreboot platform locking works on Intel chipsets prior of skylake out of the box. This is what we test here. You will see if flashrom works when its not supposed to. @natterangell please let us know! |
I have tested with my t440P and it works as expected |
I have also now tested my x220 which also works fine |
@ThePlexus can you test and report for untested platform? We could then merge, xx20/xx30/haswell having been reported working for this PR. |
IMO it should be possible for the user to disable this one. It might be worth thinking about a central configuration store for Alternatively make it possible to disable it at build time via some switch. |
I like the idea, which would open the door for runtime switches. While undocumented, here are the current exports that lands currently under /etc/config:
The original PR was looking for I think this would deserve another issue to discuss implementation. I would be ok introducing CONFIG_FINALIZE_PLATFORM_LOCKING_PRE-SKYLAKE, so that kexec-boot finalize chip if both io386 binary is under initrd and the board config exports Nonetheless to say, it could be possible to unset an exported variable at runtime as well. Think of unsafe boot, for example, that could prompt the user in case @3hhh thoughts? |
So runtime configuration options are already implemented via cbfs?
Yes. If there's meant to be a GUI implementation, probably something like
That would then enable the aforementioned runtime configuration for this PR, yes. |
@3hhh @JonathonHall-Purism not sure how to do first step torward dynamic whiptail menus at 7c379f7#diff-ea606b9946e2de366108a7bea0a76c2b884d7360824975ad7c6e057cd906c120 But @3hhh the last commit permits to go into config manager, and deactivate platform locking for current boot session (meaning no lock_chip would be called on next kexec call), and optionally save the config back to spi, reboot, seal etc as would happen after firmware upgrade. @JonathonHall-Purism any advice on creating dynamic menus? Have some to point me to in pureboot codebase? |
@tlaurion Yes, I have examples of exactly this: https://source.puri.sm/firmware/pureboot/-/blob/Release-27/initrd/bin/config-gui.sh#L33 In particular Bash arrays are wonderful. |
…onfig option kexec-boot: depend on io386 presence and board config option to call lock_chip
…ed at runtime ash_functions: make sure /tmp/config is sourced before going to recovery shell TODO: revisit https://source.puri.sm/firmware/pureboot/-/blob/Release-27/initrd/bin/config-gui.sh#L33 to have proper config store later on
@3hhh you have t530 I see? 995a693 implements a runtime config override, which as all configuration override, can be setuped to be saved into /etc/config.user to override /etc/config that comes from the board configuration. From a little step back reflexion, I figured it was the best way to implement your request so that people can override default security policy only for one boot, in current case, desiring for example to boot an ISO/USB dongle and be able to override platform locking mecahnism on next kexec call. Please let me know if that fits your requirement. We could also see another config option override which would permit to add "iomem=relaxed" to KERNEL_ADD arguments passed down to kexec call, defined per board config. Note that an option forward could be to put all configuration options in board configs set to Also note that Purism has worked a lot on the config-gui.sh on their side, and a lot of things there could be cherry-picked/PR to be merged under Heads as well: https://source.puri.sm/firmware/pureboot/-/blob/Release-27/initrd/bin/config-gui.sh A config store would definitely be a good idea, and the code there has a nice simple implementation to implement toggles on board config provided options, which can be used at runtime and saved as config.user override of board config runtime options. |
Very nice, thank you very much! I tested it on a T530 and it worked as advertised. :-) And yes, the Pureboot configuration options look interesting and user-friendly, albeit probably a lot harder to maintain than the simple (but possibly less user-friendly) config file editing I proposed. |
@ThePlexus your confirmation needed for merging! |
@3hhh you can save the configuration changes from the "Change Configuration Settings" menu. On previous screenshot, that would be "Save the current configuration to the running BIOS" which is basically injecting runtime /tmp/config into what is extracted on boot and sourced at /etc/config.user |
@tlaurion I confirm test case works as described on p8z77-m_pro. |
thanks for this work! |
Merging! Thanks everyone! More testing needed on other PR soon! :) |
Once again thanks to @hardenedvault and @persmule for #326 which took way too long to be adapted, tested and merged with boards config to use it. Hopefully things will get faster from now on. |
Last discussion point on skylake+ under #326 (comment) |
Op refers to x11, post skylake platform, which implements needed change out of coreboot tree and can be used as a base TODO:
|
Edited OP to point to #1373 (comment) to show how to disable on a single boot session since asked under #1657 |
Edit: see #1373 (comment) to deactivate the feature on a single boot session
On chipsets preceding skylake, coreboot can prepare platform locking but let the payload (here Heads) finalize the lockdown (PR0 locked by SMI; also called SMM write Protection) instead of coreboot locking it by itself. This is what this PR is doing for in-tree supported maximized platforms (Haswell, Ivy/Sandy bridge).
Consequently, Heads becomes the only internal programmer (payload) being able to write to SPI (to update whole spi images).
Eventually Heads will also implement authentication prior of permitting to write to SPI. Unsafe boot options or access recovery shell. This is the first step in that direction. And the lowest hanging fruit torward increased security preventing OS to write to firmware.
Based on #326 PR and discussions and adapted to apply chipset locking prior of final kexec call. Also provides coreboot configs and board configs enabling the feature by default for current maximized boards under master.
Also pins io386 module to current latest commit so that firmware image is not impacted by reproducibility issues in the future.
Local build hash and CircleCi hashes matches for io386 (from hashes.txt output in artifacts of CircleCI as well):
949308795c0446fe847bfab5ad67da305c46676a5bc49c170629fcdf5717bb38 ./bin/io386
for io386 module pinned commit 874898af57d86dc057cea39b4a7e0621fc64aa4fb777dfb1eeb11e9134bc9a06 built to be optimized for size and stripped before being injected in tools.cpio (and packed under initrd.cpio.xz and stitched into coreboot as part of its payload).
Also enables to toggle the protection off for single boot (and flash for permanence if really desired), through Change Comfiguration Settings menu, see below for screenshots.
"Finalizing chipset" should always be seen provious of a kexec call.
Tested (board owners pinged directly from #692 willing testers) with testcase #1373 (comment)
TODO:
Skylake and newer have been tweaked to be able to do the same but it seems that upstreaming the changes to coreboot has not happened yet but had for older platforms. More info for coreboot devels to jump in from vaultboot fork for their x11 platform patch on unknown coreboot git commit