From b8a5155d17d141bcb2d5c55a9589077cdf53ef17 Mon Sep 17 00:00:00 2001 From: ParantezTech <12572227+par274@users.noreply.github.com> Date: Tue, 6 Oct 2026 13:44:48 +0300 Subject: [PATCH] [Kernel] Validate pthread stack bounds before reporting them Co-authored-by: Sekai <140012992+igettingit@users.noreply.github.com> --- .../Kernel/KernelPthreadExtendedCompatExports.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SharpEmu.Libs/Kernel/KernelPthreadExtendedCompatExports.cs b/src/SharpEmu.Libs/Kernel/KernelPthreadExtendedCompatExports.cs index 16b86ca..08a64ae 100644 --- a/src/SharpEmu.Libs/Kernel/KernelPthreadExtendedCompatExports.cs +++ b/src/SharpEmu.Libs/Kernel/KernelPthreadExtendedCompatExports.cs @@ -574,6 +574,11 @@ public static class KernelPthreadExtendedCompatExports return (int)OrbisGen2Result.ORBIS_GEN2_OK; } + private static bool IsValidStackBounds(ulong stackAddress, ulong stackSize) => + stackAddress != 0 && + stackSize != 0 && + stackAddress <= ulong.MaxValue - stackSize; + private static bool TryInferNativeGuestStack(ulong stackPointer, out ulong stackAddress) { stackAddress = 0;