From: John Hodge Date: Tue, 24 Aug 2010 02:24:47 +0000 (+0800) Subject: Trying to reduce the ability for a fork bomb to fault the kernel X-Git-Tag: rel0.06~45 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=2a05bcd81312a2885f824dac79e82c01a6e60c6c;p=tpg%2Facess2.git Trying to reduce the ability for a fork bomb to fault the kernel - Darn, there's still a requirement for proc.asm to know the structure of tThread --- diff --git a/Kernel/arch/x86/mm_virt.c b/Kernel/arch/x86/mm_virt.c index dce47828..fdc19b14 100644 --- a/Kernel/arch/x86/mm_virt.c +++ b/Kernel/arch/x86/mm_virt.c @@ -653,14 +653,15 @@ tPAddr MM_Clone(void) */ tVAddr MM_NewKStack(void) { - tVAddr base = KERNEL_STACKS; + tVAddr base; Uint i; - for(;baseMemState.CR3 = cur->MemState.CR3; + #endif // Create new KStack newThread->KernelStack = MM_NewKStack(); @@ -606,7 +610,7 @@ int Proc_Clone(Uint *Err, Uint Flags) __asm__ __volatile__ ("mov %0, %%db0" : : "r" (newThread) ); #if USE_MP // ACK the interrupt - if(GetCPUNum()) + if( GetCPUNum() ) gpMP_LocalAPIC->EOI.Val = 0; else #endif diff --git a/Kernel/threads.c b/Kernel/threads.c index 5d8e4013..610f7b5d 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -928,7 +928,7 @@ void Mutex_Release(tMutex *Mutex) // Wake new owner Mutex->Owner->Status = THREAD_STAT_ACTIVE; Threads_AddActive(Mutex->Owner); - Log("Mutex %p Woke %p", Mutex, Mutex->Owner); + //Log("Mutex %p Woke %p", Mutex, Mutex->Owner); } else { Mutex->Owner = NULL; @@ -947,3 +947,6 @@ int Mutex_IsLocked(tMutex *Mutex) // === EXPORTS === EXPORT(Threads_GetUID); +EXPORT(Mutex_Acquire); +EXPORT(Mutex_Release); +EXPORT(Mutex_IsLocked); diff --git a/Usermode/Applications/bomb_src/main.c b/Usermode/Applications/bomb_src/main.c index f9ecfa0b..d7923224 100644 --- a/Usermode/Applications/bomb_src/main.c +++ b/Usermode/Applications/bomb_src/main.c @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) return 1; } - switch( argv[i][0] ) + switch( argv[i][1] ) { case 'f': gbForkBomb = 1; diff --git a/Usermode/Applications/init_src/Makefile b/Usermode/Applications/init_src/Makefile index 641503d2..94aebd11 100644 --- a/Usermode/Applications/init_src/Makefile +++ b/Usermode/Applications/init_src/Makefile @@ -4,7 +4,8 @@ CPPFLAGS += CFLAGS += -Wall -Werror -O3 -LDFLAGS += -lspiderscript +LDFLAGS += +# -lspiderscript BIN = ../init OBJ = main.o diff --git a/Usermode/Applications/init_src/main.c b/Usermode/Applications/init_src/main.c index eb2e9318..a88af9f9 100644 --- a/Usermode/Applications/init_src/main.c +++ b/Usermode/Applications/init_src/main.c @@ -4,7 +4,7 @@ #include #include #include -#include +//#include //#include "common.h" // === CONSTANTS === @@ -17,9 +17,12 @@ #define ARRAY_SIZE(x) ((sizeof(x))/(sizeof((x)[0]))) // === PROTOTYPES === +/* tSpiderVariable *Script_System_IO_Open(tSpiderScript *, int, tSpiderVariable *); +*/ // === GLOBALS === +/* tSpiderFunction gaScriptNS_IO_Fcns[] = { {"Open", Script_System_IO_Open} }; @@ -45,6 +48,7 @@ tSpiderVariant gScriptVariant = { "init", 0, ARRAY_SIZE(gaScriptNamespaces), gaScriptNamespaces }; +*/ // === CODE === /** @@ -88,16 +92,20 @@ int main(int argc, char *argv[]) */ void ExecuteScript(const char *Filename) { + /* tSpiderScript *script; script = SpiderScript_ParseFile(&gScriptVariant, Filename); SpiderScript_ExecuteMethod(script, ""); SpiderScript_Free(script); + */ } /** * \brief Open a file */ +/* tSpiderVariable *Script_System_IO_Open(tSpiderScript *Script, int NArgs, tSpiderVariable *Args) { return NULL; } +*/ diff --git a/Usermode/Libraries/libc.so_src/string.c b/Usermode/Libraries/libc.so_src/string.c index 4e8dfe2e..eaddd181 100644 --- a/Usermode/Libraries/libc.so_src/string.c +++ b/Usermode/Libraries/libc.so_src/string.c @@ -88,18 +88,6 @@ EXPORT int strlen(const char *str) return retval; } -/** - * \fn EXPORT int strncmp(const char *s1, const char *s2, size_t len) - * \brief Compare two strings with a limit - */ -EXPORT int strncmp(const char *s1, const char *s2, size_t len) -{ - while(--len && *s1 == *s2 && *s1 != '\0' && *s2 != '\0') { - s1++; s2++; - } - return (int)*s1 - (int)*s2; -} - /** * \fn EXPORT char *strdup(const char *str) * \brief Duplicate a string using heap memory