From a321a83609de8f1ff512f94901698e83d64121ba Mon Sep 17 00:00:00 2001 From: CleverMouse Date: Fri, 1 Mar 2013 10:27:19 +0000 Subject: [PATCH] Protect thread from external terminate while running any syscall except 5,10,23. Now 18.2/18.12 are really safe through kernel-colored glasses (however, you still should not use them except for really critical cases), although the protection is sometimes quite excessive. git-svn-id: svn://kolibrios.org@3303 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/syscall.inc | 20 +++++++++++++++----- kernel/trunk/gui/event.inc | 2 ++ kernel/trunk/kernel.asm | 9 +++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index 650406be40..e036d2fe43 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -38,9 +38,13 @@ sysenter_entry: pushad cld - movzx eax, al + call protect_from_terminate + + movzx eax, byte [esp+28] + mov edx, dword [esp+24] call dword [servetable2 + eax * 4] + call unprotect_from_terminate popad ;------------------ xchg ecx, [ss:esp] ; в вершин стека - app ecx, ecx - app esp + 4 @@ -62,8 +66,11 @@ align 16 i40: pushad cld - movzx eax, al + call protect_from_terminate + movzx eax, byte [esp+28] + mov edx, dword [esp+24] call dword [servetable2 + eax * 4] + call unprotect_from_terminate popad iretd @@ -85,10 +92,13 @@ syscall_entry: ;------------------ pushad cld + call protect_from_terminate - movzx eax, al + movzx eax, byte [esp+28] + mov edx, dword [esp+24] call dword [servetable2 + eax * 4] + call unprotect_from_terminate popad ;------------------ mov ecx, [ss:esp+4] @@ -125,7 +135,7 @@ iglobal dd sys_getkey ; 2-GetKey dd sys_clock ; 3-GetTime dd syscall_writetext ; 4-WriteText - dd delay_hs ; 5-DelayHs + dd delay_hs_unprotected ; 5-DelayHs dd syscall_openramdiskfile ; 6-OpenRamdiskFile dd syscall_putimage ; 7-PutImage dd syscall_button ; 8-DefineButton @@ -190,7 +200,7 @@ iglobal dd syscall_move_window ; 67-Window move or resize dd f68 ; 68-Some internal services dd sys_debug_services ; 69-Debug - dd file_system_lfn_protected; 70-Common file system interface, version 2 + dd file_system_lfn ; 70-Common file system interface, version 2 dd syscall_window_settings ; 71-Window settings dd sys_sendwindowmsg ; 72-Send window message dd blit_32 ; 73-blitter; diff --git a/kernel/trunk/gui/event.inc b/kernel/trunk/gui/event.inc index 6b40ec732b..4583124980 100644 --- a/kernel/trunk/gui/event.inc +++ b/kernel/trunk/gui/event.inc @@ -467,9 +467,11 @@ sys_waitforevent: ;; f10 ;-------------------------------------- align 4 sys_wait_event_timeout: ;; f23 + call unprotect_from_terminate mov edx, get_event_for_app; wait_test call Wait_events_ex ; ebx - timeout mov [esp+32], eax + call protect_from_terminate ret ;----------------------------------------------------------------------------- align 4 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 7e947e945f..919c832c35 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -3735,6 +3735,15 @@ set_app_param: mov [esp+32], eax ; return old mask value ret ;----------------------------------------------------------------------------- + +; this is for syscall +proc delay_hs_unprotected + call unprotect_from_terminate + call delay_hs + call protect_from_terminate + ret +endp + align 4 delay_hs: ; delay in 1/100 secs ; ebx = delay time