From 60d47eaeff8f82d617deca85df4aefba34bd4704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 6 Apr 2017 15:18:23 +0200 Subject: [PATCH] IOS/ES: Return IPC_EINVAL for unknown ioctlvs Instead of allowing unknown ioctlvs and faking success for both unknown and unimplemented ioctlvs, which can possibly result in nasty, hard to debug bugs (if the emulated software behaves unexpectedly), we should reject unknown ioctlvs and log known, but unimplemented ioctlvs. --- Source/Core/Core/IOS/ES/ES.cpp | 27 ++++++++++++++++++++++----- Source/Core/Core/IOS/ES/ES.h | 15 +++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index eaad202a9c..068a441e58 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -409,12 +409,29 @@ IPCCommandResult ES::IOCtlV(const IOCtlVRequest& request) return Sign(request); case IOCTL_ES_GETBOOT2VERSION: return GetBoot2Version(request); - default: - request.DumpUnknown(GetDeviceName(), LogTypes::IOS_ES); - break; - } - return GetDefaultReply(IPC_SUCCESS); + case IOCTL_ES_VERIFYSIGN: + case IOCTL_ES_DELETESHAREDCONTENT: + case IOCTL_ES_UNKNOWN_39: + case IOCTL_ES_UNKNOWN_3A: + case IOCTL_ES_UNKNOWN_3B: + case IOCTL_ES_UNKNOWN_3C: + case IOCTL_ES_UNKNOWN_3D: + case IOCTL_ES_UNKNOWN_3E: + case IOCTL_ES_UNKNOWN_3F: + case IOCTL_ES_UNKNOWN_40: + case IOCTL_ES_UNKNOWN_41: + case IOCTL_ES_UNKNOWN_42: + case IOCTL_ES_UNKNOWN_43: + case IOCTL_ES_UNKNOWN_44: + PanicAlert("IOS-ES: Unimplemented ioctlv 0x%x (%zu in vectors, %zu io vectors)", + request.request, request.in_vectors.size(), request.io_vectors.size()); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_ES, LogTypes::LERROR); + return GetDefaultReply(IPC_EINVAL); + + default: + return GetDefaultReply(IPC_EINVAL); + } } IPCCommandResult ES::GetConsumption(const IOCtlVRequest& request) diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index 7b424ec654..e8a9e69fba 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -112,7 +112,7 @@ private: IOCTL_ES_GETBOOT2VERSION = 0x2E, IOCTL_ES_ADDTITLECANCEL = 0x2F, IOCTL_ES_SIGN = 0x30, - // IOCTL_ES_VERIFYSIGN = 0x31, + IOCTL_ES_VERIFYSIGN = 0x31, IOCTL_ES_GETSTOREDCONTENTCNT = 0x32, IOCTL_ES_GETSTOREDCONTENTS = 0x33, IOCTL_ES_GETSTOREDTMDSIZE = 0x34, @@ -120,7 +120,18 @@ private: IOCTL_ES_GETSHAREDCONTENTCNT = 0x36, IOCTL_ES_GETSHAREDCONTENTS = 0x37, IOCTL_ES_DELETESHAREDCONTENT = 0x38, - // + IOCTL_ES_UNKNOWN_39 = 0x39, + IOCTL_ES_UNKNOWN_3A = 0x3A, + IOCTL_ES_UNKNOWN_3B = 0x3B, + IOCTL_ES_UNKNOWN_3C = 0x3C, + IOCTL_ES_UNKNOWN_3D = 0x3D, + IOCTL_ES_UNKNOWN_3E = 0x3E, + IOCTL_ES_UNKNOWN_3F = 0x3F, + IOCTL_ES_UNKNOWN_40 = 0x40, + IOCTL_ES_UNKNOWN_41 = 0x41, + IOCTL_ES_UNKNOWN_42 = 0x42, + IOCTL_ES_UNKNOWN_43 = 0x43, + IOCTL_ES_UNKNOWN_44 = 0x44, IOCTL_ES_CHECKKOREAREGION = 0x45, };