0006-Add-support-for-io_pgetevents_time64-syscall.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 5b5e2985f355c8e99c196d9ce5d02c15bebadfbc Mon Sep 17 00:00:00 2001
  2. From: Alistair Francis <alistair.francis@wdc.com>
  3. Date: Thu, 29 Aug 2019 13:56:21 -0700
  4. Subject: [PATCH] Add support for io_pgetevents_time64 syscall
  5. 32-bit architectures that are y2038 safe don't include syscalls that use
  6. 32-bit time_t. Instead these architectures have suffixed syscalls that
  7. always use a 64-bit time_t. In the case of the io_getevents syscall the
  8. syscall has been replaced with the io_pgetevents_time64 syscall instead.
  9. This patch changes the io_getevents() function to use the correct
  10. syscall based on the avaliable syscalls and the time_t size. We will
  11. only use the new 64-bit time_t syscall if the architecture is using a
  12. 64-bit time_t. This is to avoid having to deal with 32/64-bit
  13. conversions and relying on a 64-bit timespec struct on 32-bit time_t
  14. platforms. As of Linux 5.3 there are no 32-bit time_t architectures
  15. without __NR_io_getevents. In the future if a 32-bit time_t architecture
  16. wants to use the 64-bit syscalls we can handle the conversion.
  17. This fixes build failures on 32-bit RISC-V.
  18. Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  19. Reviewed-by: Richard Levitte <levitte@openssl.org>
  20. Reviewed-by: Paul Dale <paul.dale@oracle.com>
  21. (Merged from https://github.com/openssl/openssl/pull/9819)
  22. [yann.morin.1998@free.fr: backport from upstream 3.0 branch]
  23. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
  24. ---
  25. engines/e_afalg.c | 16 ++++++++++++++++
  26. 1 file changed, 16 insertions(+)
  27. diff --git a/engines/e_afalg.c b/engines/e_afalg.c
  28. index dacbe358cb..99516cb1bb 100644
  29. --- a/engines/e_afalg.c
  30. +++ b/engines/e_afalg.c
  31. @@ -125,7 +125,23 @@ static ossl_inline int io_getevents(aio_context_t ctx, long min, long max,
  32. struct io_event *events,
  33. struct timespec *timeout)
  34. {
  35. +#if defined(__NR_io_getevents)
  36. return syscall(__NR_io_getevents, ctx, min, max, events, timeout);
  37. +#elif defined(__NR_io_pgetevents_time64)
  38. + /* Let's only support the 64 suffix syscalls for 64-bit time_t.
  39. + * This simplifies the code for us as we don't need to use a 64-bit
  40. + * version of timespec with a 32-bit time_t and handle converting
  41. + * between 64-bit and 32-bit times and check for overflows.
  42. + */
  43. + if (sizeof(timeout->tv_sec) == 8)
  44. + return syscall(__NR_io_pgetevents_time64, ctx, min, max, events, timeout, NULL);
  45. + else {
  46. + errno = ENOSYS;
  47. + return -1;
  48. + }
  49. +#else
  50. +# error "We require either the io_getevents syscall or __NR_io_pgetevents_time64."
  51. +#endif
  52. }
  53. static void afalg_waitfd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
  54. --
  55. 2.25.1