Bug 230153 - getrusage(2): getrusage fails to return EFAULT in 32-bit emulation
Summary: getrusage(2): getrusage fails to return EFAULT in 32-bit emulation
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-29 17:01 UTC by Alan Somers
Modified: 2018-10-01 18:02 UTC (History)
0 users

See Also:
asomers: mfc-stable11+
asomers: mfc-stable10+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2018-07-29 17:01:05 UTC
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.
Comment 1 commit-hook freebsd_committer freebsd_triage 2018-07-29 18:22:35 UTC
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
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-07-29 19:20:29 UTC
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
Comment 3 commit-hook freebsd_committer freebsd_triage 2018-10-01 15:50:10 UTC
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
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-10-01 15:50:12 UTC
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
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-10-01 16:23:48 UTC
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
Comment 6 commit-hook freebsd_committer freebsd_triage 2018-10-01 16:23:50 UTC
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