mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel: Pass name+length to set_mmap_name() and remove SmapDisabler
This commit is contained in:
parent
6af8392cf8
commit
33025a8049
Notes:
sideshowbarker
2024-07-19 10:18:45 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/33025a8049e
4 changed files with 27 additions and 8 deletions
|
@ -208,17 +208,24 @@ Region* Process::region_containing(const Range& range)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int Process::sys$set_mmap_name(void* addr, size_t size, const char* name)
|
||||
int Process::sys$set_mmap_name(const Syscall::SC_set_mmap_name_params* user_params)
|
||||
{
|
||||
SmapDisabler disabler;
|
||||
if (!validate_read_str(name))
|
||||
if (!validate_read_typed(user_params))
|
||||
return -EFAULT;
|
||||
auto* region = region_from_range({ VirtualAddress((u32)addr), size });
|
||||
|
||||
Syscall::SC_set_mmap_name_params params;
|
||||
copy_from_user(¶ms, user_params, sizeof(params));
|
||||
|
||||
if (!validate_read(params.name, params.name_length))
|
||||
return -EFAULT;
|
||||
auto name = copy_string_from_user(params.name, params.name_length);
|
||||
|
||||
auto* region = region_from_range({ VirtualAddress((u32)params.addr), params.size });
|
||||
if (!region)
|
||||
return -EINVAL;
|
||||
if (!region->is_mmap())
|
||||
return -EPERM;
|
||||
region->set_name(String(name));
|
||||
region->set_name(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
pid_t sys$waitpid(pid_t, int* wstatus, int options);
|
||||
void* sys$mmap(const Syscall::SC_mmap_params*);
|
||||
int sys$munmap(void*, size_t size);
|
||||
int sys$set_mmap_name(void*, size_t, const char*);
|
||||
int sys$set_mmap_name(const Syscall::SC_set_mmap_name_params*);
|
||||
int sys$mprotect(void*, size_t, int prot);
|
||||
int sys$madvise(void*, size_t, int advice);
|
||||
int sys$purge(int mode);
|
||||
|
|
|
@ -298,6 +298,13 @@ struct SC_realpath_params {
|
|||
size_t buffer_size;
|
||||
};
|
||||
|
||||
struct SC_set_mmap_name_params {
|
||||
void* addr;
|
||||
size_t size;
|
||||
const char* name;
|
||||
size_t name_length;
|
||||
};
|
||||
|
||||
void initialize();
|
||||
int sync();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <errno.h>
|
||||
#include <mman.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -41,7 +42,12 @@ int mprotect(void* addr, size_t size, int prot)
|
|||
|
||||
int set_mmap_name(void* addr, size_t size, const char* name)
|
||||
{
|
||||
int rc = syscall(SC_set_mmap_name, addr, size, name);
|
||||
if (!name) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
Syscall::SC_set_mmap_name_params params { addr, size, name, strlen(name) };
|
||||
int rc = syscall(SC_set_mmap_name, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
|
@ -50,5 +56,4 @@ int madvise(void* address, size_t size, int advice)
|
|||
int rc = syscall(SC_madvise, address, size, advice);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue