0001-add-process_vm_-read-write-v-syscall-wrapper-from-gl.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. From 3d975fa52b82e390ecbb0252739ee3fae64266c2 Mon Sep 17 00:00:00 2001
  2. From: Waldemar Brodkorb <wbx@openadk.org>
  3. Date: Wed, 14 Aug 2024 17:28:19 +0200
  4. Subject: [PATCH 1/2] add process_vm_{read,write}v syscall wrapper from glibc
  5. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
  6. ---
  7. include/sys/uio.h | 19 +++++++++++
  8. libc/sysdeps/linux/common/Makefile.in | 2 ++
  9. libc/sysdeps/linux/common/process_vm_readv.c | 32 +++++++++++++++++++
  10. libc/sysdeps/linux/common/process_vm_writev.c | 32 +++++++++++++++++++
  11. 4 files changed, 85 insertions(+)
  12. create mode 100644 libc/sysdeps/linux/common/process_vm_readv.c
  13. create mode 100644 libc/sysdeps/linux/common/process_vm_writev.c
  14. diff --git a/include/sys/uio.h b/include/sys/uio.h
  15. index 330426fec..9e9708c0c 100644
  16. --- a/include/sys/uio.h
  17. +++ b/include/sys/uio.h
  18. @@ -74,6 +74,25 @@ extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count,
  19. __off64_t __offset) __wur;
  20. #endif /* Use misc. */
  21. +#ifdef __USE_GNU
  22. +/* Read from another process' address space. */
  23. +extern ssize_t process_vm_readv (pid_t __pid, const struct iovec *__lvec,
  24. + unsigned long int __liovcnt,
  25. + const struct iovec *__rvec,
  26. + unsigned long int __riovcnt,
  27. + unsigned long int __flags)
  28. + __THROW;
  29. +
  30. +/* Write to another process' address space. */
  31. +extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec,
  32. + unsigned long int __liovcnt,
  33. + const struct iovec *__rvec,
  34. + unsigned long int __riovcnt,
  35. + unsigned long int __flags)
  36. + __THROW;
  37. +
  38. +#endif
  39. +
  40. __END_DECLS
  41. #endif /* sys/uio.h */
  42. diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
  43. index 83be2691e..e0b280c33 100644
  44. --- a/libc/sysdeps/linux/common/Makefile.in
  45. +++ b/libc/sysdeps/linux/common/Makefile.in
  46. @@ -40,6 +40,8 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \
  47. ppoll.c \
  48. prctl.c \
  49. prlimit.c \
  50. + process_vm_readv.c \
  51. + process_vm_writev.c \
  52. readahead.c \
  53. reboot.c \
  54. remap_file_pages.c \
  55. diff --git a/libc/sysdeps/linux/common/process_vm_readv.c b/libc/sysdeps/linux/common/process_vm_readv.c
  56. new file mode 100644
  57. index 000000000..b69c1c97a
  58. --- /dev/null
  59. +++ b/libc/sysdeps/linux/common/process_vm_readv.c
  60. @@ -0,0 +1,32 @@
  61. +/* process_vm_readv - Linux specific syscall.
  62. + Copyright (C) 2020-2024 Free Software Foundation, Inc.
  63. +
  64. + The GNU C Library is free software; you can redistribute it and/or
  65. + modify it under the terms of the GNU Lesser General Public
  66. + License as published by the Free Software Foundation; either
  67. + version 2.1 of the License, or (at your option) any later version.
  68. +
  69. + The GNU C Library is distributed in the hope that it will be useful,
  70. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  71. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  72. + Lesser General Public License for more details.
  73. +
  74. + You should have received a copy of the GNU Lesser General Public
  75. + License along with the GNU C Library; if not, see
  76. + <https://www.gnu.org/licenses/>. */
  77. +
  78. +#include <sys/uio.h>
  79. +#include <sys/syscall.h>
  80. +#include <unistd.h>
  81. +
  82. +#ifdef __NR_process_vm_readv
  83. +ssize_t
  84. +process_vm_readv (pid_t pid, const struct iovec *local_iov,
  85. + unsigned long int liovcnt,
  86. + const struct iovec *remote_iov,
  87. + unsigned long int riovcnt, unsigned long int flags)
  88. +{
  89. + return INLINE_SYSCALL (process_vm_readv, 6, pid, local_iov,
  90. + liovcnt, remote_iov, riovcnt, flags);
  91. +}
  92. +#endif
  93. diff --git a/libc/sysdeps/linux/common/process_vm_writev.c b/libc/sysdeps/linux/common/process_vm_writev.c
  94. new file mode 100644
  95. index 000000000..e22817a8d
  96. --- /dev/null
  97. +++ b/libc/sysdeps/linux/common/process_vm_writev.c
  98. @@ -0,0 +1,32 @@
  99. +/* process_vm_writev - Linux specific syscall.
  100. + Copyright (C) 2020-2024 Free Software Foundation, Inc.
  101. +
  102. + The GNU C Library is free software; you can redistribute it and/or
  103. + modify it under the terms of the GNU Lesser General Public
  104. + License as published by the Free Software Foundation; either
  105. + version 2.1 of the License, or (at your option) any later version.
  106. +
  107. + The GNU C Library is distributed in the hope that it will be useful,
  108. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  109. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  110. + Lesser General Public License for more details.
  111. +
  112. + You should have received a copy of the GNU Lesser General Public
  113. + License along with the GNU C Library; if not, see
  114. + <https://www.gnu.org/licenses/>. */
  115. +
  116. +#include <sys/uio.h>
  117. +#include <sys/syscall.h>
  118. +#include <unistd.h>
  119. +
  120. +#ifdef __NR_process_vm_writev
  121. +ssize_t
  122. +process_vm_writev (pid_t pid, const struct iovec *local_iov,
  123. + unsigned long int liovcnt,
  124. + const struct iovec *remote_iov,
  125. + unsigned long int riovcnt, unsigned long int flags)
  126. +{
  127. + return INLINE_SYSCALL (process_vm_writev, 6, pid, local_iov,
  128. + liovcnt, remote_iov, riovcnt, flags);
  129. +}
  130. +#endif
  131. --
  132. 2.30.2