6 ms·
Memfd_secret() in 5.14
- eigma 5y agoNewbie question: multiple articles on this topic state that "even the kernel cannot access this memory" [because it is not in the direct map]. But surely, under assumption of arbitrary kernel code execution, a determined payload could restore the relevant direct map mappings, and still access this memory?
- simcop2387 5y agoCorrect. The idea tthough is thay th4 mapping isn't in the places that are usually accessible so the normal gadgets thay get used won't work. In the future combinjng this with something like sev would make even more difficult to exploit.
- cmeacham98 5y agoMy understanding is this would protect against arbitrary reads in the kernel (but not arbitrary code execution as you pointed out).
- deleted 5y ago[deleted]
- est31 5y agoI wonder about the swap behaviour. If it's going to go to swap, it means the secret might remain on the hard disk. If the swap is on an SSD, you might not have a way to securely delete it at all due to the wear levelling layer. If it's not going to swap, you piss off the people with laptops who want hibernation. You might need to encrypt it and store the key in the TPM or something. Not sure if that's implemented though.
- deleted 5y ago[deleted]
- alksjdalkj 5y agoThe article says that hibernation is completely disabled when a secret memory area is active and the memory area is locked into RAM. They designed it so the secret would never be written to persistent storage.
- GauntletWizard 5y agoThere's a whole section on the memory implications: "Another change, which created a bit of controversy over the life of the patch, disables hibernation when a secret memory area is active." Based on that, I doubt they ignored the problem of swap space. My guess is that the region of memory is designated unswappable, as was already possible before.
- nextaccountic 5y agoIdeally there would be a way for the OS to signal that it's going to hibernate, so that the application can get rid of the secret stuff (overwrite with zeroes etc) and go to a state that, when back from hibernation, would ask for a password again. Or even, disable this when hibernating to a swap inside an encrypted luks partition (which also asks for a password when it wakes up)
- Galanwe 5y agoI guess it should be theorically possible already for processes to do that. Systemd for instance is monitoring the suspend state.
- mjw1007 5y agoPerhaps a reasonable way would be to have a memfd_secret() flag which requests "kill this process if you're going to hibernate". Then you could do the operations involving the secret in a dedicated subprocess.
- formerly_proven 5y agoThis sounds usable to me and also promotes process-based isolation of application subcomponents.
- astan 5y agomlock already allows you to do this so they likely did consider it
- citrin_ru 5y agoAs noted in other comments it is locked in memory and hibernation is disabled, but generally encrypted swap is even easier to use than encrypted FS - a key can be generated on each boot (one-time random swap key is not compatible with hibernation though, for this you'd need a fixed one).
- nneonneo 5y agoPer an earlier article in this series, https://lwn.net/Articles/812325/ https://lwn.net/Articles/812325/, this syscall is meant for protecting against disclosure of secrets via things like speculative execution and cache attacks, by ensuring that the kernel does not have the secret memory mapped at all. It does not protect against other kinds of attacks, like malicious code in the kernel. Thus, it will not keep your memory secret in every possible case; for that, you’d want to use something like Intel SGX (modulo the many vulnerabilities in that technology) which uses a combination of memory encryption and processor features to keep memory secret even from malicious kernels, hypervisors, etc.
- josephcsible 5y agoI dislike the forced disablement of hibernation. That should have been something you could opt out of with a kernel command line parameter.
- nitinreddy88 5y agoHonestly hibernation never worked out perfectly in Linux. I have desktops to laptops running with different hardware, every once in a while the hibernation goes for toss and need to reboot
- juancampa 5y agoWorks fine for me. I believe the only time I've seen issues is when I upgrade the kernel, forget to restart, and then hibernate the old (running) kernel. But it just ignores the image and boots like normal
- juancampa 5y agoWorks fine for me. I believe the only time I've seen issues is when I upgrade the kernel, forget to restart, and then hibernate the old (running) kernel. But then it just ignores the image and boots like normal
- dgan 5y agoi had hibernation problem with one specific network card,i guess atheros,it would make the whole system hang
- Galanwe 5y agoI don't think it's really annoying in practice. First, most Linux servers don't care about hibernation, so the issue really just happens for desktops/laptops. Second, there are at least 3 or 4 suspend states that Linux can offer, hibernation happens to be the most efficient one, but downgrading to a slightly less power efficient suspend state that keeps power in the RAM shouldn't make that much difference. See https://01.org/linuxgraphics/gfx-docs/drm/admin-guide/pm/sleep-states.html https://01.org/linuxgraphics/gfx-docs/drm/admin-guide/pm/sle... for more information.
- staticassertion 5y agoThis is a big capability. Right now it's quite difficult (requiring pinning together a few pieces of technology) to protect one process from another, especially if the other process is root. This isn't enough to get quite there, but it's a good start. Windows has been working on similar tech via Protected Processes[0], notably used for both LSASS and their new eBPF verifier. That's been a tricky technology to get right but I think it's interesting. > Andy Lutomirski repeatedly opposed making uncached mappings available, objecting to the performance cost and more; Interesting. I'll want to read more into this. My guess is that for the next 5 years there will be endless ways to leak these secrets and maybe, if we're lucky, things will improve over that time. [0] https://www.alex-ionescu.com/?p=97 https://www.alex-ionescu.com/?p=97
- diegocg 5y agoThis seems pretty cool, but I'm pretty sure that malware creators are going to be one of the main users.
- tinus_hn 5y agoWhat about the most important secrets of all, DRM keys?
- na85 5y agoIf they're visible to children surely you can inject a DLL and exec into a new child process with access to the key?
- MathMonkeyMan 5y agoThe file is closed on exec, I believe.
- sleavey 5y agoIf you wanted DRM keys, couldn't you just patch memfd_secret() to remove its security features, let the program use it, then have a look at the assigned memory?
- c0l0 5y agoSure, on paper, that will always be possible - just not in the age of signed kernel images that are cryptographically verified by your immutable bootloader.
- deleted 5y ago[deleted]
- remram 5y agoDo we live in that age? Are there any computers that can't be made to boot an unsigned image? My experience is that Secure Boot is optional.
- sillycross 5y agoI'm most amused by this comment in the original post: (Context: the discussion is around the drawback that memfd_secret must disable hibernation) > That's why the only way to introduce new security feature is with “more security” choice being the only option. > ... eventually, Chrome and Firefox would join the crowd. At that point it would become a moot point if you want to use hibernation or not: you system wouldn't be much useful if you would choose the hibernation. Always interesting to see how ignorant some "security experts" are and how they love to hijack users and sabotage user experience using the excuse of "security".
- captainmuon 5y agoThe solution is to either encrypt or evict the secret memory on hibernation, and then decrypt it or have the app derive the secrets again when the user enters their password. This would require some cooperation with the login program, and maybe with the user app, so it's hard to organize in the Linux world. I think something like this is available on Windows, but I'm not sure. It would be also great if you could use the graphical login (greeter) to decrypt your disk (at boot or after sleep). I think some of the neccessary infrastructure would be the same for both features.
- api 5y agoWhy can’t the kernel just generate a random secret at boot and encrypt swap and hibernate files automatically? MacOS does this. I thought Linux did already. With AES in hardware it’s not much more costly than memcpy.
- jchw 5y agoThis is done for Linux Lockdown. For memfd_secret, it might not be considered good enough; I think the memory needs to be evicted.
- api 5y agoWhat is the threat model for this? If it’s a highly advanced attacker with physical access not even that is good enough. The best we can do is a true hardware enclave.