mirror of
https://github.com/clearlinux/graphene.git
synced 2026-10-03 23:48:19 +00:00
[Pal/Linux] reverse the return value of _DkCheckMemoryMappable()
At the glance of the function name, people will expect it return - true if mappable - false if not. But it's reverse. Make return value what is usually expected.
This commit is contained in:
@@ -153,7 +153,7 @@ static int file_map (PAL_HANDLE handle, void ** addr, int prot,
|
||||
{
|
||||
int fd = handle->file.fd;
|
||||
void * mem = *addr;
|
||||
if (mem && _DkCheckMemoryMappable(mem, size))
|
||||
if (mem && !_DkCheckMemoryMappable(mem, size))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
/*
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
bool _DkCheckMemoryMappable (const void * addr, size_t size)
|
||||
{
|
||||
return (addr < DATA_END && addr + size > TEXT_START);
|
||||
return (addr >= DATA_END || addr + size <= TEXT_START);
|
||||
}
|
||||
|
||||
int _DkVirtualMemoryAlloc (void ** paddr, size_t size, int alloc_type,
|
||||
@@ -42,7 +42,7 @@ int _DkVirtualMemoryAlloc (void ** paddr, size_t size, int alloc_type,
|
||||
{
|
||||
void * addr = *paddr, * mem = addr;
|
||||
|
||||
if (addr && _DkCheckMemoryMappable(addr, size))
|
||||
if (addr && !_DkCheckMemoryMappable(addr, size))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
int flags = HOST_FLAGS(alloc_type, prot|PAL_PROT_WRITECOPY);
|
||||
@@ -60,7 +60,7 @@ int _DkVirtualMemoryAlloc (void ** paddr, size_t size, int alloc_type,
|
||||
|
||||
int _DkVirtualMemoryFree (void * addr, size_t size)
|
||||
{
|
||||
if (_DkCheckMemoryMappable(addr, size))
|
||||
if (!_DkCheckMemoryMappable(addr, size))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
int ret = INLINE_SYSCALL(munmap, 2, addr, size);
|
||||
@@ -70,7 +70,7 @@ int _DkVirtualMemoryFree (void * addr, size_t size)
|
||||
|
||||
int _DkVirtualMemoryProtect (void * addr, size_t size, int prot)
|
||||
{
|
||||
if (_DkCheckMemoryMappable(addr, size))
|
||||
if (!_DkCheckMemoryMappable(addr, size))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
int ret = INLINE_SYSCALL(mprotect, 3, addr, size, HOST_PROT(prot));
|
||||
|
||||
@@ -82,7 +82,7 @@ int handle_set_cloexec(PAL_HANDLE handle, bool enable) {
|
||||
/* _DkStreamUnmap for internal use. Unmap stream at certain memory address.
|
||||
The memory is unmapped as a whole.*/
|
||||
int _DkStreamUnmap(void* addr, uint64_t size) {
|
||||
if (_DkCheckMemoryMappable(addr, size))
|
||||
if (!_DkCheckMemoryMappable(addr, size))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
/* Just let the kernel tell us if the mapping isn't good. */
|
||||
|
||||
Reference in New Issue
Block a user