-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MVP Loader implementation #458
Conversation
sagiegurari/shell2batch#9Lines 224 to 234 in 2ba154e
This comment was generated by todo based on a
|
Write our threat models. Will require careful planning.SunriseOS/docs/SECURITY_ARCHITECTURE.md Lines 155 to 161 in 2ba154e
This comment was generated by todo based on a
|
ASLRWe should generate a random aslr base. Lines 153 to 163 in 2ba154e
This comment was generated by todo based on a
|
This comment has been minimized.
This comment has been minimized.
Ask the weird animal if this will unleash the kraken.SunriseOS/kernel/src/paging/arch/i386/lands.rs Lines 61 to 63 in 2ba154e
This comment was generated by todo based on a
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Create memory region reservationsMemory region reservations is sort of insane in HOS/NX - especially for 32-bit. I'll figure it out later. SunriseOS/kernel/src/syscalls.rs Lines 948 to 958 in 2ba154e
This comment was generated by todo based on a
|
Use svcGetInfo to get the address space in find_free_addressWe should use svcGetInfo to get the address space in `find_free_address`. This is extremely important as the low addresses (from 0 to ADDRESS_SPACE_MIN) are not usable, but are marked as available by QueryMemory. Lines 25 to 35 in 2ba154e
This comment was generated by todo based on a
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Sysmodule, | ||
/// Pool of memory usable by nvidia's driver. | ||
/// | ||
/// <Insert nvidia meme here> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kernel/src/syscalls.rs
Outdated
if meminfo.address() < addr { | ||
dstmem.map_partial_shared_mapping(frames.clone(), meminfo.address(), meminfo.phys_offset(), addr - meminfo.address(), meminfo.state().ty(), meminfo.flags()).expect("Can't fail"); | ||
} | ||
if meminfo.address() + meminfo.length() > addr + size && meminfo.length() > PAGE_SIZE { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, you're checking if there's an after part, and remapping it as is. But why the meminfo.length() > PAGE_SIZE
condition ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm...
|
||
if size > MAX_ELF_SIZE { | ||
error!("Why is titleid {:016x} so ridiculously huge? It's {} bytes. | ||
Like, seriously, stop with the gifs!", titleid, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// BODY: a vector of frames) and comparing them. | ||
// BODY: | ||
// BODY: We could do something similar by iterating over the Mappings and | ||
// BODY: checking if their Frames + PhysOffset are equals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syscall is really shitty.
I don't get why it didn't simply create a handle of some kind, and you could simply unmap the handle as a whole.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♂ I don't find it all that bad. Just maybe a bit too flexible.
I do hate that closing the handle doesn't automatically unmap the frames though.
This comment has been minimized.
This comment has been minimized.
UnmapProcessMemory: Verify that the src page list == dst page list.In UnmapProcessMemory, we don't ensure that src_address is correct, that is, we don't check that the frames in the dst match the frame in the src. HOS/NX does this by building a PageList (essentially a vector of frames) and comparing them. SunriseOS/kernel/src/syscalls.rs Lines 952 to 962 in 9e93f28
This comment was generated by todo based on a
|
UnmapProcessMemory: Verify that the src page list == dst page list.In UnmapProcessMemory, we don't ensure that src_address is correct, that is, we don't check that the frames in the dst match the frame in the src. HOS/NX does this by building a PageList (essentially a vector of frames) and comparing them. SunriseOS/kernel/src/syscalls.rs Lines 952 to 962 in e1d6e43
This comment was generated by todo based on a
|
UnmapProcessMemory: Verify that the src page list == dst page list.In UnmapProcessMemory, we don't ensure that src_address is correct, that is, we don't check that the frames in the dst match the frame in the src. HOS/NX does this by building a PageList (essentially a vector of frames) and comparing them. SunriseOS/kernel/src/syscalls.rs Lines 952 to 962 in 2d7cdb3
This comment was generated by todo based on a
|
kernel/src/process.rs
Outdated
ProcessState::CreatedAttached => ProcessState::StartedAttached, | ||
_ => unreachable!() | ||
}; | ||
this.state.store(newstate, Ordering::SeqCst); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
textbook read-modify-write race condition.
You need to compare exchange the states, to arbitrate who's the winner of the race, and gets to actually start it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly why I believe we should be mutexing this stuff :P
- Process::new now takes a ProcInfo, and derives all necessary information from this. - Specify aslr base in a single location. - Make UserLand address space start at 0x00200000 - Implement create_process syscall, as accurately as currently possible.
MapProcessMemory will allow loader to map the remote code created in CreateProcess in its own address space in order to load the ELf into it.
This function mimicks nintendo's KMemoryManager::CheckRange. It goes over a memory region and checks that it is in the expected state (both in terms of MemoryState, MemoryPermissions and MemoryAttributes), and that it is homogenous (that is, all submappings have the same state and perms). This is used to significantly simplify set_process_memory_permission and map_process_memory.
Used to unmap memory mapped with MapProcessMemory. Loader now unmaps the process memory it previously mapped.
Stop unwrapping left and right and return actual errors. This means we should no longer be crashing if we send an invalid binary to loader. Instead, loader will log an error and hum along.
Avoids starting a process twice. Will in the future allow tracking crashes, and allow waiting on a process from userspace to see when it changes state.
UnmapProcessMemory: Verify that the src page list == dst page list.In UnmapProcessMemory, we don't ensure that src_address is correct, that is, we don't check that the frames in the dst match the frame in the src. HOS/NX does this by building a PageList (essentially a vector of frames) and comparing them. SunriseOS/kernel/src/syscalls.rs Lines 952 to 962 in 3b26b34
This comment was generated by todo based on a
|
UnmapProcessMemory: Verify that the src page list == dst page list.In UnmapProcessMemory, we don't ensure that src_address is correct, that is, we don't check that the frames in the dst match the frame in the src. HOS/NX does this by building a PageList (essentially a vector of frames) and comparing them. SunriseOS/kernel/src/syscalls.rs Lines 952 to 962 in 06f20e2
This comment was generated by todo based on a
|
UnmapProcessMemory: Verify that the src page list == dst page list.In UnmapProcessMemory, we don't ensure that src_address is correct, that is, we don't check that the frames in the dst match the frame in the src. HOS/NX does this by building a PageList (essentially a vector of frames) and comparing them. SunriseOS/kernel/src/syscalls.rs Lines 952 to 962 in 5b48fde
This comment was generated by todo based on a
|
UnmapProcessMemory: Verify that the src page list == dst page list.In UnmapProcessMemory, we don't ensure that src_address is correct, that is, we don't check that the frames in the dst match the frame in the src. HOS/NX does this by building a PageList (essentially a vector of frames) and comparing them. SunriseOS/kernel/src/syscalls.rs Lines 954 to 964 in 27ab3e4
This comment was generated by todo based on a
|
seriously, todobot, you're drunk. Hopefully this time travis passes and we'll get this merged. |
MVP loader. Things to do before merging this PR: