-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Inteltxt support #160
base: release4.2
Are you sure you want to change the base?
Inteltxt support #160
Conversation
It doesn't build on fc37-based dom0:
|
@marmarek Thank you for pointing that out. Will check this. To reproduce this error I need to change Also, should I set you as reviewer of this PR? Got also similar for grub2 QubesOS/qubes-grub2#13 |
Yes, that should be enough.
You can if you want, but no need to do that. |
4ca5894
to
a56c58b
Compare
Changing initramfs results in changes to both PCR-17 and PCR-18, is that desired? Is it because initramfs size is implicitly measured into PCR-18, while initramfs content is measured into PCR-17? |
It indeed seems to be about the size - if just initramfs content is different but still the same size, then PCR-18 remains unchanged. This isn't very problematic this way. More problematic would be intended change to PCR-18 also affecting PCR-17. I guess it's about measuring multiboot structure which includes initramfs size, right? Selective measurement is probably not worth the risk, but maybe I'm missing something? |
@krystian-hebel I would say that you are the expert in this regard. Could you answer these questions? |
Exactly. PCR18 contains (among others) measurement of Multiboot2's MBI, which contains size of all modules, including initramfs. Same thing would happen if kernel's size changes, or even if some additional commands are run in GRUB before booting that require allocating memory and kernel/initramfs lands in different place as a consequence. If external, untrusted devices can be memory mapped, this may be relevant. Another important thing that lives in MBI is kernel's command line, I think I don't have to explain what security implications of changing it without measurement would be. On Intel platforms, PCR18 also contains some other data, as described in TXT specification, I don't remember what exactly. AMD platforms would have full control over PCR18 content, so with current approach it would contain only MBI. To make it a bit more isolated we could move MBI measurement to another PCR (19+), but for reasons mentioned in the previous paragraph it still should be included in any attestation decision.
This would require parsing (using) structure that is not yet measured (trusted), which may open a way for TOCTOU attacks. This parser would also have to closely follow logic that is used by OS's parser, especially around corner cases like e.g. what happens if there are 2 or more command line tags. |
@marmarek WDYT about above? Should we work more about these patches? |
@marmarek How can we help to get this changes merged? |
I'm trying to install the packages and confirm their correctness according to blog post, but I've encountered a problem: The When trying to install any package in dom0, I get the same error as reported here: QubesOS/qubes-issues#6885, so I can't install missing dependencies. I'm working on an image from https://openqa.qubes-os.org/tests/55506#downloads, where I once completely reproduced the results from a blog post with earlier versions of packages. I would like to ask for help, what should I do in this situation? |
The reason for the issues from the #160 (comment) was that I received the wrong packages. I went back to reproduce the results from the blog post and after completing step 6 form I have only one entry in Grub:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1304-arch-x86-intel_txt.c-fixes-after-testing.patch
This is definitely not ready for review, please clean up.
1301-xen-arch-x86-boot-Add-MLE-header-and-file-for-new-en.patch
Outdated
Show resolved
Hide resolved
a56c58b
to
98e5787
Compare
Changed to draft because we want to use CI to check if changes compiled correctly |
0ab3116
to
a46e3e7
Compare
Looks like CI ended with success. @meithecatte I kindly re-request for review. |
@marmarek, @meithecatte We'd really appreciate your review and feedback on these two PRs: As these PRs are closing phase one, your input is crucial in determining their merge status. If any blockers exist, please let us know so we can address them together. |
@marmarta @meithecatte when you will have time to take a look at those patches? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a first batch of comments. Focused on things that make sense on it's own. I'm still reading up on Intel TXT, so review of more involved things are still in progress.
1301-x86-include-asm-intel_txt.h-constants-and-accessors-.patch
Outdated
Show resolved
Hide resolved
1301-x86-include-asm-intel_txt.h-constants-and-accessors-.patch
Outdated
Show resolved
Hide resolved
1301-x86-include-asm-intel_txt.h-constants-and-accessors-.patch
Outdated
Show resolved
Hide resolved
1301-x86-include-asm-intel_txt.h-constants-and-accessors-.patch
Outdated
Show resolved
Hide resolved
1301-x86-include-asm-intel_txt.h-constants-and-accessors-.patch
Outdated
Show resolved
Hide resolved
1311-x86-setup.c-don-t-use-XSM-policy-and-ucode-updates-w.patch
Outdated
Show resolved
Hide resolved
1311-x86-setup.c-don-t-use-XSM-policy-and-ucode-updates-w.patch
Outdated
Show resolved
Hide resolved
1311-x86-setup.c-don-t-use-XSM-policy-and-ucode-updates-w.patch
Outdated
Show resolved
Hide resolved
I think naming of things in a global namespace (constants in headers, global variables, etc.) deserve some thought. This is not blocking for usage in Qubes but a good preparation for getting it upstream. I have seen: https://lore.kernel.org/all/[email protected]/:
(A similar note should go in the Xen patches somewhere) I'm not sure why you avoid the Trenchboot name here. I think Consistently using
Via @marmarek other ideas from some Xen developers:
Again, this isn't blocking, but might be worth to think about. Edit: missed firth paragraph when copy+pasting. |
1301-x86-include-asm-intel_txt.h-constants-and-accessors-.patch
Outdated
Show resolved
Hide resolved
04208ab
to
5bf7fa7
Compare
@meithecatte, @HW42 could you please review the changes by @SergiiDmytruk? |
5bf7fa7
to
d7feb43
Compare
@SergiiDmytruk, @krystian-hebel: First of all sorry for the long delay on this task. I'm aware that in the meantime you added some fixes and new functionality on your https://github.com/TrenchBoot/xen repo. I already looked at some of them. I see that in the aem-4.17.4 branch you even already rebased them to Xen 4.17.4. Can you please update this PR. GitHub's review features is, in my experience, not good at matching comments between revisions of a PR, so it would be good to have this before adding more comments. |
@HW42, I guess the next step here depends on how this will get merged:
|
@SergiiDmytruk: I think that having a separate set of patches here, and let that diverge from what you plan to upstream is very undesirable. Especially for such a big set of patches. So please update the PR with the latest version you have. If you look at the history here we already had such force pushes. Yes, this makes review harder, but in my opinion clearly outweighs a diverging set of patches. If you feel like GitHub PR comments here got too messy, you can create a new PR, as you suggested. Works for me either way. |
fbe20ec
to
8e209dc
Compare
Squashed 6 commits from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting in small batches after having lost a unfinished review. Sorry in advance for the multiple notifications.
+ | ||
+/* The same set of registers is exposed twice (with different permissions) and | ||
+ * they are allocated continuously with page alignment. */ | ||
+#define NR_TXT_CONFIG_PAGES ((TXT_PUB_CONFIG_REGS_BASE - \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All users of this constant seems to do * PAGE_SIZE
, so maybe change this to be the size in bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- https://github.com/TrenchBoot/xen/compare/dd475a4a76..aem-phase4-rebase#diff-dd4611d055ace3b3c87ffe90aaf480b0d4a0e4098adb6de5026e3144a4821b09L9
- https://github.com/TrenchBoot/xen/compare/dd475a4a76..aem-phase4-rebase#diff-31035528a674298c3fdbc80ca9452ac5a422984a24386556a0729ee18ab93aebL18
- https://github.com/TrenchBoot/xen/compare/dd475a4a76..aem-phase4-rebase#diff-31035528a674298c3fdbc80ca9452ac5a422984a24386556a0729ee18ab93aebL56
- https://github.com/TrenchBoot/xen/compare/dd475a4a76..aem-phase4-rebase#diff-31035528a674298c3fdbc80ca9452ac5a422984a24386556a0729ee18ab93aebL56
+ * Functions to extract data from the Intel TXT Heap Memory. The layout | ||
+ * of the heap is as follows: | ||
+ * +---------------------------------+ | ||
+ * | Size Bios Data table (uint64_t) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Size of ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ * yet supported by the code. | ||
+ */ | ||
+ if (os_sinit->vtd_pmr_lo_size == 0) | ||
+ txt_reset(SLAUNCH_ERROR_LO_PMR_BASE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For high PMR you defined SLAUNCH_ERROR_HI_PMR_SIZE
, was this meant to be SLAUNCH_ERROR_LO_PMR_SIZE
? (Probably doesn't matter much if you distinguish those cases, but noticed that you already defined an error code for the other region's size)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ txt_heap = _p(read_txt_reg(TXTCR_HEAP_BASE)); | ||
+ | ||
+ if (txt_os_mle_data_size(txt_heap) < sizeof(*os_mle) || | ||
+ txt_os_sinit_data_size(txt_heap) < sizeof(*os_sinit)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading this right, those checks are of by sizeof(uint64_t)
. I would suggest to let txt_*_data_size
return the size of the memory area without the size header (this obviously needs adaption of the math in txt_*_data_start
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
slr_add_entry() and slr_init_table() were omitted to not have issues | ||
with memcpy() usage (it comes from different places for different | ||
translation units). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: With having prefix the other stuff with slaunch
, slr_
is now a bit inconsistent. But probably better to keep it this way, since then the identifiers match your "Secure Launch Specification".
+ | ||
+ map_l2(txt_heap_base, txt_heap_size); | ||
+ | ||
+ find_evt_log(&evt_log_addr, &evt_log_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing NULL check of return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ txt_heap_base + txt_heap_size); | ||
+ e820_change_range_type(&e820_raw, txt_heap_base, | ||
+ txt_heap_base + txt_heap_size, | ||
+ E820_RAM, E820_RESERVED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's reserve_e820_ram
as a short cut for E820_RAM, E820_RESERVED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- https://github.com/TrenchBoot/xen/compare/dd475a4a76..aem-phase4-rebase#diff-31035528a674298c3fdbc80ca9452ac5a422984a24386556a0729ee18ab93aebR38
- https://github.com/TrenchBoot/xen/compare/dd475a4a76..aem-phase4-rebase#diff-31035528a674298c3fdbc80ca9452ac5a422984a24386556a0729ee18ab93aebR51
- https://github.com/TrenchBoot/xen/compare/dd475a4a76..aem-phase4-rebase#diff-1d266d1dff9daf02e019100b9c620a099561c98811a05a0b7581363b3c00ac39R92
+ txt_heap_base + txt_heap_size); | ||
+ e820_change_range_type(&e820_raw, txt_heap_base, | ||
+ txt_heap_base + txt_heap_size, | ||
+ E820_RAM, E820_RESERVED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing return check of here and below. To be fair existing Xen code seems to be inconsistent about it, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ os_mle_size = txt_os_mle_data_size(__va(txt_heap_base)); | ||
+ os_mle = txt_os_mle_data_start(__va(txt_heap_base)); | ||
+ | ||
+ if ( os_mle_size < sizeof(*os_mle) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Off by sizeof(uint64_t)
, see comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1306-x86-sha1.c-add-file.patch
Outdated
|
||
File comes from [1] and is licensed under MIT License. Only enough | ||
changes to make it compile under Xen and to swap endianness of result | ||
were made to the original file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After having a look at it, this should to be pretty easy to get lib/crypto/sha{1,256}.c
from Linux into Xen. The used macros already exist in Xen, or did I miss something.
Even for less critical cases like here (hashing public data), I think we should use a well reviewed and maintained implementation.
Signed-off-by: Tomasz Żyjewski <[email protected]>
Signed-off-by: Tomasz Żyjewski <[email protected]> Signed-off-by: Sergii Dmytruk <[email protected]>
8e209dc
to
413d4c8
Compare
Set of patches which adds Intel TXT support in Xen for TrenchBoot.
This is necessary to create Proof of Concept for TrenchBoot Anti Evil
Maid for QubesOS.
Due to the requirements of Intel TXT and how it is utilised, it is
impossible to use the Xen boot protocols defined in the UEFI or
Multiboot2 specifications. Those patches creates a custom Intel TXT
entry point for Xen which would hand-off to the standard Multiboot2
entry point and enable direct launch of Xen by GRUB via DRTM on Intel
hardware. Additionally there was no support for launching Xen with Intel
TXT other than Trusted Boot. Certain parts had to be ported from
Trusted Boot specific code to Xen native code:
See: https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg01663.html
for details
Signed-off-by: Tomasz Żyjewski [email protected]