]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
apparmor: fix rlimit for posix cpu timers
authorJohn Johansen <john.johansen@canonical.com>
Sun, 9 Nov 2025 22:16:54 +0000 (14:16 -0800)
committerJohn Johansen <john.johansen@canonical.com>
Thu, 29 Jan 2026 09:27:54 +0000 (01:27 -0800)
Posix cpu timers requires an additional step beyond setting the rlimit.
Refactor the code so its clear when what code is setting the
limit and conditionally update the posix cpu timers when appropriate.

Fixes: baa73d9e478ff ("posix-timers: Make them configurable")
Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/resource.c

index 8e80db3ae21c09052aa06cb24700ac2c6bcf229e..64212b39ba4bbc8581aaf74285f6e790f4688911 100644 (file)
@@ -196,6 +196,11 @@ void __aa_transition_rlimits(struct aa_label *old_l, struct aa_label *new_l)
                                             rules->rlimits.limits[j].rlim_max);
                        /* soft limit should not exceed hard limit */
                        rlim->rlim_cur = min(rlim->rlim_cur, rlim->rlim_max);
+                       if (j == RLIMIT_CPU &&
+                           rlim->rlim_cur != RLIM_INFINITY &&
+                           IS_ENABLED(CONFIG_POSIX_TIMERS))
+                               (void) update_rlimit_cpu(current->group_leader,
+                                                        rlim->rlim_cur);
                }
        }
 }