From e3ad5951e3eb5572c8db4fa8022dff94bdc7055a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Jun 2025 10:34:05 +0200 Subject: [PATCH] Add alignment check for function exports (but don't reject, just log) --- Core/HLE/sceKernelModule.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index ec8576f669..16ed48db12 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1396,7 +1396,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load continue; } - u32 variableCount = ent->size <= 4 ? ent->vcount : std::max((u32)ent->vcount , (u32)ent->vcountNew); + const u32 variableCount = ent->size <= 4 ? ent->vcount : std::max((u32)ent->vcount , (u32)ent->vcountNew); const char *name; if (Memory::IsValidAddress(ent->name)) { name = Memory::GetCharPointer(ent->name); @@ -1427,8 +1427,13 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load func.moduleName[KERNELOBJECT_MAX_NAME_LENGTH] = '\0'; for (u32 j = 0; j < ent->fcount; j++) { - u32 nid = residentPtr[j]; - u32 exportAddr = exportPtr[j]; + const u32 nid = residentPtr[j]; + const u32 exportAddr = exportPtr[j]; + + if (exportAddr & 3) { + ERROR_LOG(Log::Loader, "Bad fn export address %08x", exportAddr); + // We should probably reject it, but risky. + } switch (nid) { case NID_MODULE_START: