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

fix(main/valgrind): x86_64 syscall patch #19741

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

truboxl
Copy link
Contributor

@truboxl truboxl commented Apr 11, 2024

Fix #17359

@twaik
Copy link
Member

twaik commented Apr 11, 2024

Probably that needs further investigation.

~ $ valgrind ls
valgrind: mmap(0x181000, 712704) failed in UME with error 22 (Invalid argument).
valgrind: this can be caused by executables with very large text, data or bss segments.
~ $ strace valgrind ls
execve("/data/data/com.termux/files/usr/bin/valgrind", ["valgrind", "ls"], 0x7fff9e8af0b8 /* 49 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7ffcb4da5e20) = 0
getpid()                                = 6263
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d556e6000
set_tid_address(0x3064c8)               = 6263
faccessat(AT_FDCWD, "/dev/urandom", R_OK) = 0
getrandom("\x7b\x41\x76\x28\x20\x49\xc6\xa3\xe3\x55\x3b\xb5\x45\x2c\x2f\x41\xe8\x1c\x02\x93\x10\x76\x4d\x89\x86\x1f\x42\xd0\xe9\xfe\x45\x65"..., 40, GRND_NONBLOCK) = 40
mmap(NULL, 1104, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d556e5000
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d556e5000, 1104, "arc4random data") = 0
sched_getscheduler(0)                   = 0 (SCHED_OTHER)
mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d556dc000
mprotect(0x719d556dc000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0x719d556dd000, ss_flags=0, ss_size=32768}, NULL) = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d556dd000, 32768, "thread signal stack") = 0
mprotect(0x305000, 4096, PROT_READ)     = 0
mprotect(0x305000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x305000, 4096, PROT_READ)     = 0
fcntl(0, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fcntl(1, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fcntl(2, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
mmap(NULL, 24576, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x719d556d6000
mprotect(0x719d556d7000, 16384, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], NULL, 8) = 0
arch_prctl(ARCH_SET_FS, 0x719d556daf80) = 0
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d556d7000, 16384, "stack_and_tls:main") = 0
munmap(0x719d556e6000, 12288)           = 0
newfstatat(AT_FDCWD, "/dev/__properties__", {st_mode=S_IFDIR|0711, st_size=3460, ...}, 0) = 0
faccessat(AT_FDCWD, "/dev/__properties__/property_info", R_OK) = 0
openat(AT_FDCWD, "/dev/__properties__/property_info", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=44704, ...}) = 0
mmap(NULL, 44704, PROT_READ, MAP_SHARED, 3, 0) = 0x719d556cb000
close(3)                                = 0
mmap(NULL, 6760, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d556e7000
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d556e7000, 6760, "System property context nodes") = 0
openat(AT_FDCWD, "/dev/__properties__/properties_serial", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=131072, ...}) = 0
mmap(NULL, 131072, PROT_READ, MAP_SHARED, 3, 0) = 0x719d556ab000
close(3)                                = 0
openat(AT_FDCWD, "/dev/__properties__/u:object_r:debug_prop:s0", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=131072, ...}) = 0
mmap(NULL, 131072, PROT_READ, MAP_SHARED, 3, 0) = 0x719d5568b000
close(3)                                = 0
rt_sigaction(SIGRT_7, {sa_handler=0x22ef70, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x2300e0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_4, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x2300e0}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGRT_6, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x2300e0}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=0}, 8) = 0
open("/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY) = -1 ENOENT (No such file or directory)
mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d5548b000
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d5548b000, 2097152, "libc_malloc") = 0
munmap(0x719d5548b000, 2097152)         = 0
mmap(NULL, 4190208, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d5528c000
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d5528c000, 4190208, "libc_malloc") = 0
munmap(0x719d5528c000, 1523712)         = 0
munmap(0x719d55600000, 569344)          = 0
mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d55200000
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d55200000, 2097152, "libc_malloc") = 0
mprotect(0x2af000, 16384, PROT_READ)    = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x719d556e6000
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, 0x719d556e6000, 4096, "atexit handlers") = 0
mprotect(0x719d556e6000, 4096, PROT_READ) = 0
mprotect(0x719d556e6000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x719d556e6000, 4096, PROT_READ) = 0
faccessat(AT_FDCWD, "/data/data/com.termux/files/usr/bin/ls", R_OK|X_OK) = 0
openat(AT_FDCWD, "/data/data/com.termux/files/usr/bin/ls", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\234\7\0\0\0\0\0"..., 4096) = 4096
close(3)                                = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/data/data/com.termux/files/usr/"..., 500) = 44
execve("/data/data/com.termux/files/usr/libexec/valgrind/memcheck-amd64-linux", ["valgrind", "ls"], 0x719d5520b000 /* 50 vars */) = 0
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY) = 3
read(3, "00200000-00201000 r--p 00000000 "..., 100000) = 1081
read(3, "", 98919)                      = 0
close(3)                                = 0
mmap(0x1002001000, 4194304, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0, 0) = 0x1002001000
prlimit64(0, RLIMIT_DATA, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
getcwd("/data/data/com.termux/files/home", 499) = 33
openat(AT_FDCWD, "/data/data/com.termux/files/home/.valgrindrc", O_RDONLY) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/data/data/com.termux/files/usr/bin/ls", {st_mode=S_IFREG|0700, st_size=1258832, ...}, 0) = 0
faccessat(AT_FDCWD, "/data/data/com.termux/files/usr/bin/ls", R_OK|X_OK) = 0
openat(AT_FDCWD, "/data/data/com.termux/files/usr/bin/ls", O_RDONLY) = 3
newfstatat(AT_FDCWD, "/data/data/com.termux/files/usr/bin/ls", {st_mode=S_IFREG|0700, st_size=1258832, ...}, 0) = 0
getxattr("/data/data/com.termux/files/usr/bin/ls", "security.capability", NULL, 0) = -1 ENODATA (No data available)
geteuid()                               = 10162
fstat(3, {st_mode=S_IFREG|0700, st_size=1258832, ...}) = 0
pread64(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\234\7\0\0\0\0\0"..., 4096, 0) = 4096
pread64(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\234\7\0\0\0\0\0"..., 64, 0) = 64
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 616, 64) = 616
pread64(3, "/system/bin/linker64\0", 21, 680) = 21
openat(AT_FDCWD, "/system/bin/linker64", O_RDONLY) = 4
pread64(4, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\36\6\0\0\0\0\0"..., 64, 0) = 64
pread64(4, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 560, 64) = 560
mmap(0x108000, 495616, PROT_READ, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x108000
fstat(3, {st_mode=S_IFREG|0700, st_size=1258832, ...}) = 0
readlinkat(AT_FDCWD, "/proc/self/fd/3", "/data/data/com.termux/files/usr/"..., 4096) = 45
write(2, "valgrind: mmap(0x181000, 712704)"..., 81valgrind: mmap(0x181000, 712704) failed in UME with error 22 (Invalid argument).
) = 81
write(2, "valgrind: this can be caused by "..., 88valgrind: this can be caused by executables with very large text, data or bss segments.
) = 88
exit_group(1)                           = ?
+++ exited with 1 +++

@truboxl
Copy link
Contributor Author

truboxl commented Apr 11, 2024

@landfillbaby @Grimler91 can you confirm this issue also happens on aarch64 / arm? If so I think valgrind is broken for all arches

@twaik
Copy link
Member

twaik commented Apr 11, 2024

Hmmmm. I am getting almost the same message (with different numbers) on my aarch64 device. I can confirm it is broken.

@landfillbaby
Copy link
Member

landfillbaby commented Apr 11, 2024

yep it's the same for me too on my pixel 6

@truboxl
Copy link
Contributor Author

truboxl commented Apr 12, 2024

Ok I will merge this to fix x86_64 valgrind seccomp issue. Supposedly fixing aarch64 should also reflect on other arches.

@truboxl truboxl merged commit 7400b66 into termux:master Apr 12, 2024
@truboxl truboxl deleted the valgrind-x86_64-syscall branch April 12, 2024 12:57
bigbio2002 pushed a commit to bigbio2002/termux-packages that referenced this pull request Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: valgrind bad system call
3 participants