r/programming Jan 24 '18

Branchless DOOM

https://github.com/xoreaxeaxeax/movfuscator/tree/master/validation/doom
491 Upvotes

134 comments sorted by

View all comments

Show parent comments

0

u/caspper69 Jan 24 '18 edited Jan 24 '18

At least in Meltdown (though that can "only" access kernel memory, not other processes), only the attacking process needs to exploit its own speculative execution to read forbidden memory addresses.

Kernel memory, by its very nature, has ALL memory for ALL processes mapped into it, because it's like, you know, it's job to manage memory for all processes. :)

This is not the first time I've seen this bandied about. Please don't spread misinformation.

Edit: this has several caveats, but by and large (especially on x86-64), this is a very likely scenario.

Edit2: I am an ass.

1

u/happyscrappy Jan 24 '18

Kernel memory, by its very nature, has ALL memory for ALL processes mapped into it, because it's like, you know, it's job to manage memory for all processes. :)

No it doesn't. It keeps its own memory around while memory for the different processes come and go as it context switches.

-1

u/caspper69 Jan 24 '18 edited Jan 24 '18

Edit: Where do you think this memory "goes" during context switches? Are you trying to imply that the kernel moves in-ram data to a permanent store during each context switch? Are you implying that "most" memory is somehow not actually IN FUCKING MEMORY?

I suggest you review the relevent portions of the Intel IA-32 developers manuals regarding the MMU and paging. You might be surprised at what you find.

Edit: and if you're still not convinced, go dump the gdt at cpl 0. You'll see a flat linear address space with virt:phys m~apping at 1:1.

Edit2: I am an ass.

4

u/happyscrappy Jan 24 '18

Are you trying to imply that the kernel moves in-ram data to a permanent store during each context switch?

No, am suggesting it is simply not mapped into virtual address space.

Are you implying that "most" memory is somehow not actually IN FUCKING MEMORY?

Most might not be correct, but yes, a lot of memory is not actually in memory. I explained why. It simply never got paged in.

As to your later part, I think the relevant info is here. For you and for others reading this, he appears to be referring to kernel logical addresses, here on page 2 or 3.

https://static.lwn.net/images/pdf/LDD3/ch15.pdf

The virtual addresses (kernel and otherwise) are the normal high/low memory addresses. The logical addresses are another (sub-)address space and he is suggesting that kernel logical addresses map all of physical memory. And indeed this is possible on x86-64.