MemoryManager: Add validate_userspace_string()
A bit crude, should be replaced by a strdup_from_user() helper to avoid touching userspace memory directly. But it'll do for now.
This commit is contained in:
parent
0ea9974512
commit
caa3fe8c45
@ -347,6 +347,23 @@ namespace MemoryManager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Replace this with some kind of strdup_from_user() function.
|
||||||
|
bool validate_userspace_string(u64 address)
|
||||||
|
{
|
||||||
|
if (!validate_readable_page(address)) return false;
|
||||||
|
|
||||||
|
while (*(char*)address != 0)
|
||||||
|
{
|
||||||
|
address++;
|
||||||
|
if (address % ARCH_PAGE_SIZE)
|
||||||
|
{
|
||||||
|
if (!validate_readable_page(address)) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
usize free()
|
usize free()
|
||||||
{
|
{
|
||||||
return free_mem;
|
return free_mem;
|
||||||
|
@ -20,6 +20,8 @@ namespace MemoryManager
|
|||||||
bool validate_readable_page(u64 address);
|
bool validate_readable_page(u64 address);
|
||||||
bool validate_writable_page(u64 address);
|
bool validate_writable_page(u64 address);
|
||||||
|
|
||||||
|
bool validate_userspace_string(u64 address);
|
||||||
|
|
||||||
Result<void> map_frames_at(u64 virt, u64 phys, usize count, int flags);
|
Result<void> map_frames_at(u64 virt, u64 phys, usize count, int flags);
|
||||||
|
|
||||||
Result<u64> alloc_at(u64 virt, usize count, int flags);
|
Result<u64> alloc_at(u64 virt, usize count, int flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user