scoped_base_variants.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Landlock scoped_domains variants
  4. *
  5. * See the hierarchy variants from ptrace_test.c
  6. *
  7. * Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
  8. * Copyright © 2019-2020 ANSSI
  9. * Copyright © 2024 Tahera Fahimi <fahimitahera@gmail.com>
  10. */
  11. /* clang-format on */
  12. FIXTURE_VARIANT(scoped_domains)
  13. {
  14. bool domain_both;
  15. bool domain_parent;
  16. bool domain_child;
  17. };
  18. /*
  19. * No domain
  20. *
  21. * P1-. P1 -> P2 : allow
  22. * \ P2 -> P1 : allow
  23. * 'P2
  24. */
  25. /* clang-format off */
  26. FIXTURE_VARIANT_ADD(scoped_domains, without_domain) {
  27. /* clang-format on */
  28. .domain_both = false,
  29. .domain_parent = false,
  30. .domain_child = false,
  31. };
  32. /*
  33. * Child domain
  34. *
  35. * P1--. P1 -> P2 : allow
  36. * \ P2 -> P1 : deny
  37. * .'-----.
  38. * | P2 |
  39. * '------'
  40. */
  41. /* clang-format off */
  42. FIXTURE_VARIANT_ADD(scoped_domains, child_domain) {
  43. /* clang-format on */
  44. .domain_both = false,
  45. .domain_parent = false,
  46. .domain_child = true,
  47. };
  48. /*
  49. * Parent domain
  50. * .------.
  51. * | P1 --. P1 -> P2 : deny
  52. * '------' \ P2 -> P1 : allow
  53. * '
  54. * P2
  55. */
  56. /* clang-format off */
  57. FIXTURE_VARIANT_ADD(scoped_domains, parent_domain) {
  58. /* clang-format on */
  59. .domain_both = false,
  60. .domain_parent = true,
  61. .domain_child = false,
  62. };
  63. /*
  64. * Parent + child domain (siblings)
  65. * .------.
  66. * | P1 ---. P1 -> P2 : deny
  67. * '------' \ P2 -> P1 : deny
  68. * .---'--.
  69. * | P2 |
  70. * '------'
  71. */
  72. /* clang-format off */
  73. FIXTURE_VARIANT_ADD(scoped_domains, sibling_domain) {
  74. /* clang-format on */
  75. .domain_both = false,
  76. .domain_parent = true,
  77. .domain_child = true,
  78. };
  79. /*
  80. * Same domain (inherited)
  81. * .-------------.
  82. * | P1----. | P1 -> P2 : allow
  83. * | \ | P2 -> P1 : allow
  84. * | ' |
  85. * | P2 |
  86. * '-------------'
  87. */
  88. /* clang-format off */
  89. FIXTURE_VARIANT_ADD(scoped_domains, inherited_domain) {
  90. /* clang-format on */
  91. .domain_both = true,
  92. .domain_parent = false,
  93. .domain_child = false,
  94. };
  95. /*
  96. * Inherited + child domain
  97. * .-----------------.
  98. * | P1----. | P1 -> P2 : allow
  99. * | \ | P2 -> P1 : deny
  100. * | .-'----. |
  101. * | | P2 | |
  102. * | '------' |
  103. * '-----------------'
  104. */
  105. /* clang-format off */
  106. FIXTURE_VARIANT_ADD(scoped_domains, nested_domain) {
  107. /* clang-format on */
  108. .domain_both = true,
  109. .domain_parent = false,
  110. .domain_child = true,
  111. };
  112. /*
  113. * Inherited + parent domain
  114. * .-----------------.
  115. * |.------. | P1 -> P2 : deny
  116. * || P1 ----. | P2 -> P1 : allow
  117. * |'------' \ |
  118. * | ' |
  119. * | P2 |
  120. * '-----------------'
  121. */
  122. /* clang-format off */
  123. FIXTURE_VARIANT_ADD(scoped_domains, nested_and_parent_domain) {
  124. /* clang-format on */
  125. .domain_both = true,
  126. .domain_parent = true,
  127. .domain_child = false,
  128. };
  129. /*
  130. * Inherited + parent and child domain (siblings)
  131. * .-----------------.
  132. * | .------. | P1 -> P2 : deny
  133. * | | P1 . | P2 -> P1 : deny
  134. * | '------'\ |
  135. * | \ |
  136. * | .--'---. |
  137. * | | P2 | |
  138. * | '------' |
  139. * '-----------------'
  140. */
  141. /* clang-format off */
  142. FIXTURE_VARIANT_ADD(scoped_domains, forked_domains) {
  143. /* clang-format on */
  144. .domain_both = true,
  145. .domain_parent = true,
  146. .domain_child = true,
  147. };