|
9 | 9 | #ifndef _SECURITY_LANDLOCK_RULESET_H |
10 | 10 | #define _SECURITY_LANDLOCK_RULESET_H |
11 | 11 |
|
12 | | -#include <linux/bitops.h> |
13 | | -#include <linux/build_bug.h> |
14 | 12 | #include <linux/cleanup.h> |
15 | 13 | #include <linux/err.h> |
16 | | -#include <linux/kernel.h> |
17 | 14 | #include <linux/mutex.h> |
18 | 15 | #include <linux/rbtree.h> |
19 | 16 | #include <linux/refcount.h> |
20 | 17 | #include <linux/workqueue.h> |
21 | | -#include <uapi/linux/landlock.h> |
22 | 18 |
|
| 19 | +#include "access.h" |
23 | 20 | #include "limits.h" |
24 | 21 | #include "object.h" |
25 | 22 |
|
26 | | -/* |
27 | | - * All access rights that are denied by default whether they are handled or not |
28 | | - * by a ruleset/layer. This must be ORed with all ruleset->access_masks[] |
29 | | - * entries when we need to get the absolute handled access masks. |
30 | | - */ |
31 | | -/* clang-format off */ |
32 | | -#define LANDLOCK_ACCESS_FS_INITIALLY_DENIED ( \ |
33 | | - LANDLOCK_ACCESS_FS_REFER) |
34 | | -/* clang-format on */ |
35 | | - |
36 | | -typedef u16 access_mask_t; |
37 | | -/* Makes sure all filesystem access rights can be stored. */ |
38 | | -static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_ACCESS_FS); |
39 | | -/* Makes sure all network access rights can be stored. */ |
40 | | -static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_ACCESS_NET); |
41 | | -/* Makes sure all scoped rights can be stored. */ |
42 | | -static_assert(BITS_PER_TYPE(access_mask_t) >= LANDLOCK_NUM_SCOPE); |
43 | | -/* Makes sure for_each_set_bit() and for_each_clear_bit() calls are OK. */ |
44 | | -static_assert(sizeof(unsigned long) >= sizeof(access_mask_t)); |
45 | | - |
46 | | -/* Ruleset access masks. */ |
47 | | -struct access_masks { |
48 | | - access_mask_t fs : LANDLOCK_NUM_ACCESS_FS; |
49 | | - access_mask_t net : LANDLOCK_NUM_ACCESS_NET; |
50 | | - access_mask_t scope : LANDLOCK_NUM_SCOPE; |
51 | | -}; |
52 | | - |
53 | | -union access_masks_all { |
54 | | - struct access_masks masks; |
55 | | - u32 all; |
56 | | -}; |
57 | | - |
58 | | -/* Makes sure all fields are covered. */ |
59 | | -static_assert(sizeof(typeof_member(union access_masks_all, masks)) == |
60 | | - sizeof(typeof_member(union access_masks_all, all))); |
61 | | - |
62 | | -typedef u16 layer_mask_t; |
63 | | -/* Makes sure all layers can be checked. */ |
64 | | -static_assert(BITS_PER_TYPE(layer_mask_t) >= LANDLOCK_MAX_NUM_LAYERS); |
65 | | - |
66 | 23 | /** |
67 | 24 | * struct landlock_layer - Access rights for a given layer |
68 | 25 | */ |
@@ -371,7 +328,7 @@ landlock_get_fs_access_mask(const struct landlock_ruleset *const ruleset, |
371 | 328 | { |
372 | 329 | /* Handles all initially denied by default access rights. */ |
373 | 330 | return ruleset->access_masks[layer_level].fs | |
374 | | - LANDLOCK_ACCESS_FS_INITIALLY_DENIED; |
| 331 | + _LANDLOCK_ACCESS_FS_INITIALLY_DENIED; |
375 | 332 | } |
376 | 333 |
|
377 | 334 | static inline access_mask_t |
|
0 commit comments