text stringlengths 0 1.99k |
|---|
sane and allowed. If so it then performs an action on behalf of that |
ring 3 request. |
---[ 2.1.2 - Page protections |
A page is a physical region of memory that can be mapped to one or more |
virtual addresses [3]. These mappings have several flags that determine |
how the mapped page can be accessed. For this article we only care |
about the following 3 flags: |
P - Present |
Is this page mapped at all? |
R/W - Read/Write |
Is this page read-only or writable? |
U/S - User/Supervisor |
Is this page accessible from ring 3 or only ring 0? |
I want to explicitly point out that these flags exist for each separate |
mapping of a page. The same physical page can be mapped at multiple |
virtual addresses with different permissions. |
---[ 2.1.3 - KASLR - Kernel Address Space Layout Randomization |
The kernel version of user space ASLR you may already be familiar with. |
What this effectively means is that you don't know ahead of time where |
in memory the kernel will be mapped. |
---[ 2.1.4 - SMEP/SMAP - Supervisor Mode Execution/Access Prevention |
These two mitigations prevent the kernel from accessing userspace |
memory directly through a pointer. Any data access has to instead go |
through special functions that will temporarily disable the mitigation. |
Any execution access of userspace memory in kernel mode is completely |
disallowed. When the kernel returns to userspace it has to also switch |
to user mode at the same time. |
---[ 2.1.5 - ToaruOS mitigations overview |
+ CPU rings |
+ Page Protections |
- KASLR |
- SMEP/SMAP |
On ToaruOS the first two mitigations exist and the latter two don't. |
This is more or less expected since the first two are mainly enforced |
by the hardware architecture rather than the OS. |
The first three of those are the ones you should keep in mind for the |
rest of this article. |
---[ 3 - Kernel bugs |
We are all very used to the security guarantees that our OS provides |
and most of us probably take them for granted. |
Of course, you can't open /etc/shadow as a normal user. |
Of course, you can't just attach a debugger to a root process and alter |
what it does. |
Of course, you can't change the owner of an suid executable and keep |
the suid flag. |
But all of those things are enforced by the operating system. |
It is common to become root or SYSTEM to demonstrate a kernel exploit, |
but the truth is that you effectively have even higher privileges. |
If the OS, specifically the kernel, isn't stopping you, you can do |
anything. |
(Yes, I am ignoring hypervisor based security for dramatic reasons) |
All this to say: Kernel bugs may have the same root causes as many user |
space bugs, but there are also entirely different bug classes that can |
only really exist in a kernel. |
So, I encourage you to challenge your preconceptions and question even |
those "obvious" security concepts. ToaruOS has quite a few |
similarities to Linux, so it is tempting to assume it provides all of |
the same guarantees. |
---[ 4 - Searching for a bug |
Since the kernels' job is to enforce security guarantees it makes sense |
to start by looking at how exactly it does that. Our goal is simply to |
read a file, so let's look at how we may be able to open it. |
---[ 4.1 - How to open a file |
If you want to open a file in C you call the libc open() function. |
This function internally then issues the corresponding system call. |
The kernel side code of ToaruOS that handles the syscall is sys_open() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.