Skip to content

Commit f4d3ef2

Browse files
micromaomaol0kod
authored andcommitted
landlock: Minor comments improvements
This patch contains some small comment changes. The first three comments for ruleset.c, I sort of made along the way while working on / trying to understand Landlock, and the one from ruleset.h was from the hashtable patch but extracted here. In fs.c, one comment which I found would have been helpful to me when reading this. Signed-off-by: Tingmao Wang <m@maowtm.org> Link: https://lore.kernel.org/r/20250602134150.67189-1-m@maowtm.org Link: https://lore.kernel.org/r/20297185fd71ffbb5ce4fec14b38e5444c719c96.1748379182.git.m@maowtm.org [mic: Squash patches with updated description, cosmetic fixes] Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent ac3fd01 commit f4d3ef2

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

security/landlock/fs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,8 @@ static void test_is_eacces_with_write(struct kunit *const test)
714714
* is_access_to_paths_allowed - Check accesses for requests with a common path
715715
*
716716
* @domain: Domain to check against.
717-
* @path: File hierarchy to walk through.
717+
* @path: File hierarchy to walk through. For refer checks, this would be
718+
* the common mountpoint.
718719
* @access_request_parent1: Accesses to check, once @layer_masks_parent1 is
719720
* equal to @layer_masks_parent2 (if any). This is tied to the unique
720721
* requested path for most actions, or the source in case of a refer action

security/landlock/ruleset.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ static void build_check_rule(void)
8383
.num_layers = ~0,
8484
};
8585

86+
/*
87+
* Checks that .num_layers is large enough for at least
88+
* LANDLOCK_MAX_NUM_LAYERS layers.
89+
*/
8690
BUILD_BUG_ON(rule.num_layers < LANDLOCK_MAX_NUM_LAYERS);
8791
}
8892

@@ -290,6 +294,10 @@ static void build_check_layer(void)
290294
.access = ~0,
291295
};
292296

297+
/*
298+
* Checks that .level and .access are large enough to contain their expected
299+
* maximum values.
300+
*/
293301
BUILD_BUG_ON(layer.level < LANDLOCK_MAX_NUM_LAYERS);
294302
BUILD_BUG_ON(layer.access < LANDLOCK_MASK_ACCESS_FS);
295303
}
@@ -644,8 +652,8 @@ bool landlock_unmask_layers(const struct landlock_rule *const rule,
644652
bool is_empty;
645653

646654
/*
647-
* Records in @layer_masks which layer grants access to each
648-
* requested access.
655+
* Records in @layer_masks which layer grants access to each requested
656+
* access: bit cleared if the related layer grants access.
649657
*/
650658
is_empty = true;
651659
for_each_set_bit(access_bit, &access_req, masks_array_size) {

security/landlock/ruleset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct landlock_hierarchy;
2727
*/
2828
struct landlock_layer {
2929
/**
30-
* @level: Position of this layer in the layer stack.
30+
* @level: Position of this layer in the layer stack. Starts from 1.
3131
*/
3232
u16 level;
3333
/**

0 commit comments

Comments
 (0)