0ee2c886d6
[ Upstream commit 6b64a650f0b2ae3940698f401732988699eecf7a ] It was observed[1] on arm64 that __builtin_strlen led to an infinite loop in the get_size selftest. This is because __builtin_strlen (and other builtins) may sometimes result in a call to the C library function. The C library implementation of strlen uses an IFUNC resolver to load the most efficient strlen implementation for the underlying machine and hence has a PLT indirection even for static binaries. Because this binary avoids the C library startup routines, the PLT initialization never happens and hence the program gets stuck in an infinite loop. On x86_64 the __builtin_strlen just happens to expand inline and avoid the call but that is not always guaranteed. Further, while testing on x86_64 (Fedora 31), it was observed that the test also failed with a segfault inside write() because the generated code for the write function in glibc seems to access TLS before the syscall (probably due to the cancellation point check) and fails because TLS is not initialised. To mitigate these problems, this patch reduces the interface with the C library to just the syscall function. The syscall function still sets errno on failure, which is undesirable but for now it only affects cases where syscalls fail. [1] https://bugs.linaro.org/show_bug.cgi?id=5479 Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org> Reported-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Reviewed-by: Tim Bird <tim.bird@sony.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> |
||
---|---|---|
.. | ||
android | ||
bpf | ||
breakpoints | ||
capabilities | ||
cgroup | ||
cpu-hotplug | ||
cpufreq | ||
drivers | ||
efivarfs | ||
exec | ||
filesystems | ||
firmware | ||
ftrace | ||
futex | ||
gpio | ||
ia64 | ||
intel_pstate | ||
ipc | ||
kcmp | ||
kmod | ||
kvm | ||
lib | ||
locking | ||
media_tests | ||
membarrier | ||
memfd | ||
memory-hotplug | ||
mount | ||
mqueue | ||
net | ||
netfilter | ||
networking/timestamping | ||
nsfs | ||
ntb | ||
powerpc | ||
prctl | ||
proc | ||
pstore | ||
ptp | ||
ptrace | ||
rcutorture | ||
rseq | ||
rtc | ||
seccomp | ||
sigaltstack | ||
size | ||
sparc64 | ||
splice | ||
static_keys | ||
sync | ||
sysctl | ||
tc-testing | ||
timers | ||
uevent | ||
user | ||
vDSO | ||
vm | ||
watchdog | ||
x86 | ||
zram | ||
.gitignore | ||
gen_kselftest_tar.sh | ||
kselftest.h | ||
kselftest_harness.h | ||
kselftest_install.sh | ||
lib.mk | ||
Makefile |