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
This commit is contained in:
Alan Somers 2018-07-29 18:22:26 +00:00
parent 6dfd050075
commit 5cf35a100c

View File

@ -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);
}