The getrusage man page says that it should return EFAULT if the rusage argument is not in the process's address space. This is indeed what happens on amd64 with 64-bit binaries. However, in 32-bit emulation, getrusage returns 0 instead. The bug appears to have been introduced in r100384, which first added 32-bit emulation.
A commit references this bug: Author: asomers Date: Sun Jul 29 18:22:26 UTC 2018 New revision: 336871 URL: https://svnweb.freebsd.org/changeset/base/336871 Log: 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 Changes: head/sys/compat/freebsd32/freebsd32_misc.c
A commit references this bug: Author: asomers Date: Sun Jul 29 19:20:13 UTC 2018 New revision: 336874 URL: https://svnweb.freebsd.org/changeset/base/336874 Log: freebsd32_getrusage(2): skip freebsd32_rusage_out on error PR: 230153 Reported by: kib MFC after: 2 weeks X-MFC-With: 336871 Differential Revision: https://reviews.freebsd.org/D16500 Changes: head/sys/compat/freebsd32/freebsd32_misc.c
A commit references this bug: Author: asomers Date: Mon Oct 1 15:49:44 UTC 2018 New revision: 339052 URL: https://svnweb.freebsd.org/changeset/base/339052 Log: MFC r336871, r336874 r336871: 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 Differential Revision: https://reviews.freebsd.org/D16500 r336874: freebsd32_getrusage(2): skip freebsd32_rusage_out on error PR: 230153 Reported by: kib X-MFC-With: 336871 Differential Revision: https://reviews.freebsd.org/D16500 Changes: _U stable/11/ stable/11/sys/compat/freebsd32/freebsd32_misc.c
A commit references this bug: Author: asomers Date: Mon Oct 1 16:23:00 UTC 2018 New revision: 339065 URL: https://svnweb.freebsd.org/changeset/base/339065 Log: MFC r336871, r336874 r336871: 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 Differential Revision: https://reviews.freebsd.org/D16500 r336874: freebsd32_getrusage(2): skip freebsd32_rusage_out on error PR: 230153 Reported by: kib X-MFC-With: 336871 Differential Revision: https://reviews.freebsd.org/D16500 Changes: _U stable/10/ stable/10/sys/compat/freebsd32/freebsd32_misc.c