Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions security/landlock/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ static void test_is_eacces_with_write(struct kunit *const test)
* is_access_to_paths_allowed - Check accesses for requests with a common path
*
* @domain: Domain to check against.
* @path: File hierarchy to walk through.
* @path: File hierarchy to walk through. For refer checks, this would be
* the common mountpoint.
* @access_request_parent1: Accesses to check, once @layer_masks_parent1 is
* equal to @layer_masks_parent2 (if any). This is tied to the unique
* requested path for most actions, or the source in case of a refer action
Expand Down Expand Up @@ -910,9 +911,10 @@ static bool is_access_to_paths_allowed(
}
if (unlikely(IS_ROOT(walker_path.dentry))) {
/*
* Stops at disconnected root directories. Only allows
* access to internal filesystems (e.g. nsfs, which is
* reachable through /proc/<pid>/ns/<namespace>).
* Stops at disconnected root directories. Allows access to
* internal filesystems (e.g. nsfs, which is reachable through
* /proc/<pid>/ns/<namespace>), in addition to what's already
* allowed.
*/
if (walker_path.mnt->mnt_flags & MNT_INTERNAL) {
allowed_parent1 = true;
Expand Down
11 changes: 10 additions & 1 deletion security/landlock/ruleset.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ static void build_check_rule(void)
.num_layers = ~0,
};

/*
* Check that .num_layers is large enough for at least
* LANDLOCK_MAX_NUM_LAYERS layers
*/
BUILD_BUG_ON(rule.num_layers < LANDLOCK_MAX_NUM_LAYERS);
}

Expand Down Expand Up @@ -290,6 +294,10 @@ static void build_check_layer(void)
.access = ~0,
};

/*
* Check that .level and .access are large enough to contain their
* expected max values.
*/
BUILD_BUG_ON(layer.level < LANDLOCK_MAX_NUM_LAYERS);
BUILD_BUG_ON(layer.access < LANDLOCK_MASK_ACCESS_FS);
}
Expand Down Expand Up @@ -645,7 +653,8 @@ bool landlock_unmask_layers(const struct landlock_rule *const rule,

/*
* Records in @layer_masks which layer grants access to each
* requested access.
* requested access (bit in layer mask cleared if layer grants
* access).
*/
is_empty = true;
for_each_set_bit(access_bit, &access_req, masks_array_size) {
Expand Down
2 changes: 1 addition & 1 deletion security/landlock/ruleset.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct landlock_hierarchy;
*/
struct landlock_layer {
/**
* @level: Position of this layer in the layer stack.
* @level: Position of this layer in the layer stack. Starts from 1.
*/
u16 level;
/**
Expand Down