From 5cf35a100c33b082a8b951288f5ce2625b2c9f5b Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 29 Jul 2018 18:22:26 +0000 Subject: [PATCH] getrusage(2): fix return value under 32-bit emulation According to the man page, getrusage(2) should return EFAULT if the rusage argument lies outside of the process's address space. But due to an oversight in r100384, that's never been the case during 32-bit emulation. Fix it. PR: 230153 Reported by: tests(7) Reviewed by: cem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16500 --- sys/compat/freebsd32/freebsd32_misc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 2cfc985a3b1c..77153b674008 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -883,12 +883,9 @@ freebsd32_getrusage(struct thread *td, struct freebsd32_getrusage_args *uap) int error; error = kern_getrusage(td, uap->who, &s); - if (error) - return (error); - if (uap->rusage != NULL) { - freebsd32_rusage_out(&s, &s32); + freebsd32_rusage_out(&s, &s32); + if (error == 0) error = copyout(&s32, uap->rusage, sizeof(s32)); - } return (error); }