NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
Linux Internals: How /proc/self/mem writes to unwritable memory (2021) (offlinemark.com)
hansendc 4 hours ago [-]
"On x86-64, there are two CPU settings which control the kernel’s ability to access memory."

There are a couple more than two, even in 2021.

Memory Protection Keys come to mind, as do the NPT/EPT tables when virtualization is in play. SEV and SGX also have their own ways of preventing the kernel from writing to memory. The CPU also has range registers that protect certain special physical address ranges, like the TDX module's range. You can't write there either.

That's all that comes to mind at the moment. It's definitely a fun question!

KenoFischer 1 hours ago [-]
I'm still surprised I was the first one to notice when Linus tried to change this - I always thought it was a pretty well known behavior.
bluepeter 4 hours ago [-]
The kernel owns the page tables. It can always find another way in.
mschuster91 4 hours ago [-]
> The kernel owns the page tables.

not entirely, IOMMU is a thing, that is IIRC how Amazon and other hyperscalers can promise you virtual machines whose memory cannot be touched even in the case the host is compromised (and, by extension, also if the feds arrive to v& your server).

gruez 32 minutes ago [-]
>how Amazon and other hyperscalers can promise you virtual machines whose memory cannot be touched even in the case the host is compromised (and, by extension, also if the feds arrive to v& your server).

Even if we take those promises at face value, it practically doesn't mean much because every server still needs to handle reboots, which is when they can inject their evil code.

Borealid 11 minutes ago [-]
MK-TME allows having memory encrypted at run time, and the platform TPM signs an attestation saying the memory was not altered.

Malicious code can't be injected at boot without breaking that TPM.

ronsor 2 hours ago [-]
If your threat model is being v& by feds, maybe you should keep your server at home behind Tor.
haberman 2 hours ago [-]
TL;DR: when a user writes to /proc/self/mem, the kernel bypasses the MMU and hardware address translation, opting to emulate it in software (including emulated page faults!), which allows it to disregard any memory protection that is currently setup in the page tables.
rramadass 33 minutes ago [-]
Thank You.
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 04:07:07 GMT+0000 (Coordinated Universal Time) with Vercel.