aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/openat2/openat2_test.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-13selftests/openat2: Fix wrong format specifierMaciej Wieczor-Retman1-1/+1
Compiling openat2 selftest after adding a __printf() attribute to ksft_print_msg() exposes a -Wformat warning in test_openat2_flags(). The wrong format specifier is used for printing test.how->flags variable. Change the format specifier to %llX so it matches the printed variable. Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2022-01-27selftests: openat2: Skip testcases that fail with EOPNOTSUPPCristian Marussi1-1/+11
Skip testcases that fail since the requested valid flags combination is not supported by the underlying filesystem. Cc: Aleksa Sarai <cyphar@cyphar.com> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-08-25selftests: openat2: Fix testing failure for O_LARGEFILE flagBaolin Wang1-0/+4
The openat2 test suite fails on ARM64 because the definition of O_LARGEFILE is different on ARM64. Fix the problem by defining the correct O_LARGEFILE definition on ARM64. "openat2 unexpectedly returned # 3['.../tools/testing/selftests/openat2'] with 208000 (!= 208000) not ok 102 openat2 with incompatible flags (O_PATH | O_LARGEFILE) fails with -22 (Invalid argument)" Fixed change log to improve formatting and clarity: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> Reviewed-by: Aleksa Sarai <cyphar@cyphar.com> Acked-by: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-05-28test: add openat2() test for invalid upper 32 bit flag valueChristian Brauner1-1/+6
Test that openat2() rejects unknown flags in the upper 32 bit range. Link: https://lore.kernel.org/r/20210528092417.3942079-4-brauner@kernel.org Cc: Richard Guy Briggs <rgb@redhat.com> Cc: Aleksa Sarai <cyphar@cyphar.com> Cc: linux-fsdevel@vger.kernel.org Reviewed-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-12-03selftests: openat2: add RESOLVE_ conflict testAleksa Sarai1-1/+7
Now that we reject conflicting RESOLVE_ flags, add a selftest to avoid regressions. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> Link: https://lore.kernel.org/r/20201027235044.5240-3-cyphar@cyphar.com Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-18selftests: add openat2(2) selftestsAleksa Sarai1-0/+312
Test all of the various openat2(2) flags. A small stress-test of a symlink-rename attack is included to show that the protections against ".."-based attacks are sufficient. The main things these self-tests are enforcing are: * The struct+usize ABI for openat2(2) and copy_struct_from_user() to ensure that upgrades will be handled gracefully (in addition, ensuring that misaligned structures are also handled correctly). * The -EINVAL checks for openat2(2) are all correctly handled to avoid userspace passing unknown or conflicting flag sets (most importantly, ensuring that invalid flag combinations are checked). * All of the RESOLVE_* semantics (including errno values) are correctly handled with various combinations of paths and flags. * RESOLVE_IN_ROOT correctly protects against the symlink rename(2) attack that has been responsible for several CVEs (and likely will be responsible for several more). Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>