News for hackers. Stuff that matters.
Re:Linux to begin tightening up ability to write to CPU MSRs... by segfaultbuserr on Thursday June 25, 2020 @10:19AM (#23641027)
MSRs are not your ordinary registers, they are low-level registers for configuring major settings on the CPU.

> Think performance counter MSRs, MSRs with sticky or locked bits, MSRs making major system changes like loading microcode, MTRRs, PAT configuration, TSC counter, security mitigations MSRs, you name it.

I think the only legitimate uses of MSRs in userspace today is changing power-management related settings and performance profiling, which should be managed by the kernel anyway.

I welcome this move. PaX/grsec had an option to block MSR accesses for years.

Re:Linux to begin tightening up ability to write to CPU MSRs... by ghaff on Thursday June 25, 2020 @10:23AM (#23641082)
While I don't know for a fact if MSRs were used in this case, I was at a presentation a few months back where a security researcher (Kit Murdock) used under-voltaging to get data out of a secure enclave (SGX).

"Plundervolt is an attack on Intel SGX enclaves, which are trusted execution environments. We showed that we can get secrets out of SGX enclaves by lowering the CPU voltage while it is performing calculations. Plundervolt is a problem because SGX has an attacker model that says, “Even if you’re root, you should not be able to look inside my encrypted area.” "

https://research.redhat.com/wp-content/uploads/2019/12/RRQ-V...

Re:Linux to begin tightening up ability to write to CPU MSRs... by bserge on Thursday June 25, 2020 @10:44AM (#23641318)
Intel's solution? "Just disable voltage control, teehee"

Afaik, if you need the best security on Intel chips, disabling Hyper Threading is still a must :/

Wtf are they doing...

Re:Linux to begin tightening up ability to write to CPU MSRs... by nameless912 on Thursday June 25, 2020 @10:49AM (#23641394)
Blowing up 15 years of market dominance through mismanagement and hubris?
Re:Linux to begin tightening up ability to write to CPU MSRs... by wmf on Thursday June 25, 2020 @06:26PM (#23646478)
Would you prefer if they told you to just buy a new CPU... which isn't even available yet?
Re:Linux to begin tightening up ability to write to CPU MSRs... by ghaff on Thursday June 25, 2020 @11:00AM (#23641514)
Or AMD. One can argue about specific exploits but there are plenty of serious security folks who recommend turning off lots of performance features if you really want to be safe.
Re:Linux to begin tightening up ability to write to CPU MSRs... by Symmetry on Thursday June 25, 2020 @01:09PM (#23642893)
I do wish there was some sort of "1 process per physical core" rule you could apply at the scheduler level to get most of the benefit with fewer risks. Or maybe isolate the handling of untrusted code like browser javascript, pdfs, etc.
Re:Linux to begin tightening up ability to write to CPU MSRs... by WJW on Thursday June 25, 2020 @06:04PM (#23646300)
Step 1: Buy lots of raspberry pis.

Step 2: Run 1 process per pi.

Step 3: Enjoy freedom from spectre-related problems!

Optional step 4: Move everything back to Intel/AMD when management realizes why they went for multiple processes per box in the first place. Money rules everything around us.

Re:Linux to begin tightening up ability to write to CPU MSRs... by Symmetry on Friday June 26, 2020 @07:07AM (#23650684)
If I'm willing to give up long pipelines and out of order execution for security I'd at least go for a Project Denver chip or something. No need to give up all the single thread performance, or multiple cores sharing a memory pool.

Or more likely a chip with a ton of ARM A5* cores on it due to availability.

EDIT: Wait, it looks like I could actually get a Drive AGX for $700 on Newegg[1] and they seem to have about 40% the single thread performance of a Ryzen[2]. So actually not out of the question if I was willing to give up more for security than I actually am.

[1]https://www.newegg.com/nvidia-jetson-agx-xavier-32gb-256-bit...

[2]https://www.phoronix.com/scan.php?page=article&item=nvidia-j...

Re:Linux to begin tightening up ability to write to CPU MSRs... by secondcoming on Thursday June 25, 2020 @01:28PM (#23643137)
You can tell the kernel to not make certain cores available to the scheduler (isolcpus)
Re:Linux to begin tightening up ability to write to CPU MSRs... by Symmetry on Thursday June 25, 2020 @03:28PM (#23644531)
Yes, but that doesn't help if I want a virtual core to only be available to threads belonging to the same process as the thread on the other virtual core. I suppose syscalls make the idea not work anyways.
Re:Linux to begin tightening up ability to write to CPU MSRs... by lima on Thursday June 25, 2020 @10:34AM (#23641195)
> I welcome this move. PaX/grsec had an option to block MSR accesses for years.

On recent kernels, MSRs writes are disabled by default even by the upstream kernel when the kernel is in lockdown mode (like when using Secure Boot).

Re:Linux to begin tightening up ability to write to CPU MSRs... by kinghajj on Thursday June 25, 2020 @05:54PM (#23646214)
Yup, I just wrote a blog post about recompiling the msr module and signing it with a MOK, as a way to keep undervolting functional while using SecureBoot.

https://kinghajj.github.io/blog/undervolting-with-secureboot...

Re:Linux to begin tightening up ability to write to CPU MSRs... by pwdisswordfish2 on Friday June 26, 2020 @01:48AM (#23649082)
That is a well-written blog post. Thanks for sharing. Wondering if I can do this with a BSD kernel.
Re:Linux to begin tightening up ability to write to CPU MSRs... by Wowfunhappy on Thursday June 25, 2020 @10:24AM (#23641097)
And also, because it's Linux, anyone who really needs this for some kind of niche reason can recompile the kernel, right?
Re:Linux to begin tightening up ability to write to CPU MSRs... by segfaultbuserr on Thursday June 25, 2020 @10:26AM (#23641120)
It's even better - you just need to change your boot parameters.

> This behavior right now can be toggled via the msr.allow_writes= kernel module paramrter with on/off/default. Should legitimate use-cases come up where writes to MSRs from user-space are still desired, they may add the infrastructure to selectively grant/deny access to specific MSRs and ensure they are sanitized by the kernel.

Similar hardware restrictions already exists in the kernel, for example, by default the kernel restricts access to I/O memory since it's a dangerous, low-level zone, but if you really need to for some reasons (e.g. reflash your BIOS), you can boot with "iomem=relaxed" to turn it off. Treating MSR registers in the same way is very reasonable.

Re:Linux to begin tightening up ability to write to CPU MSRs... by kinghajj on Thursday June 25, 2020 @05:56PM (#23646232)
Is there any clarification on how this MSR whitelisting will be implemented by end users? Or is there just going to be the global "allow_writes" parameters? I'd assume too that even with that parameter set to on, programs accessing the MSRs will still need the SYS_RAWIO capability.
Re:Linux to begin tightening up ability to write to CPU MSRs... by segfaultbuserr on Thursday June 25, 2020 @06:27PM (#23646486)
Not sure, but I believe root or equivalent (CAP_SYS_RAWIO) privilege is always needed to write MSR, nothing has changed here.
Re:Linux to begin tightening up ability to write to CPU MSRs... by Wowfunhappy on Thursday June 25, 2020 @10:41AM (#23641273)
Ah, perfect! That seems like exactly the right way to handle things.
Re:Linux to begin tightening up ability to write to CPU MSRs... by bserge on Thursday June 25, 2020 @10:39AM (#23641252)
Thank God for that (niche reason being fine grained performance and thermal management on inadequately cooled machines, which is... all of them :D)
Re:Linux to begin tightening up ability to write to CPU MSRs... by Const-me on Friday June 26, 2020 @06:42AM (#23650533)
Timestamp counter have legitimate uses, the combination of resolution and access cost is unprecedented. I use them when I need timestamps for events which happen at 1MHz or more. On modern CPUs these counters even run at stable frequency, unaffected by scaling.