File tree Expand file tree Collapse file tree 3 files changed +19
-11
lines changed Expand file tree Collapse file tree 3 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 20
20
/*
21
21
* All access rights that are denied by default whether they are handled or not
22
22
* by a ruleset/layer. This must be ORed with all ruleset->access_masks[]
23
- * entries when we need to get the absolute handled access masks.
23
+ * entries when we need to get the absolute handled access masks, see
24
+ * landlock_upgrade_handled_access_masks().
24
25
*/
25
26
/* clang-format off */
26
27
#define _LANDLOCK_ACCESS_FS_INITIALLY_DENIED ( \
@@ -59,4 +60,18 @@ typedef u16 layer_mask_t;
59
60
/* Makes sure all layers can be checked. */
60
61
static_assert (BITS_PER_TYPE (layer_mask_t ) >= LANDLOCK_MAX_NUM_LAYERS );
61
62
63
+ /* Upgrades with all initially denied by default access rights. */
64
+ static inline struct access_masks
65
+ landlock_upgrade_handled_access_masks (struct access_masks access_masks )
66
+ {
67
+ /*
68
+ * All access rights that are denied by default whether they are
69
+ * explicitly handled or not.
70
+ */
71
+ if (access_masks .fs )
72
+ access_masks .fs |= _LANDLOCK_ACCESS_FS_INITIALLY_DENIED ;
73
+
74
+ return access_masks ;
75
+ }
76
+
62
77
#endif /* _SECURITY_LANDLOCK_ACCESS_H */
Original file line number Diff line number Diff line change @@ -389,14 +389,6 @@ static bool is_nouser_or_private(const struct dentry *dentry)
389
389
unlikely (IS_PRIVATE (d_backing_inode (dentry ))));
390
390
}
391
391
392
- static access_mask_t
393
- get_handled_fs_accesses (const struct landlock_ruleset * const domain )
394
- {
395
- /* Handles all initially denied by default access rights. */
396
- return landlock_union_access_masks (domain ).fs |
397
- _LANDLOCK_ACCESS_FS_INITIALLY_DENIED ;
398
- }
399
-
400
392
static const struct access_masks any_fs = {
401
393
.fs = ~0 ,
402
394
};
@@ -788,7 +780,7 @@ static bool is_access_to_paths_allowed(
788
780
* a superset of the meaningful requested accesses).
789
781
*/
790
782
access_masked_parent1 = access_masked_parent2 =
791
- get_handled_fs_accesses (domain );
783
+ landlock_union_access_masks (domain ). fs ;
792
784
is_dom_check = true;
793
785
} else {
794
786
if (WARN_ON_ONCE (dentry_child1 || dentry_child2 ))
Original file line number Diff line number Diff line change @@ -387,7 +387,8 @@ static int merge_ruleset(struct landlock_ruleset *const dst,
387
387
err = - EINVAL ;
388
388
goto out_unlock ;
389
389
}
390
- dst -> access_masks [dst -> num_layers - 1 ] = src -> access_masks [0 ];
390
+ dst -> access_masks [dst -> num_layers - 1 ] =
391
+ landlock_upgrade_handled_access_masks (src -> access_masks [0 ]);
391
392
392
393
/* Merges the @src inode tree. */
393
394
err = merge_tree (dst , src , LANDLOCK_KEY_INODE );
You can’t perform that action at this time.
0 commit comments