Commit Graph
5 Commits
Author SHA1 Message Date
Cristian Marussi ac9e0a250b selftests: openat2: Skip testcases that fail with EOPNOTSUPP
Skip testcases that fail since the requested valid flags combination is not
supported by the underlying filesystem.

Cc: Aleksa Sarai <[email protected]>
Signed-off-by: Cristian Marussi <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
2022-01-27 16:31:07 -07:00
Baolin Wang d538ddb97e selftests: openat2: Fix testing failure for O_LARGEFILE flag
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 <[email protected]>

Signed-off-by: Baolin Wang <[email protected]>
Reviewed-by: Aleksa Sarai <[email protected]>
Acked-by: Christian Brauner <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
2021-08-25 13:46:13 -06:00
Christian Brauner 15845cbcd1 test: add openat2() test for invalid upper 32 bit flag value
Test that openat2() rejects unknown flags in the upper 32 bit range.

Link: https://lore.kernel.org/r/[email protected]
Cc: Richard Guy Briggs <[email protected]>
Cc: Aleksa Sarai <[email protected]>
Cc: [email protected]
Reviewed-by: Richard Guy Briggs <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
2021-05-28 17:44:37 +02:00
Aleksa Sarai 4e62d55d77 selftests: openat2: add RESOLVE_ conflict test
Now that we reject conflicting RESOLVE_ flags, add a selftest to avoid
regressions.

Signed-off-by: Aleksa Sarai <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Christian Brauner <[email protected]>
2020-12-03 10:16:28 +01:00
Aleksa Sarai b28a10aedc selftests: add openat2(2) selftests
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 <[email protected]>
Signed-off-by: Aleksa Sarai <[email protected]>
Signed-off-by: Al Viro <[email protected]>
2020-01-18 09:19:18 -05:00