Fix insecure user-space pointer dereferences in sys_tfork.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-01-19 18:22:53 +01:00
parent 08c11ee45c
commit 8f8f09ac82
1 changed files with 6 additions and 2 deletions

View File

@ -930,8 +930,12 @@ cleanup_done:
return result; return result;
} }
static pid_t sys_tfork(int flags, tforkregs_t* regs) static pid_t sys_tfork(int flags, tforkregs_t* user_regs)
{ {
tforkregs_t regs;
if ( !CopyFromUser(&regs, user_regs, sizeof(regs)) )
return -1;
if ( Signal::IsPending() ) if ( Signal::IsPending() )
return errno = EINTR, -1; return errno = EINTR, -1;
@ -940,7 +944,7 @@ static pid_t sys_tfork(int flags, tforkregs_t* regs)
return errno = ENOSYS, -1; return errno = ENOSYS, -1;
CPU::InterruptRegisters cpuregs; CPU::InterruptRegisters cpuregs;
InitializeThreadRegisters(&cpuregs, regs); InitializeThreadRegisters(&cpuregs, &regs);
// TODO: Is it a hack to create a new kernel stack here? // TODO: Is it a hack to create a new kernel stack here?
Thread* curthread = CurrentThread(); Thread* curthread = CurrentThread();