Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundled linux/prctl.h missing the PR_SET_VMA macro needed for Android #189

Closed
yan12125 opened this issue Jul 19, 2021 · 1 comment
Closed

Comments

@yan12125
Copy link
Contributor

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 to the bundled one, building is fine. Here is my test:

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
@yan12125
Copy link
Contributor Author

Thanks! I can confirm the fix for Android aarch and x86-64.

yan12125 pushed a commit to archlinuxcn/repo that referenced this issue Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants