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 2020/*
2121 * All access rights that are denied by default whether they are handled or not
2222 * 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().
2425 */
2526/* clang-format off */
2627#define _LANDLOCK_ACCESS_FS_INITIALLY_DENIED ( \
@@ -59,4 +60,18 @@ typedef u16 layer_mask_t;
5960/* Makes sure all layers can be checked. */
6061static_assert (BITS_PER_TYPE (layer_mask_t ) >= LANDLOCK_MAX_NUM_LAYERS );
6162
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+
6277#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)
389389 unlikely (IS_PRIVATE (d_backing_inode (dentry ))));
390390}
391391
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-
400392static const struct access_masks any_fs = {
401393 .fs = ~0 ,
402394};
@@ -788,7 +780,7 @@ static bool is_access_to_paths_allowed(
788780 * a superset of the meaningful requested accesses).
789781 */
790782 access_masked_parent1 = access_masked_parent2 =
791- get_handled_fs_accesses (domain );
783+ landlock_union_access_masks (domain ). fs ;
792784 is_dom_check = true;
793785 } else {
794786 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,
387387 err = - EINVAL ;
388388 goto out_unlock ;
389389 }
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 ]);
391392
392393 /* Merges the @src inode tree. */
393394 err = merge_tree (dst , src , LANDLOCK_KEY_INODE );
You can’t perform that action at this time.
0 commit comments