From e240e260d99b9fac91f11905e065b9390877b565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 8 Jun 2017 00:30:47 +0200 Subject: [PATCH] IOSC: Fix the SetOwnership implementation --- Source/Core/Core/IOS/IOSC.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/IOS/IOSC.cpp b/Source/Core/Core/IOS/IOSC.cpp index 129d0c485c..438abe3f30 100644 --- a/Source/Core/Core/IOS/IOSC.cpp +++ b/Source/Core/Core/IOS/IOSC.cpp @@ -166,7 +166,11 @@ ReturnCode IOSC::SetOwnership(Handle handle, u32 new_owner, u32 pid) if (!HasOwnership(handle, pid)) return IOSC_EACCES; - m_key_entries[handle].owner_mask = new_owner; + const u32 mask_with_current_pid = 1 << pid; + const u32 mask = m_key_entries[handle].owner_mask | mask_with_current_pid; + if (mask != mask_with_current_pid) + return IOSC_EACCES; + m_key_entries[handle].owner_mask = (new_owner & ~7) | mask; return IPC_SUCCESS; }