mbox series

[v2,0/6] Always use long time_t for certain syscalls

Message ID 20200210174325.6566-1-alistair.francis@wdc.com
Headers show
Series Always use long time_t for certain syscalls | expand

Message

Alistair Francis Feb. 10, 2020, 5:43 p.m. UTC
On y2038 safe 32-bit systems the Linux kernel expects itimerval
and rusage to use a 32-bit time_t, even though the other time_t's
are 64-bit.

This series converts getitimer, setitimer, getrusage and wait4 to be
both y2038 safe and always pass a long time_t. On 32 and 64-bit systems
we will pass a long time to the kernel (no matter the time_t size). This is
no change for 64-bit architectures or 32-bit architectures with a 32-bit time_t.

This follows the standard y2038 conversion so that we don't break
backwards compatibility but we expose a 64-bit version for y2038 safe
architectrures (like RV32).

Alistair Francis (6):
  sysv/linux: Rename alpha functions to be alpha specific
  time: Add a timeval with a long tv_sec and tv_usec
  time: Add a __itimerval64 struct
  linux: Use long time_t __getitimer/__setitimer
  resource: Add a __rusage64 struct
  linux: Use long time_t for wait4/getrusage

 include/sys/resource.h                        | 120 ++++++++++++++++++
 include/time.h                                |  64 ++++++++++
 .../{tv32-compat.h => alpha-tv32-compat.h}    |  16 +--
 sysdeps/unix/sysv/linux/alpha/osf_adjtime.c   |  10 +-
 sysdeps/unix/sysv/linux/alpha/osf_getitimer.c |   6 +-
 sysdeps/unix/sysv/linux/alpha/osf_getrusage.c |   4 +-
 .../unix/sysv/linux/alpha/osf_gettimeofday.c  |   4 +-
 sysdeps/unix/sysv/linux/alpha/osf_setitimer.c |  10 +-
 .../unix/sysv/linux/alpha/osf_settimeofday.c  |   4 +-
 sysdeps/unix/sysv/linux/alpha/osf_utimes.c    |   6 +-
 sysdeps/unix/sysv/linux/alpha/osf_wait4.c     |   4 +-
 sysdeps/unix/sysv/linux/getitimer.c           |  54 ++++++++
 sysdeps/unix/sysv/linux/getrusage.c           |  53 ++++++++
 sysdeps/unix/sysv/linux/setitimer.c           |  89 +++++++++++++
 sysdeps/unix/sysv/linux/tv32-compat.h         |  82 ++++++++++++
 sysdeps/unix/sysv/linux/wait4.c               |  40 +++++-
 16 files changed, 530 insertions(+), 36 deletions(-)
 rename sysdeps/unix/sysv/linux/alpha/{tv32-compat.h => alpha-tv32-compat.h} (88%)
 create mode 100644 sysdeps/unix/sysv/linux/getitimer.c
 create mode 100644 sysdeps/unix/sysv/linux/getrusage.c
 create mode 100644 sysdeps/unix/sysv/linux/setitimer.c
 create mode 100644 sysdeps/unix/sysv/linux/tv32-compat.h

Comments

Alistair Francis Feb. 10, 2020, 5:58 p.m. UTC | #1
On Mon, Feb 10, 2020 at 9:50 AM Alistair Francis
<alistair.francis@wdc.com> wrote:
>
> On y2038 safe 32-bit systems the Linux kernel expects itimerval
> and rusage to use a 32-bit time_t, even though the other time_t's
> are 64-bit.
>
> This series converts getitimer, setitimer, getrusage and wait4 to be
> both y2038 safe and always pass a long time_t. On 32 and 64-bit systems
> we will pass a long time to the kernel (no matter the time_t size). This is
> no change for 64-bit architectures or 32-bit architectures with a 32-bit time_t.
>
> This follows the standard y2038 conversion so that we don't break
> backwards compatibility but we expose a 64-bit version for y2038 safe
> architectrures (like RV32).

This series was tested by running:
  ./scripts/build-many-glibcs.py ... compilers
  ./scripts/build-many-glibcs.py ... glibcs
on my x86_64 machine.

I also ran make check on RV32 and I only see a total of 10 test failures.

>
> Alistair Francis (6):
>   sysv/linux: Rename alpha functions to be alpha specific
>   time: Add a timeval with a long tv_sec and tv_usec
>   time: Add a __itimerval64 struct
>   linux: Use long time_t __getitimer/__setitimer
>   resource: Add a __rusage64 struct
>   linux: Use long time_t for wait4/getrusage
>
>  include/sys/resource.h                        | 120 ++++++++++++++++++
>  include/time.h                                |  64 ++++++++++
>  .../{tv32-compat.h => alpha-tv32-compat.h}    |  16 +--
>  sysdeps/unix/sysv/linux/alpha/osf_adjtime.c   |  10 +-
>  sysdeps/unix/sysv/linux/alpha/osf_getitimer.c |   6 +-
>  sysdeps/unix/sysv/linux/alpha/osf_getrusage.c |   4 +-
>  .../unix/sysv/linux/alpha/osf_gettimeofday.c  |   4 +-
>  sysdeps/unix/sysv/linux/alpha/osf_setitimer.c |  10 +-
>  .../unix/sysv/linux/alpha/osf_settimeofday.c  |   4 +-
>  sysdeps/unix/sysv/linux/alpha/osf_utimes.c    |   6 +-
>  sysdeps/unix/sysv/linux/alpha/osf_wait4.c     |   4 +-
>  sysdeps/unix/sysv/linux/getitimer.c           |  54 ++++++++
>  sysdeps/unix/sysv/linux/getrusage.c           |  53 ++++++++
>  sysdeps/unix/sysv/linux/setitimer.c           |  89 +++++++++++++
>  sysdeps/unix/sysv/linux/tv32-compat.h         |  82 ++++++++++++
>  sysdeps/unix/sysv/linux/wait4.c               |  40 +++++-
>  16 files changed, 530 insertions(+), 36 deletions(-)
>  rename sysdeps/unix/sysv/linux/alpha/{tv32-compat.h => alpha-tv32-compat.h} (88%)
>  create mode 100644 sysdeps/unix/sysv/linux/getitimer.c
>  create mode 100644 sysdeps/unix/sysv/linux/getrusage.c
>  create mode 100644 sysdeps/unix/sysv/linux/setitimer.c
>  create mode 100644 sysdeps/unix/sysv/linux/tv32-compat.h
>
> --
> 2.25.0
>