]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
landlock: Improve TSYNC types
authorMickaël Salaün <mic@digikod.net>
Tue, 17 Feb 2026 12:23:40 +0000 (13:23 +0100)
committerMickaël Salaün <mic@digikod.net>
Wed, 4 Mar 2026 17:28:11 +0000 (18:28 +0100)
Constify pointers when it makes sense.

Consistently use size_t for loops, especially to match works->size type.

Add new lines to improve readability.

Cc: Jann Horn <jannh@google.com>
Reviewed-by: Günther Noack <gnoack@google.com>
Link: https://lore.kernel.org/r/20260217122341.2359582-2-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
security/landlock/tsync.c

index 3e44be4f66e36da0d6039ccd4216c5b247aa4553..1e738ef2cff51369427939ddd07f9e2e09c5ae74 100644 (file)
@@ -290,13 +290,14 @@ static int tsync_works_grow_by(struct tsync_works *s, size_t n, gfp_t flags)
  * tsync_works_contains - checks for presence of task in s
  */
 static bool tsync_works_contains_task(const struct tsync_works *s,
-                                     struct task_struct *task)
+                                     const struct task_struct *task)
 {
        size_t i;
 
        for (i = 0; i < s->size; i++)
                if (s->works[i]->task == task)
                        return true;
+
        return false;
 }
 
@@ -318,6 +319,7 @@ static void tsync_works_release(struct tsync_works *s)
 
        for (i = 0; i < s->capacity; i++)
                kfree(s->works[i]);
+
        kfree(s->works);
        s->works = NULL;
        s->size = 0;
@@ -329,7 +331,7 @@ static void tsync_works_release(struct tsync_works *s)
  */
 static size_t count_additional_threads(const struct tsync_works *works)
 {
-       struct task_struct *thread, *caller;
+       const struct task_struct *caller, *thread;
        size_t n = 0;
 
        caller = current;
@@ -368,7 +370,8 @@ static bool schedule_task_work(struct tsync_works *works,
                               struct tsync_shared_context *shared_ctx)
 {
        int err;
-       struct task_struct *thread, *caller;
+       const struct task_struct *caller;
+       struct task_struct *thread;
        struct tsync_work *ctx;
        bool found_more_threads = false;
 
@@ -438,10 +441,10 @@ static bool schedule_task_work(struct tsync_works *works,
  * shared_ctx->num_preparing and shared_ctx->num_unfished and mark the two
  * completions if needed, as if the task was never scheduled.
  */
-static void cancel_tsync_works(struct tsync_works *works,
+static void cancel_tsync_works(const struct tsync_works *works,
                               struct tsync_shared_context *shared_ctx)
 {
-       int i;
+       size_t i;
 
        for (i = 0; i < works->size; i++) {
                if (WARN_ON_ONCE(!works->works[i]->task))