Skip to content

Commit 1759558

Browse files
pm215Michael Tokarev
authored andcommitted
linux-user: Check for EFAULT failure in nanosleep
target_to_host_timespec() returns an error if the memory the guest passed us isn't actually readable. We check for this everywhere except the callsite in the TARGET_NR_nanosleep case, so this mistake was caught by a Coverity heuristic. Add the missing error checks to the calls that convert between the host and target timespec structs. Coverity: CID 1507104 Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Message-ID: <[email protected]> (cherry picked from commit c4828cb8502d0b2adc39b9cde93df7d2886df897) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 1714828 commit 1759558

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

linux-user/syscall.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11639,10 +11639,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
1163911639
case TARGET_NR_nanosleep:
1164011640
{
1164111641
struct timespec req, rem;
11642-
target_to_host_timespec(&req, arg1);
11642+
if (target_to_host_timespec(&req, arg1)) {
11643+
return -TARGET_EFAULT;
11644+
}
1164311645
ret = get_errno(safe_nanosleep(&req, &rem));
1164411646
if (is_error(ret) && arg2) {
11645-
host_to_target_timespec(arg2, &rem);
11647+
if (host_to_target_timespec(arg2, &rem)) {
11648+
return -TARGET_EFAULT;
11649+
}
1164611650
}
1164711651
}
1164811652
return ret;

0 commit comments

Comments
 (0)