From 906a16d3a2a14b2eecaee4748393c653157d212b Mon Sep 17 00:00:00 2001 From: Doczom Date: Tue, 26 Apr 2022 13:09:12 +0000 Subject: [PATCH] fixed kernel malfunction when loading a program with mem_size > os_base . git-svn-id: svn://kolibrios.org@9794 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/taskman.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index f38ed323f5..59af3b5c8a 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -234,6 +234,17 @@ test_app_header: mov [ebx + APP_HDR.eip], ecx mov edx, [APP_HEADER_00.mem_size] mov [ebx + APP_HDR._emem], edx + + cmp edx, [APP_HEADER_00.i_end] + jb .fail + + cmp edx, OS_BASE ;check memory + jae .fail + mov ecx, [pg_data.pages_free] + shl ecx, 12 ; ecx * 4kb + cmp edx, ecx + jae .fail + shr edx, 1 sub edx, 0x10 mov [ebx + APP_HDR.esp], edx @@ -261,6 +272,12 @@ test_app_header: cmp edx, [APP_HEADER_01.i_end] jb .fail ; \end{diamond}[20.08.2006] + cmp edx, OS_BASE ;check memory + jae .fail + mov ecx, [pg_data.pages_free] + shl ecx, 12 ; ecx * 4kb + cmp edx, ecx + jae .fail mov [ebx + APP_HDR._emem], edx mov ecx, [APP_HEADER_01.stack_top]