Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame^] | 1 | From a43e62dddcf51ec6578a90c5988a41e856b44b05 Mon Sep 17 00:00:00 2001 |
| 2 | From: Mark Wielaard <mark@klomp.org> |
| 3 | Date: Sat, 18 Nov 2023 21:17:02 +0100 |
| 4 | Subject: [PATCH 3/4] Add fchmodat2 syscall on linux |
| 5 | |
| 6 | fchmodat2 is a new syscall on linux 6.6. It is a variant of fchmodat |
| 7 | that takes an extra flags argument. |
| 8 | |
| 9 | https://bugs.kde.org/show_bug.cgi?id=477198 |
| 10 | |
| 11 | (cherry picked from commit 372d09fd9a8d76847c81092ebff71c80fd6c145d) |
| 12 | |
| 13 | Upstream-Status: Backport [https://sourceware.org/git/?p=valgrind.git;a=commit;h=a43e62dddcf51ec6578a90c5988a41e856b44b05] |
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 15 | --- |
| 16 | NEWS | 1 + |
| 17 | coregrind/m_syswrap/priv_syswrap-linux.h | 3 +++ |
| 18 | coregrind/m_syswrap/syswrap-amd64-linux.c | 2 ++ |
| 19 | coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++ |
| 20 | coregrind/m_syswrap/syswrap-arm64-linux.c | 2 ++ |
| 21 | coregrind/m_syswrap/syswrap-linux.c | 11 +++++++++++ |
| 22 | coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++ |
| 23 | coregrind/m_syswrap/syswrap-mips64-linux.c | 1 + |
| 24 | coregrind/m_syswrap/syswrap-nanomips-linux.c | 1 + |
| 25 | coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 ++ |
| 26 | coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 ++ |
| 27 | coregrind/m_syswrap/syswrap-s390x-linux.c | 2 ++ |
| 28 | coregrind/m_syswrap/syswrap-x86-linux.c | 2 ++ |
| 29 | include/vki/vki-scnums-shared-linux.h | 2 ++ |
| 30 | 14 files changed, 35 insertions(+) |
| 31 | |
| 32 | diff --git a/NEWS b/NEWS |
| 33 | index 6cd13429a..da0f8c1aa 100644 |
| 34 | --- a/NEWS |
| 35 | +++ b/NEWS |
| 36 | @@ -8,6 +8,7 @@ The following bugs have been fixed or resolved on this branch. |
| 37 | 476548 valgrind 3.22.0 fails on assertion when loading debuginfo |
| 38 | file produced by mold |
| 39 | 476708 valgrind-monitor.py regular expressions should use raw strings |
| 40 | +477198 Add fchmodat2 syscall on linux |
| 41 | |
| 42 | To see details of a given bug, visit |
| 43 | https://bugs.kde.org/show_bug.cgi?id=XXXXXX |
| 44 | diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h |
| 45 | index 7c9decf5a..798c456c9 100644 |
| 46 | --- a/coregrind/m_syswrap/priv_syswrap-linux.h |
| 47 | +++ b/coregrind/m_syswrap/priv_syswrap-linux.h |
| 48 | @@ -331,6 +331,9 @@ DECL_TEMPLATE(linux, sys_openat2); |
| 49 | // Linux-specific (new in Linux 5.14) |
| 50 | DECL_TEMPLATE(linux, sys_memfd_secret); |
| 51 | |
| 52 | +// Since Linux 6.6 |
| 53 | +DECL_TEMPLATE(linux, sys_fchmodat2); |
| 54 | + |
| 55 | /* --------------------------------------------------------------------- |
| 56 | Wrappers for sockets and ipc-ery. These are split into standalone |
| 57 | procedures because x86-linux hides them inside multiplexors |
| 58 | diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c |
| 59 | index 008600798..fe17d118b 100644 |
| 60 | --- a/coregrind/m_syswrap/syswrap-amd64-linux.c |
| 61 | +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c |
| 62 | @@ -886,6 +886,8 @@ static SyscallTableEntry syscall_table[] = { |
| 63 | LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 64 | |
| 65 | LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 |
| 66 | + |
| 67 | + LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 |
| 68 | }; |
| 69 | |
| 70 | SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) |
| 71 | diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c |
| 72 | index 9a7a1e0d2..811931d3b 100644 |
| 73 | --- a/coregrind/m_syswrap/syswrap-arm-linux.c |
| 74 | +++ b/coregrind/m_syswrap/syswrap-arm-linux.c |
| 75 | @@ -1059,6 +1059,8 @@ static SyscallTableEntry syscall_main_table[] = { |
| 76 | LINX_(__NR_faccessat2, sys_faccessat2), // 439 |
| 77 | |
| 78 | LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 79 | + |
| 80 | + LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 |
| 81 | }; |
| 82 | |
| 83 | |
| 84 | diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c |
| 85 | index 6af7bab83..3307bc2ca 100644 |
| 86 | --- a/coregrind/m_syswrap/syswrap-arm64-linux.c |
| 87 | +++ b/coregrind/m_syswrap/syswrap-arm64-linux.c |
| 88 | @@ -840,6 +840,8 @@ static SyscallTableEntry syscall_main_table[] = { |
| 89 | LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 90 | |
| 91 | LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 |
| 92 | + |
| 93 | + LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 |
| 94 | }; |
| 95 | |
| 96 | |
| 97 | diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c |
| 98 | index d571fc327..efa47f2e6 100644 |
| 99 | --- a/coregrind/m_syswrap/syswrap-linux.c |
| 100 | +++ b/coregrind/m_syswrap/syswrap-linux.c |
| 101 | @@ -6059,6 +6059,17 @@ PRE(sys_fchmodat) |
| 102 | PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2 ); |
| 103 | } |
| 104 | |
| 105 | +PRE(sys_fchmodat2) |
| 106 | +{ |
| 107 | + PRINT("sys_fchmodat2 ( %ld, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "u, %" |
| 108 | + FMT_REGWORD "u )", |
| 109 | + SARG1, ARG2, (HChar*)(Addr)ARG2, ARG3, ARG4); |
| 110 | + PRE_REG_READ4(long, "fchmodat2", |
| 111 | + int, dfd, const char *, path, vki_mode_t, mode, |
| 112 | + unsigned int, flags); |
| 113 | + PRE_MEM_RASCIIZ( "fchmodat2(pathname)", ARG2 ); |
| 114 | +} |
| 115 | + |
| 116 | PRE(sys_faccessat) |
| 117 | { |
| 118 | PRINT("sys_faccessat ( %ld, %#" FMT_REGWORD "x(%s), %ld )", |
| 119 | diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c |
| 120 | index 6268a00dd..74a1f6eac 100644 |
| 121 | --- a/coregrind/m_syswrap/syswrap-mips32-linux.c |
| 122 | +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c |
| 123 | @@ -1143,6 +1143,8 @@ static SyscallTableEntry syscall_main_table[] = { |
| 124 | LINX_ (__NR_faccessat2, sys_faccessat2), // 439 |
| 125 | |
| 126 | LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 127 | + |
| 128 | + LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 |
| 129 | }; |
| 130 | |
| 131 | SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) |
| 132 | diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c |
| 133 | index 6cdf25893..4e8508b7a 100644 |
| 134 | --- a/coregrind/m_syswrap/syswrap-mips64-linux.c |
| 135 | +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c |
| 136 | @@ -820,6 +820,7 @@ static SyscallTableEntry syscall_main_table[] = { |
| 137 | LINXY (__NR_close_range, sys_close_range), |
| 138 | LINX_ (__NR_faccessat2, sys_faccessat2), |
| 139 | LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), |
| 140 | + LINX_ (__NR_fchmodat2, sys_fchmodat2), |
| 141 | }; |
| 142 | |
| 143 | SyscallTableEntry * ML_(get_linux_syscall_entry) ( UInt sysno ) |
| 144 | diff --git a/coregrind/m_syswrap/syswrap-nanomips-linux.c b/coregrind/m_syswrap/syswrap-nanomips-linux.c |
| 145 | index d724cde74..7859900c1 100644 |
| 146 | --- a/coregrind/m_syswrap/syswrap-nanomips-linux.c |
| 147 | +++ b/coregrind/m_syswrap/syswrap-nanomips-linux.c |
| 148 | @@ -829,6 +829,7 @@ static SyscallTableEntry syscall_main_table[] = { |
| 149 | LINXY (__NR_close_range, sys_close_range), |
| 150 | LINX_ (__NR_faccessat2, sys_faccessat2), |
| 151 | LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), |
| 152 | + LINX_ (__NR_fchmodat2, sys_fchmodat2), |
| 153 | }; |
| 154 | |
| 155 | SyscallTableEntry* ML_(get_linux_syscall_entry) (UInt sysno) |
| 156 | diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c |
| 157 | index c0cfef235..1e19116ee 100644 |
| 158 | --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c |
| 159 | +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c |
| 160 | @@ -1063,6 +1063,8 @@ static SyscallTableEntry syscall_table[] = { |
| 161 | LINX_(__NR_faccessat2, sys_faccessat2), // 439 |
| 162 | |
| 163 | LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 164 | + |
| 165 | + LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 |
| 166 | }; |
| 167 | |
| 168 | SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) |
| 169 | diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c |
| 170 | index f5976f30c..1097212a4 100644 |
| 171 | --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c |
| 172 | +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c |
| 173 | @@ -1032,6 +1032,8 @@ static SyscallTableEntry syscall_table[] = { |
| 174 | LINX_(__NR_faccessat2, sys_faccessat2), // 439 |
| 175 | |
| 176 | LINXY (__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 177 | + |
| 178 | + LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 |
| 179 | }; |
| 180 | |
| 181 | SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) |
| 182 | diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c |
| 183 | index afba154e7..3588672c7 100644 |
| 184 | --- a/coregrind/m_syswrap/syswrap-s390x-linux.c |
| 185 | +++ b/coregrind/m_syswrap/syswrap-s390x-linux.c |
| 186 | @@ -873,6 +873,8 @@ static SyscallTableEntry syscall_table[] = { |
| 187 | LINX_(__NR_faccessat2, sys_faccessat2), // 439 |
| 188 | |
| 189 | LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 190 | + |
| 191 | + LINX_ (__NR_fchmodat2, sys_fchmodat2), // 452 |
| 192 | }; |
| 193 | |
| 194 | SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) |
| 195 | diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c |
| 196 | index da4fd8fa2..58badc6b0 100644 |
| 197 | --- a/coregrind/m_syswrap/syswrap-x86-linux.c |
| 198 | +++ b/coregrind/m_syswrap/syswrap-x86-linux.c |
| 199 | @@ -1658,6 +1658,8 @@ static SyscallTableEntry syscall_table[] = { |
| 200 | LINXY(__NR_epoll_pwait2, sys_epoll_pwait2), // 441 |
| 201 | |
| 202 | LINXY(__NR_memfd_secret, sys_memfd_secret), // 447 |
| 203 | + |
| 204 | + LINX_(__NR_fchmodat2, sys_fchmodat2), // 452 |
| 205 | }; |
| 206 | |
| 207 | SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) |
| 208 | diff --git a/include/vki/vki-scnums-shared-linux.h b/include/vki/vki-scnums-shared-linux.h |
| 209 | index 542382b53..a4cd87149 100644 |
| 210 | --- a/include/vki/vki-scnums-shared-linux.h |
| 211 | +++ b/include/vki/vki-scnums-shared-linux.h |
| 212 | @@ -50,4 +50,6 @@ |
| 213 | |
| 214 | #define __NR_memfd_secret 447 |
| 215 | |
| 216 | +#define __NR_fchmodat2 452 |
| 217 | + |
| 218 | #endif |
| 219 | -- |
| 220 | 2.44.0 |
| 221 | |