From 201d20a7fdea8a45a48f6e2d2a34f07264cf4630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Jun 2025 10:53:51 +0200 Subject: [PATCH] Merge pull request #20513 from hrydgard/revert-bad-export-check ELF loader: Revert bad export check --- Core/HLE/sceKernelModule.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 577e0bb913..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: @@ -1461,13 +1466,8 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load var.moduleName[KERNELOBJECT_MAX_NAME_LENGTH] = '\0'; for (u32 j = 0; j < variableCount; j++) { - u32 nid = residentPtr[ent->fcount + j]; - u32 exportAddr = exportPtr[ent->fcount + j]; - - if (exportAddr & 3) { - ERROR_LOG(Log::Loader, "Bad export address %08x", exportAddr); - continue; - } + const u32 nid = residentPtr[ent->fcount + j]; + const u32 exportAddr = exportPtr[ent->fcount + j]; // These can be unaligned (small varables or char arrays). int size; switch (nid) {