Open
Description
this simple user program could panic the kernel
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <syscall.h>
int main(int argc, char *argv[])
{
int res = syscall(SYS_clock_gettime, CLOCK_MONOTONIC, 0);
printf("ret %d\n", res);
return 0;
}
log:
[Print] [1/45400c0000|0] unhandle EXCEPTION: page_fault FAULT
This is because the syscall handler SysClockGetTime
(among many others) copies to user buffer without sanity check.
let clock = GetClock(task, clockID)?;
let ts = clock.Now().Timespec();
task.CopyOutObj(&ts, addr)?;
In this case I'm passing a null ptr. This causes a pagefault in kernel.
Actually, any illegal user pointer will cause a kernel panic. Because the Memcpy
is called upon the user pointer in kernel space.
Metadata
Metadata
Assignees
Labels
No labels