From bd5708286d54332b38f075cd2b7070850fde1405 Mon Sep 17 00:00:00 2001 From: NAKAMURA Gou Date: Wed, 16 Sep 2015 12:39:36 +0900 Subject: [PATCH] make sys_gettimeofday() use copy_to_user() --- kernel/syscall.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/syscall.c b/kernel/syscall.c index 8ab21834..d4a69ec2 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -4977,6 +4977,8 @@ SYSCALL_DECLARE(gettimeofday) struct timeval *tv = (struct timeval *)ihk_mc_syscall_arg0(ctx); struct syscall_request request IHK_DMA_ALIGN; struct timezone *tz = (struct timezone *)ihk_mc_syscall_arg1(ctx); + struct timeval atv; + int error; if (!tv && !tz) { /* nothing to do */ @@ -4987,17 +4989,13 @@ SYSCALL_DECLARE(gettimeofday) if (!tz && gettime_local_support) { update_cpu_local_time(); - /* Check validity of argument */ - if (!lookup_process_memory_range(cpu_local_var(current)->vm, - (unsigned long)tv, (unsigned long)tv + sizeof(*tv))) { - return -EFAULT; - } + atv.tv_sec = cpu_local_var(tv_sec); + atv.tv_usec = cpu_local_var(tv_nsec) / 1000; - tv->tv_sec = cpu_local_var(tv_sec); - tv->tv_usec = cpu_local_var(tv_nsec) / 1000; + error = copy_to_user(tv, &atv, sizeof(atv)); - dkprintf("gettimeofday(): \n"); - return 0; + dkprintf("gettimeofday(): %d\n", error); + return error; } /* Otherwise offload */