kernel-fxtec-pro1x/tools/testing/selftests
Siddhesh Poyarekar 0ee2c886d6 kselftest: Minimise dependency of get_size on C library interfaces
[ 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>
2020-02-24 08:34:37 +01:00
..
android
bpf selftests/bpf: Correct path to include msg + path 2019-12-31 16:34:53 +01:00
breakpoints
capabilities
cgroup cgroup: kselftest: relax fs_spec checks 2019-08-06 19:06:55 +02:00
cpu-hotplug selftests: cpu-hotplug: fix case where CPUs offline > CPUs present 2019-03-13 14:02:28 -07:00
cpufreq
drivers
efivarfs
exec
filesystems
firmware selftests: firmware: Fix it to do root uid check and skip 2020-01-17 19:47:14 +01:00
ftrace selftests/ftrace: Fix multiple kprobe testcase 2020-01-12 12:17:10 +01:00
futex
gpio selftests: gpio-mockup-chardev: Check asprintf() for error 2019-03-05 17:58:48 +01:00
ia64
intel_pstate
ipc selftests/ipc: Fix msgque compiler warnings 2020-01-27 14:50:40 +01:00
kcmp
kmod
kvm selftests: kvm: fix build with glibc >= 2.30 2019-12-13 08:51:05 +01:00
lib
locking
media_tests
membarrier
memfd
memory-hotplug
mount
mqueue
net selftests: rtnetlink: add addresses with fixed life time 2020-01-09 10:19:08 +01:00
netfilter selftests: netfilter: missing error check when setting up veth interface 2019-06-22 08:15:15 +02:00
networking/timestamping
nsfs
ntb
powerpc selftests/powerpc: Skip test instead of failing 2019-12-13 08:51:45 +01:00
prctl
proc selftests: fix warning: "_GNU_SOURCE" redefined 2019-12-01 09:17:00 +01:00
pstore
ptp
ptrace
rcutorture
rseq rseq/selftests: Turn off timeout setting 2020-01-17 19:47:15 +01:00
rtc selftests: rtc: rtctest: add alarm test on minute boundary 2019-03-05 17:58:47 +01:00
seccomp selftests: skip seccomp get_metadata test if not real root 2019-04-05 22:33:07 +02:00
sigaltstack
size kselftest: Minimise dependency of get_size on C library interfaces 2020-02-24 08:34:37 +01:00
sparc64
splice
static_keys
sync
sysctl
tc-testing tc-testing: fix build of eBPF programs 2019-11-24 08:20:29 +01:00
timers selftests/timers: Add missing fflush(stdout) calls 2019-06-19 08:18:04 +02:00
uevent
user
vDSO
vm tools/testing/selftests/vm/gup_benchmark.c: fix 'write' flag usage 2019-12-01 09:17:02 +01:00
watchdog selftests: watchdog: Fix error message. 2019-12-01 09:16:59 +01:00
x86
zram
.gitignore
gen_kselftest_tar.sh
kselftest.h
kselftest_harness.h
kselftest_install.sh
lib.mk
Makefile