waitid(): Avoid unbalanced user_access_end() on access_ok() error

As pointed out by Linus and David, the earlier waitid() fix resulted in
a (currently harmless) unbalanced user_access_end() call.  This fixes it
to just directly return EFAULT on access_ok() failure.

Fixes: 96ca579a1e ("waitid(): Add missing access_ok() checks")
Acked-by: David Daney <david.daney@cavium.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Kees Cook 2017-10-20 07:36:05 -07:00 committed by Linus Torvalds
parent 9a27ded219
commit 1c9fec470b
1 changed files with 2 additions and 2 deletions

View File

@ -1611,7 +1611,7 @@ SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
return err; return err;
if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop))) if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop)))
goto Efault; return -EFAULT;
user_access_begin(); user_access_begin();
unsafe_put_user(signo, &infop->si_signo, Efault); unsafe_put_user(signo, &infop->si_signo, Efault);
@ -1739,7 +1739,7 @@ COMPAT_SYSCALL_DEFINE5(waitid,
return err; return err;
if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop))) if (!access_ok(VERIFY_WRITE, infop, sizeof(*infop)))
goto Efault; return -EFAULT;
user_access_begin(); user_access_begin();
unsafe_put_user(signo, &infop->si_signo, Efault); unsafe_put_user(signo, &infop->si_signo, Efault);