[strace/strace] Bundled linux/prctl.h missing the PR_SET_VMA macro needed for Android (#189)
Chih-Hsuan Yen
notifications at github.com
Mon Jul 19 13:18:37 UTC 2021
Bundled `linux/prctl.h` in version 5.13 is missing the `PR_SET_VMA` macro needed for Android, and thus building strace for Android is broken.
```
aarch64-linux-android21-clang -DHAVE_CONFIG_H -I./linux/aarch64 -I./linux/aarch64 -I./linux/generic -I./linux/generic -I. -I. -I../bundled/linux/arch/arm64/include/uapi -I ../bundled/linux/include/uapi -DIN_STRACE=1 -Isrc/linux/generic -I./bundled/linux/arch/arm64/include/uapi -I./bundled/linux/include/uapi -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wformat-security -Winit-self -Winitializer-overrides -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wundef -Wwrite-strings -g -O2 -MT libstrace_a-prctl.o -MD -MP -MF .deps/libstrace_a-prctl.Tpo -c -o libstrace_a-prctl.o `test -f 'prctl.c' || echo './'`prctl.c
In file included from prctl.c:18:
./xlat/prctl_options.h:190:7: error: use of undeclared identifier 'PR_SET_VMA'
XLAT(PR_SET_VMA),
^
./xlat/prctl_options.h:201:10: error: invalid application of 'sizeof' to an incomplete type 'const struct xlat_data []'
.size = ARRAY_SIZE(prctl_options_xdata),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./macros.h:17:32: note: expanded from macro 'ARRAY_SIZE'
# define ARRAY_SIZE(a_) (sizeof(a_) / sizeof((a_)[0]) + MUST_BE_ARRAY(a_))
^~~~
```
The steps to reproduce are the same as #174, just with strace 5.13 instead of 5.11. This issue exists on both aarch64 and x86_64. Full logs can be found at https://build.archlinuxcn.org/~imlonghao/log/android-aarch64-strace/2021-07-19T12%3A17%3A02.html and https://build.archlinuxcn.org/~imlonghao/log/android-x86-64-strace/2021-07-19T12%3A17%3A02.html, respectively.
If I add that macro from [Google's kernel sources](https://android.googlesource.com/kernel/common/+/refs/tags/5.10-android12-9/include/uapi/linux/prctl.h#251) to the bundled one, building is fine. Here is my test:
```Diff
diff --git a/bundled/linux/include/uapi/linux/prctl.h b/bundled/linux/include/uapi/linux/prctl.h
index 18a9f59dc..763a7dcd6 100644
--- a/bundled/linux/include/uapi/linux/prctl.h
+++ b/bundled/linux/include/uapi/linux/prctl.h
@@ -255,6 +255,9 @@ struct prctl_mm_map {
# define SYSCALL_DISPATCH_FILTER_ALLOW 0
# define SYSCALL_DISPATCH_FILTER_BLOCK 1
+#define PR_SET_VMA 0x53564d41
+# define PR_SET_VMA_ANON_NAME 0
+
/* Set/get enabled arm64 pointer authentication keys */
#define PR_PAC_SET_ENABLED_KEYS 60
#define PR_PAC_GET_ENABLED_KEYS 61
```
Running seems fine, too:
```
$ ./strace ./strace 2>&1 | grep PR_SET_VMA | head
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d6943000, 20480, "bionic TLS guard") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d6944000, 12288, "bionic TLS") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d6942000, 1104, "arc4random data") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d693e000, 16384, "thread signal stack") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d693d000, 4096, "thread signal stack guard") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d693c000, 4096, "atexit handlers") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d693b000, 4096, "linker_alloc_small_objects") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d693a000, 24, "linker_alloc_vector") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d6939000, 4096, "linker_alloc_small_objects") = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x72d6938000, 24, "linker_alloc_vector") = 0
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/strace/strace/issues/189
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20210719/bd4141e1/attachment.htm>
More information about the Strace-devel
mailing list