scoped_test.c 676 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Landlock tests - Common scope restriction
  4. *
  5. * Copyright © 2024 Tahera Fahimi <fahimitahera@gmail.com>
  6. */
  7. #define _GNU_SOURCE
  8. #include <errno.h>
  9. #include <linux/landlock.h>
  10. #include <sys/prctl.h>
  11. #include "common.h"
  12. #define ACCESS_LAST LANDLOCK_SCOPE_SIGNAL
  13. TEST(ruleset_with_unknown_scope)
  14. {
  15. __u64 scoped_mask;
  16. for (scoped_mask = 1ULL << 63; scoped_mask != ACCESS_LAST;
  17. scoped_mask >>= 1) {
  18. struct landlock_ruleset_attr ruleset_attr = {
  19. .scoped = scoped_mask,
  20. };
  21. ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr,
  22. sizeof(ruleset_attr), 0));
  23. ASSERT_EQ(EINVAL, errno);
  24. }
  25. }
  26. TEST_HARNESS_MAIN