summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorEduardo Vasconcelos <eduardo@eduardovasconcelos.com>2026-05-21 12:13:06 -0300
committerJohn Johansen <john.johansen@canonical.com>2026-06-13 20:20:13 -0700
commit5112ed5258b8d5e0769ae7d2bf9c9dea14c59703 (patch)
tree4953e26185aaf145c981149d7d0dff51f1c36c29 /security
parentbcd1b34c21748531a3febaf7440632b89d8deab7 (diff)
apparmor: Fix inverted comparison in cache_hold_inc()
cache_hold_inc() prevents the per-CPU cache hold counter from rising above MAX_HOLD_COUNT, but the comparison is inverted (> MAX_HOLD_COUNT instead of <), so the counter never rises above 0. This breaks the cache mechanism because since the hold counter is always 0, the global pool is always attempted first before falling back to the local cache. The decrement also never occurs, thus the hold counter is effectively dead. Fix by changing > to < in cache_hold_inc(). Fixes: 0b6a6b72b329 ("apparmor: document the buffer hold, add an overflow guard") Signed-off-by: Eduardo Vasconcelos <eduardo@eduardovasconcelos.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/lsm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index 3491e9f60194..b7c19805a216 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -2129,7 +2129,7 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
*/
static void cache_hold_inc(unsigned int *hold)
{
- if (*hold > MAX_HOLD_COUNT)
+ if (*hold < MAX_HOLD_COUNT)
(*hold)++;
}