News for hackers. Stuff that matters.
Re:macOS extensions are moving away from the kernel by AshamedCaptain on Wednesday July 07, 2021 @05:16AM (#27759066)
The entire "ring 1" thing is highly likely false. It's been decades since I last saw anyone using the x86 ring levels and I seriously doubt XNU is using them.

In any case, extensions run in the same address space as the rest of the kernel making any such "rings" pointless.

Re:macOS extensions are moving away from the kernel by kmeisthax on Wednesday July 07, 2021 @10:16AM (#27761375)
The funny thing is that the M1 has an undocumented but totally used feature called Guarded Execution[0] that lets you separate parts of the kernel (or hypervisor, if you're in EL2) from one another. Basically, on the M1 each Exception Level now has a regular and a guarded sublevel, with their own page table permissions, and special instructions to enter or exit the guarded execution within the same EL.

macOS on the M1 uses this to prohibit most kernel code from touching pagetables. You have to do that from within the guarded sublevel, which kernel extensions can only call into.

This is more or less the original intent of x86 rings: to separate an OS kernel out into parts with different permissions and levels of isolation.

[0] https://blog.svenpeter.dev/posts/m1_sprr_gxf/

Re:macOS extensions are moving away from the kernel by als0 on Wednesday July 07, 2021 @06:06AM (#27759344)
Rings 1 and 2 don't even exist on AMD64/x86-64.
Re:macOS extensions are moving away from the kernel by zvrba on Wednesday July 07, 2021 @08:37AM (#27760393)
Yes they do, but segmentation is practically non-existent and page tables distinguish only between rings 0 and rings 1-3. So no, they aren't very useful, but they do exist and, AFAIK, they're still checked in "far" control transfers.
Re:macOS extensions are moving away from the kernel by tzs on Wednesday July 07, 2021 @10:09AM (#27761298)
It's too bad they have been made useless. I'm not fully sure about this, but I think that if you could have two rings for user code so that applications that want to run untrusted code in a sandbox could run the main application in ring 2 and the sandboxed code in ring 3, you could make the application safe from Spectre attacks from the sandboxed code without giving up performance.
Re:macOS extensions are moving away from the kernel by bonzini on Wednesday July 07, 2021 @01:42PM (#27763793)
The point of Spectre attacks is that they use side channel to infer the target's data from communication between the target and the attacking userspace process. This is possible even over the network, so ring 2 wouldn't help much.
Re:macOS extensions are moving away from the kernel by zinekeller on Wednesday July 07, 2021 @06:11AM (#27759371)
I mean, recent developments in the Windows/NT architecture uses virtualization to create a three-level "ring" system, so while it's not strictly architectural "rings", it's effectively a tri-ring system.

But then, I haven't delved into how macOS in M1 precisely works.

Re:macOS extensions are moving away from the kernel by AshamedCaptain on Wednesday July 07, 2021 @06:21AM (#27759413)
Virtualization is indeed the last user of the x86-ring 1 that I remember. But it is much easier to put an entire virtualized kernel in a different ring (x86 or ?) than selectively put pieces and parts of one in different rings, which no one does.
Re:macOS extensions are moving away from the kernel by zinekeller on Wednesday July 07, 2021 @06:37AM (#27759489)
> Virtualization is indeed the last user of the x86-ring 1 that I remember.

Yes, I know, but I'm referring to hardware virtualization, essentially making "ring -1" "ring 0" and "ring 0" "ring 1".

Re:macOS extensions are moving away from the kernel by mmis1000 on Wednesday July 07, 2021 @01:52PM (#27763893)
If you ever want to, it seems you can have a unlimited layer of 'rings' now? I heard that both amd and intel have nested page virtualization in recent products.

Besides that, hyperv seems make use of it to achieve paravirtulization?

Re:macOS extensions are moving away from the kernel by bonzini on Wednesday July 07, 2021 @01:43PM (#27763801)
Xen on 32-bit x86 used the real ring 1. :)