* [PATCH] apparmor: Fix inverted comparison in cache_hold_inc()
@ 2026-05-21 6:57 Eduardo Vasconcelos
0 siblings, 0 replies; only message in thread
From: Eduardo Vasconcelos @ 2026-05-21 6:57 UTC (permalink / raw)
To: john.johansen, paul, jmorris, serge
Cc: Eduardo Vasconcelos, apparmor, linux-security-module,
linux-kernel
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().
Signed-off-by: Eduardo Vasconcelos <eduardo@eduardovasconcelos.com>
---
security/apparmor/lsm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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)++;
}
--
2.54.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-21 6:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21 6:57 [PATCH] apparmor: Fix inverted comparison in cache_hold_inc() Eduardo Vasconcelos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox