Skip to content

Commit e89dea2

Browse files
committed
landlock: Add missing kernel-doc "Return:" sections
The kernel-doc -Wreturn check warns about functions with documentation comments that lack a "Return:" section. Add "Return:" documentation to all functions missing it so that kernel-doc -Wreturn passes cleanly. Convert existing function descriptions into a formal "Return:" section. Also fix the inaccurate return documentation for landlock_merge_ruleset() which claimed to return @parent directly, and document the previously missing ERR_PTR() error return path. Document the ABI version and errata return paths for landlock_create_ruleset() which were previously only implied by the prose. Cc: Günther Noack <gnoack@google.com> Reviewed-by: Günther Noack <gnoack3000@gmail.com> Link: https://lore.kernel.org/r/20260304193134.250495-2-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent a060ac0 commit e89dea2

5 files changed

Lines changed: 24 additions & 14 deletions

File tree

security/landlock/domain.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ static struct landlock_details *get_current_details(void)
114114
* restriction. The subjective credentials must not be in an overridden state.
115115
*
116116
* @hierarchy->parent and @hierarchy->usage should already be set.
117+
*
118+
* Return: 0 on success, -errno on failure.
117119
*/
118120
int landlock_init_hierarchy_log(struct landlock_hierarchy *const hierarchy)
119121
{

security/landlock/fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ static int hook_path_truncate(const struct path *const path)
15681568
*
15691569
* @file: File being opened.
15701570
*
1571-
* Returns the access rights that are required for opening the given file,
1571+
* Return: The access rights that are required for opening the given file,
15721572
* depending on the file type and open mode.
15731573
*/
15741574
static access_mask_t

security/landlock/ruleset.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ static void build_check_ruleset(void)
201201
* When merging a ruleset in a domain, or copying a domain, @layers will be
202202
* added to @ruleset as new constraints, similarly to a boolean AND between
203203
* access rights.
204+
*
205+
* Return: 0 on success, -errno on failure.
204206
*/
205207
static int insert_rule(struct landlock_ruleset *const ruleset,
206208
const struct landlock_id id,
@@ -530,8 +532,8 @@ void landlock_put_ruleset_deferred(struct landlock_ruleset *const ruleset)
530532
* The current task is requesting to be restricted. The subjective credentials
531533
* must not be in an overridden state. cf. landlock_init_hierarchy_log().
532534
*
533-
* Returns the intersection of @parent and @ruleset, or returns @parent if
534-
* @ruleset is empty, or returns a duplicate of @ruleset if @parent is empty.
535+
* Return: A new domain merging @parent and @ruleset on success, or ERR_PTR()
536+
* on failure. If @parent is NULL, the new domain duplicates @ruleset.
535537
*/
536538
struct landlock_ruleset *
537539
landlock_merge_ruleset(struct landlock_ruleset *const parent,
@@ -622,7 +624,7 @@ landlock_find_rule(const struct landlock_ruleset *const ruleset,
622624
* @rule: A rule that grants a set of access rights for each layer
623625
* @masks: A matrix of unfulfilled access rights for each layer
624626
*
625-
* Returns true if the request is allowed (i.e. the access rights granted all
627+
* Return: True if the request is allowed (i.e. the access rights granted all
626628
* remaining unfulfilled access rights and masks has no leftover set bits).
627629
*/
628630
bool landlock_unmask_layers(const struct landlock_rule *const rule,

security/landlock/syscalls.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ static bool is_initialized(void)
6060
* @ksize_min: Minimal required size to be copied.
6161
* @src: User space pointer or NULL.
6262
* @usize: (Alleged) size of the data pointed to by @src.
63+
*
64+
* Return: 0 on success, -errno on failure.
6365
*/
6466
static __always_inline int
6567
copy_min_struct_from_user(void *const dst, const size_t ksize,
@@ -178,16 +180,19 @@ const int landlock_abi_version = 8;
178180
* - %LANDLOCK_CREATE_RULESET_VERSION
179181
* - %LANDLOCK_CREATE_RULESET_ERRATA
180182
*
181-
* This system call enables to create a new Landlock ruleset, and returns the
182-
* related file descriptor on success.
183+
* This system call enables to create a new Landlock ruleset.
183184
*
184185
* If %LANDLOCK_CREATE_RULESET_VERSION or %LANDLOCK_CREATE_RULESET_ERRATA is
185186
* set, then @attr must be NULL and @size must be 0.
186187
*
187-
* Possible returned errors are:
188+
* Return: The ruleset file descriptor on success, the Landlock ABI version if
189+
* %LANDLOCK_CREATE_RULESET_VERSION is set, the errata value if
190+
* %LANDLOCK_CREATE_RULESET_ERRATA is set, or -errno on failure. Possible
191+
* returned errors are:
188192
*
189193
* - %EOPNOTSUPP: Landlock is supported by the kernel but disabled at boot time;
190-
* - %EINVAL: unknown @flags, or unknown access, or unknown scope, or too small @size;
194+
* - %EINVAL: unknown @flags, or unknown access, or unknown scope, or too small
195+
* @size;
191196
* - %E2BIG: @attr or @size inconsistencies;
192197
* - %EFAULT: @attr or @size inconsistencies;
193198
* - %ENOMSG: empty &landlock_ruleset_attr.handled_access_fs.
@@ -398,7 +403,7 @@ static int add_rule_net_port(struct landlock_ruleset *ruleset,
398403
* This system call enables to define a new rule and add it to an existing
399404
* ruleset.
400405
*
401-
* Possible returned errors are:
406+
* Return: 0 on success, or -errno on failure. Possible returned errors are:
402407
*
403408
* - %EOPNOTSUPP: Landlock is supported by the kernel but disabled at boot time;
404409
* - %EAFNOSUPPORT: @rule_type is %LANDLOCK_RULE_NET_PORT but TCP/IP is not
@@ -464,7 +469,7 @@ SYSCALL_DEFINE4(landlock_add_rule, const int, ruleset_fd,
464469
* namespace or is running with no_new_privs. This avoids scenarios where
465470
* unprivileged tasks can affect the behavior of privileged children.
466471
*
467-
* Possible returned errors are:
472+
* Return: 0 on success, or -errno on failure. Possible returned errors are:
468473
*
469474
* - %EOPNOTSUPP: Landlock is supported by the kernel but disabled at boot time;
470475
* - %EINVAL: @flags contains an unknown bit.

security/landlock/task.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
*
3838
* Checks if the @parent domain is less or equal to (i.e. an ancestor, which
3939
* means a subset of) the @child domain.
40+
*
41+
* Return: True if @parent is an ancestor of or equal to @child, false
42+
* otherwise.
4043
*/
4144
static bool domain_scope_le(const struct landlock_ruleset *const parent,
4245
const struct landlock_ruleset *const child)
@@ -79,8 +82,7 @@ static int domain_ptrace(const struct landlock_ruleset *const parent,
7982
* If the current task has Landlock rules, then the child must have at least
8083
* the same rules. Else denied.
8184
*
82-
* Determines whether a process may access another, returning 0 if permission
83-
* granted, -errno if denied.
85+
* Return: 0 if permission is granted, -errno if denied.
8486
*/
8587
static int hook_ptrace_access_check(struct task_struct *const child,
8688
const unsigned int mode)
@@ -129,8 +131,7 @@ static int hook_ptrace_access_check(struct task_struct *const child,
129131
* If the parent has Landlock rules, then the current task must have the same
130132
* or more rules. Else denied.
131133
*
132-
* Determines whether the nominated task is permitted to trace the current
133-
* process, returning 0 if permission is granted, -errno if denied.
134+
* Return: 0 if permission is granted, -errno if denied.
134135
*/
135136
static int hook_ptrace_traceme(struct task_struct *const parent)
136137
{

0 commit comments

Comments
 (0)