wayland/tests
Bryce Harrington 76fe89ed53 tests: Fix FAIL in sanity-test (*timeout*) when Yama LSM enabled
This fixes a regression in the testsuite since c3653f7f, where four of
the timeout tests fail with "Timeouts suppressed" messages.

The timeouts are being suppressed because the testsuite is erroneously
detecting that a debugger is attached.  This detection mechanism
(adopted from libinput) uses ptrace to test if there is a debugger
parent process that can be attached.  Unfortunately, this is an
unreliable test: Kernel security policies exist to restrict the scope of
ptrace to prevent processes from snooping on one another.[1] This
security policy is set as the default on Ubuntu, and potentially other
Linux distributions.[2]

The Yama documentation suggests, "For software that has defined
application-specific relationships between a debugging process and its
inferior (crash handlers, etc), prctl(PR_SET_PTRACER, pid, ...) can be
used.  An inferior can declare which other process (and its descendents)
are allowed to call PTRACE_ATTACH against it."  This prctl call has no
effect if Yama LSM is not loaded.

The child needs to be synchronized to the client to prevent a race
condition where the child might try to operate before the parent has
finished its prctl call.  This synchronization is done via pipes.

This patch can be tested by running sanity-test with
/proc/sys/kernel/yama/ptrace_scope set to 0 or 1; the test must pass for
either value.

1: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2d514487faf188938a4ee4fb3464eeecfbdcf8eb
2: https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace_Protection

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>

v4: Allow parent to communicate error state to child to prevent leaving
child in zombie state if parent hits an error.

v5: Check errno instead of rc for error.  Don't waitpid on ppid.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-02-06 14:39:36 -08:00
..
array-test.c array-test: assert wl_array_add result is not NULL 2014-01-15 10:46:08 -08:00
client-test.c server: Make wl_object and wl_resource opaque structs 2013-07-02 15:52:47 -04:00
connection-test.c connection-test: add tests for closure leaks 2015-01-28 17:17:13 +00:00
cpp-compile-test.cpp tests: C++ compilation test 2015-01-27 11:17:42 +00:00
display-test.c display-test: disable leak check in tests that use pthread 2015-01-28 17:17:24 +00:00
event-loop-test.c tests: fix event_loop_timer_updates 2014-08-19 14:34:50 +03:00
exec-fd-leak-checker.c tests: support testing fd inheritance over exec 2012-04-20 15:06:27 +03:00
fixed-benchmark.c tests: fix make check for out-of-tree builds 2012-06-30 19:58:37 +00:00
fixed-test.c tests: fix make check for out-of-tree builds 2012-06-30 19:58:37 +00:00
list-test.c tests: fix make check for out-of-tree builds 2012-06-30 19:58:37 +00:00
map-test.c Update tests for wl_map changes and add a map_flags test 2013-06-05 17:55:14 -04:00
message-test.c tests: Add message version sanity test 2014-05-09 14:32:04 -07:00
os-wrappers-test.c os-wrappers-test: assert closure is not NULL before invoking it 2014-01-15 10:46:08 -08:00
queue-test.c tests: split queue-test testcases 2014-12-01 12:04:18 +02:00
resources-test.c resources-test: Don't send invalid event 2014-01-20 15:07:55 -08:00
sanity-test.c tests: add possibility to disable leak check for single test 2015-01-28 17:17:22 +00:00
signal-test.c tests: add unit tests for wl_signal 2013-09-21 11:37:38 -07:00
socket-test.c tests: add tests for bug in adding socket 2014-08-07 16:04:17 +03:00
test-compositor.c test-compositor: extend leak checks into clients 2015-01-28 17:17:06 +00:00
test-compositor.h tests: add test-compositor 2014-08-22 12:34:33 +03:00
test-helpers.c tests: add test_usleep and test_sleep functions 2014-11-17 16:48:14 +02:00
test-runner.c tests: Fix FAIL in sanity-test (*timeout*) when Yama LSM enabled 2015-02-06 14:39:36 -08:00
test-runner.h tests: add possibility to disable leak check for single test 2015-01-28 17:17:22 +00:00