From c6147a439d16112a0794b3fb98e825a9be864066 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 29 Mar 2019 18:01:38 -0400 Subject: kernel/shared_memory: Sanitize supplied size when unmapping The kernel makes sure that the given size to unmap is always the same size as the entire region managed by the shared memory instance, otherwise it returns an error code signifying an invalid size. This is similarly done for transfer memory (which we already check for). --- src/core/hle/kernel/shared_memory.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/core/hle/kernel/shared_memory.cpp') diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 62861da36..273e6a25e 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -119,7 +119,15 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi ConvertPermissions(permissions)); } -ResultCode SharedMemory::Unmap(Process& target_process, VAddr address) { +ResultCode SharedMemory::Unmap(Process& target_process, VAddr address, u64 unmap_size) { + if (unmap_size != size) { + LOG_ERROR(Kernel, + "Invalid size passed to Unmap. Size must be equal to the size of the " + "memory managed. Shared memory size=0x{:016X}, Unmap size=0x{:016X}", + size, unmap_size); + return ERR_INVALID_SIZE; + } + // TODO(Subv): Verify what happens if the application tries to unmap an address that is not // mapped to a SharedMemory. return target_process.VMManager().UnmapRange(address, size); -- cgit v1.2.3 From 108be41316cc58c191f525e816d2a33404ab41a0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 29 Mar 2019 18:08:14 -0400 Subject: kernel/shared_memory: Remove unused core/memory.h include Nothing from this header is used, so we can remove this include, getting rid of a dependency on it. --- src/core/hle/kernel/shared_memory.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core/hle/kernel/shared_memory.cpp') diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 273e6a25e..f15c5ee36 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -9,7 +9,6 @@ #include "core/hle/kernel/errors.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/shared_memory.h" -#include "core/memory.h" namespace Kernel { -- cgit v1.2.3