selftests/landlock: Test FD passing from restricted to unrestricted processes
authorGünther Noack <gnoack3000@gmail.com>
Tue, 18 Oct 2022 18:22:13 +0000 (20:22 +0200)
committerMickaël Salaün <mic@digikod.net>
Wed, 19 Oct 2022 07:01:46 +0000 (09:01 +0200)
commita1a202a581817312a02b4d0daa6ca16f701f1e8a
treee123bf25e7c80858a956157a8b40b18a68979222
parent97b30f9e35709e9d2885efc5c1cd0bf54331ea3d
selftests/landlock: Test FD passing from restricted to unrestricted processes

A file descriptor created in a restricted process carries Landlock
restrictions with it which will apply even if the same opened file is
used from an unrestricted process.

This change extracts suitable FD-passing helpers from base_test.c and
moves them to common.h. We use the fixture variants from the ftruncate
fixture to exercise the same scenarios as in the open_and_ftruncate
test, but doing the Landlock restriction and open() in a different
process than the ftruncate() call.

Signed-off-by: Günther Noack <gnoack3000@gmail.com>
Link: https://lore.kernel.org/r/20221018182216.301684-9-gnoack3000@gmail.com
Signed-off-by: Mickaël Salaün <mic@digikod.net>
tools/testing/selftests/landlock/base_test.c
tools/testing/selftests/landlock/common.h
tools/testing/selftests/landlock/fs_test.c