|
|
Log in / Subscribe / Register

AMD memory encryption technologies

By Jake Edge
September 8, 2016

Linux Security Summit

Today's virtual machines (VMs) have a variety of protections from their brethren, but hypervisor or kernel bugs can allows guests to access the memory of other guests. In addition, providers of VMs can see the memory of any of the guests, so users of public clouds have to place a lot of trust in their provider. AMD has some upcoming features in its x86 processors that will encrypt memory in ways that alleviate some of these problems. David Kaplan gave a presentation about these new technologies at the Linux Security Summit in Toronto.

[David Kaplan]

The motivation for these features is the cloud environment. Currently, the hypervisor must enforce the isolation between guests through a variety of means: hardware virtualization support, page tables, VM intercepts, and so on. But sometimes those break down, leading to various vulnerabilities that allow guests to access other guests, which is scary, he said.

But users are required to trust their cloud providers since they have full access to all guest memory to extract secrets or even to inject code into VMs. The cloud providers would rather not have that power, Kaplan said; they do not want to be able to see their customers' data. For one thing, that protects the providers from "rogue admin" attacks, where a disgruntled employee uses the unwanted access to attack a customer.

$ sudo subscribe today

Subscribe today and elevate your LWN privileges. You’ll have access to all of LWN’s high-quality articles as soon as they’re published, and help support LWN in the process. Act now and you can start with a free trial subscription.

That kind of attack, as well as those where a guest gets access to another guest's memory, are "user-access attacks", he said. AMD is targeting those as well as "physical-access attacks", where someone with access to the hardware can probe the physical DRAM interface or freeze and steal the memory chips (e.g. a cold boot attack). How important it is to resist those and other, similar attacks depends on who you talk to, he said.

There are two separate features—Secure Memory Encryption (SME) and Secure Encrypted Virtualization (SEV)—that both use the same hardware support that will be provided in upcoming processors. That support includes an AES-128 hardware engine inline with the RAM and memory controller so that memory can be encrypted and decrypted on the way in and out of the processor with "minimal performance impact". The data inside the processor (e.g. registers, caches) will be in the clear; there will just be a "little extra latency" when RAM is involved.

All of the keys will be managed within the SoC by the AMD Secure Processor, which is a separate 32-bit ARM Cortex A5 that is present on recent SoCs. It runs a secure (closed source) operating system and enables hardware-validated boot. It is used in some laptops as a firmware Trusted Platform Module (TPM). The secure processor will only run AMD-signed code; it also provides cryptographic key generation and management functions.

Of the two features, SME is the simplest. It uses a single key that is generated at boot time using the random-number generator to transparently encrypt pages that have been marked with a special "encrypted" bit in the page-table entry. The operating system or hypervisor manages which pages will be encrypted in RAM by use of that bit. There is support for hardware devices to DMA to and from encrypted memory as well. SME is targeted at thwarting physical-access attacks, since the contents of memory will be inaccessible without the key that is not accessible outside of the secure processor.

SEV, on the other hand, is more complicated. It has multiple encryption keys in the design and is meant to protect guests' memory from each other and from the hypervisor. The eventual goal, Kaplan said, is for the hypervisor to have no view into the guest.

There are keys for the hypervisor and for each VM, though groups of VMs could share keys and some VMs might be unsecured. SEV cryptographically isolates the guests and hypervisor to the point where cache lines (which are unencrypted) are tagged with an ID that specifies which address space they belong to; the processor will prevent guests from accessing the cache of other guests.

The owner of a guest is a "key player" in using SEV, Kaplan said. Information like secrets and policies will need to be transferred to the secure processor using the hypervisor to transport that data. Since the hypervisor is untrusted in this model (so that cloud providers do not have access to customer secrets), the guest owner will create a secure channel to the secure processor (through the hypervisor) using Diffie-Hellman (DH) key exchange.

Launching a guest is a somewhat complicated process; Kaplan's slides [PDF] may be of interest for those who want more details. The hypervisor begins by loading an unencrypted BIOS or OS image into memory. The guest owner then supplies their DH key and the hypervisor facilitates the creation of a secure channel between the guest owner and the secure processor (without being able to eavesdrop on the traffic). Part of that exchange will provide the guest owner with a certificate that allows them to prove that they are truly talking to the secure processor.

The hypervisor then allocates an "address space identifier" (ASID), which is what identifies the guest (and the key for that guest's memory). That ASID is provided to the secure processor with a request to generate or load a key into the AES engine and to encrypt the BIOS/OS image using that key. The hypervisor then sets up and runs the guest using the ASID assigned; the memory controller, AES engine, and secure processor will work together to ensure that the memory is encrypted and decrypted appropriately.

The hypervisor will also send a "launch receipt" to the user that includes a measurement (hash) of the image and some platform authentication information. If the user is provided with the right measurement, they can then provide secrets like disk encryption keys to the guest over a secure channel (e.g. TLS).

There are two levels of page tables: one for the guest and one for the hypervisor. The guest tables determine whether the memory is private or is shared with the hypervisor. All executable pages are private (no matter the setting), as are the guest's page tables. Data pages can be either, but DMA must use shared pages.

A common question that is asked is in regards to the ASID: couldn't the hypervisor "spoof" a different ASID? The answer is that it could, but it wouldn't really gain it anything. If it tries walking the guest page tables or executing code using the wrong key, it will not be particularly successful. SEV is meant to block a range of attacks, both physical and user access; the intent is to reduce the attack surface even more in coming years.

In order to use SEV, both hypervisors and guests will need to change to support it. There are a number of software components required, some that AMD expects to ship and others that it is working with the open-source community on. The secure processor firmware is distributed in binary form and the source is not public. There is a Linux driver to support the secure processor that has been posted for review. The open-source hypervisor support is also being worked on.

There was a question about why AMD had not used the TPM API for its secure processor. Kaplan said there was interest in a simpler API that focused on the VM launch cycle. But the API is available and is only in beta at this point, so those interested should comment. Also, as is often the case with processor features, Kaplan was unable to say when SoCs with either feature would be available.

[I would like to thank the Linux Foundation for travel support to attend the Linux Security Summit in Toronto.]

Index entries for this article
KernelMemory management/Memory encryption
ConferenceLinux Security Summit/2016


to post comments

AMD memory encryption technologies

Posted Sep 9, 2016 5:34 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link] (15 responses)

> Part of that exchange will provide the guest owner with a certificate that allows them to prove that they are truly talking to the secure processor.
However, a sufficiently malicious hypervisor can provide a invalid certificate and patch the code in the guest that checks this certificate.

And likely it won't even be too complicated.

AMD memory encryption technologies

Posted Sep 9, 2016 13:33 UTC (Fri) by yaap (subscriber, #71398) [Link] (11 responses)

The user should verify the given certificate and make sure it's signed by AMD. It won't protect against an organization able to extract the AMD root of trust certificate, but in practice it's still better than the current state. I don't think that being stolen by the NSA is big concern for a bank for example ;)

As for patching the code in the guest, it's not possible in RAM and it's not possible if the virtual disk is encrypted with a key provided only to the guest once the certificate is verified as good and over a secure channel. The the HV can only do a DoS (not useful here) but can't tamper with the guest.

Devil is in the details, but it looks ok to me.

AMD memory encryption technologies

Posted Sep 9, 2016 14:03 UTC (Fri) by luto (subscriber, #39314) [Link]

Looks less than okay to me. It's not secure against a malicious hypervisor that tries hard to break it.

https://lwn.net/Articles/686814/

http://www.mail-archive.com/linux-doc@vger.kernel.org/msg...

AMD memory encryption technologies

Posted Sep 9, 2016 21:29 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link] (9 responses)

The problem is with the client code that checks this certificate. It can easily be patched to accept fake certs.

Various obfuscation schemes would only delay the inevitable.

AMD memory encryption technologies

Posted Sep 10, 2016 2:34 UTC (Sat) by geertj (guest, #4116) [Link] (3 responses)

> Various obfuscation schemes would only delay the inevitable.

I'm somewhat optimistic that the problem can be solved. First, on a meta-level, would AMD pour 10s of millions of dollars into a complicated new silicon feature if it were just obfuscation and no cryptographic security could be had? It's possible but in my view unlikely as AMD have some very sharp engineers.

The solution would use a third, trusted server that runs on hardware you own and trust (this could be in your own data center). You need that server anyway to store the keys to unlock the disk images of your VMs (we don't trust the cloud so we need to use encrypted disk images). The untrusted hypervisor would load an unencrypted initrd that tries to mount the root file system. In order unlock the disk image, the initrd would call home to the configured trusted server.

Before giving the disk encryption key, that trusted server would do a DH exchange proxied via the initrd directly to the remote secure processor. You now have a safe channel between two trusted end points. The trusted server could ask the SP for a hash of the initrd (and any loaders that chain loaded into it.) and of the memory. Those can be checked to match trusted fingerprints. Then the trusted server can ask the SP to start encrypting the VM memory as long as it matches the hash (to prevent races).The memory hash would have to exclude local state. Once SEV is enabled you also likely want to have the SP check that indeed you're talking to your own initrd and not some man in the middle. This can probably be done through some challenge/response mediated by the SP. Once you have validated the integrity of the boot chain, that you're talking to "your" initrd, and that the SP tells you that your initrd is now protected using SEV, I think you've succesfully bootstrapped a trusted VM. You can now provide the disk encryption key and continue the boot.

I do agree that SEV v1 still has some holes, but I think those are not fundamental just limitations of the current implementation:

* Memory is encrypted but not integrity protected. Modifying the encrypted memory at a certain offset will easily lead to crashes that can be exploited.
* The VM control block apparently leaks register contents. This is mentioned in the thread referred to in a sibling to the parent comment.

AMD memory encryption technologies

Posted Sep 10, 2016 2:59 UTC (Sat) by Cyberax (✭ supporter ✭, #52523) [Link]

Basically, you have to establish an unbroken DH chain between your trusted hardware and the AMD secure authentication chip in the motherboard.

It's theoretically possible, but will be quite complicated in practice and likely to have lots of holes allowing a hypervisor to mess with you. It can try timing attacks, random number poisoning and so on.

It's better than nothing as it protects against non-malicious hosting providers, but unlikely to thwart entities like NSA.

AMD memory encryption technologies

Posted Sep 10, 2016 4:19 UTC (Sat) by raven667 (subscriber, #5198) [Link] (1 responses)

> I'm somewhat optimistic that the problem can be solved. First, on a meta-level, would AMD pour 10s of millions of dollars into a complicated new silicon feature if it were just obfuscation and no cryptographic security could be had? It's possible but in my view unlikely as AMD have some very sharp engineers.

That logic does not work in practice, for a related example, look at the engineering effort that has gone into failed DRM systems.

AMD memory encryption technologies

Posted Sep 10, 2016 15:34 UTC (Sat) by geertj (guest, #4116) [Link]

> That logic does not work in practice, for a related example, look at the engineering effort that has gone into failed DRM systems.

That is one example indeed. But in this case I was specifically talking about AMD. It is a high tech company with an strong and reputable engineering culture. In the case of DRM, the tech was driven by the RIAA and the MPIAA which are burocratic monopolists and definitely not tech savvy.

AMD memory encryption technologies

Posted Sep 12, 2016 19:25 UTC (Mon) by davidstrauss (subscriber, #85867) [Link] (3 responses)

> The problem is with the client code that checks this certificate. It can easily be patched to accept fake certs.

Yes, but the guest would probably need to be restarted so the attacker can MitM the negotiation. If gaining malicious control of the hypervisor requires restarting guests to gain access, the attack still becomes a lot more noisy, which is still an improvement over today. I support making systems more tamper-evident even when we can't make them fully tamper-resistant.

AMD memory encryption technologies

Posted Sep 12, 2016 20:00 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link] (2 responses)

I don't know about this. All security-related changes usually have operational costs, it's not really clear for me that in this case it's really worth it.

Whole memory encryption to thwart simple "pull out RAM chips" attacks certainly makes sense, though.

AMD memory encryption technologies

Posted Sep 12, 2016 20:47 UTC (Mon) by davidstrauss (subscriber, #85867) [Link] (1 responses)

> I don't know about this. All security-related changes usually have operational costs, it's not really clear for me that in this case it's really worth it.

This approach probably has implementation (and maintenance for the implementation), but it sounds like it's the sort of design that a hypervisor or guest OS could use by convention/detection without explicit administrator work (other than, say, turning it on).

> Whole memory encryption to thwart simple "pull out RAM chips" attacks certainly makes sense, though.

It also prevents a machine-local compromise (assuming a way to trick secure boot, exploit a management module, or putting in a USB key with malicious firmware). I'd actually like this on my laptop for the host OS, even.

AMD memory encryption technologies

Posted Sep 12, 2016 20:57 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link]

> This approach probably has implementation (and maintenance for the implementation), but it sounds like it's the sort of design that a hypervisor or guest OS could use by convention/detection without explicit administrator work (other than, say, turning it on).
Not really. It needs active participation from the guest OS and a third party that does remote attestation to provide decryption keys to fully utilize this.

> It also prevents a machine-local compromise (assuming a way to trick secure boot, exploit a management module, or putting in a USB key with malicious firmware). I'd actually like this on my laptop for the host OS, even.
It won't protect your laptop in case of a trusted boot breach. Also, kernel/OS updates will be tricky.

AMD memory encryption technologies

Posted Oct 25, 2016 3:52 UTC (Tue) by immibis (subscriber, #105511) [Link]

That client code might run on another machine physically controlled by the client.

AMD memory encryption technologies

Posted Sep 10, 2016 14:57 UTC (Sat) by bdell (subscriber, #84268) [Link] (2 responses)

Isn't the "guest owner" here the end user controlled system requesting the VM from the hypervisor, not code in the VM? The hypervisor can't patch in bad certificate checks in that case.

AMD memory encryption technologies

Posted Sep 11, 2016 1:22 UTC (Sun) by Cyberax (✭ supporter ✭, #52523) [Link] (1 responses)

It's the code inside the VM. If you have a trusted external system then you build an authentication chain that includes the guest VM to obtain an encryption key to unlock important data.

AMD memory encryption technologies

Posted Sep 11, 2016 2:18 UTC (Sun) by bdell (subscriber, #84268) [Link]

I guess I was going by slide 10 where the "guest owner" box is outside the box with all the hardware bits. The diagrams with the sequence of steps augment the box with "user". The secure processor supplies info about what was launched after the hypervisor can no longer tamper with it ultimately to the guest owner in slide 15 where it can be validated and authenticated before the disk encryption key is supplied to the VM. I don't see how the guest owner is inside the VM or can be tricked.

AMD memory encryption technologies

Posted Sep 9, 2016 6:37 UTC (Fri) by zuki (subscriber, #41808) [Link] (1 responses)

I cannot figure out one thing:
the hypervisor knows the ASID of a guest. What stops the hypervisor from adding a page table mapping for itself using this ASID for all of pages it has allocated for the guest and scanning those pages for any useful secrets?

AMD memory encryption technologies

Posted Sep 9, 2016 13:38 UTC (Fri) by yaap (subscriber, #71398) [Link]

Just guessing, but I would expect a read or write transaction to be tagged with the initiating ASID --- I can't see how the system could work otherwise in a multicore SMT system. Then the MMU hardware can check that the source ASID matches the target page ASID and if not block the access/trigger an exception.

AMD memory encryption technologies

Posted Sep 9, 2016 12:36 UTC (Fri) by OwenT (guest, #110558) [Link] (1 responses)

> It runs a secure (closed source) operating system
I understand why AMD have chosen to keep this closed source: it's proprietary and not a great deal of use to anyone who doesn't manufacture processors, so they're unlikely to be accepting pull requests on GitHub. However, I'm still a bit disappointed in this as it makes third-party verification of the process much harder, and I'd love to see AMD open this up for review in some way.

AMD memory encryption technologies

Posted Sep 10, 2016 0:33 UTC (Sat) by flussence (guest, #85566) [Link]

I have my doubts whether having something like that out in the open would help or hurt. It's PC motherboard firmware after all — which manufacturers are notoriously useless about keeping up to date and patched. (If they were more responsible, we wouldn't need workarounds like early microcode)

AMD memory encryption technologies

Posted Sep 17, 2016 6:22 UTC (Sat) by toyotabedzrock (guest, #88005) [Link] (1 responses)

The one issue is that without a secure place to store the disk encryption key on the system, inside a tamper resistant tpm the VM admin would have to provide it when ever the system is booted. And that admin would need to check that the certificate matched before providing that key.

AMD memory encryption technologies

Posted Mar 9, 2018 3:15 UTC (Fri) by gdamjan (subscriber, #33634) [Link]

that seems to be the "launch receipt" that's sent by the "Secure processor"


Copyright © 2016, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds