apparmor: make __begin_current_label_crit_section() indicate whether put is needed
authorMateusz Guzik <mjguzik@gmail.com>
Tue, 18 Mar 2025 22:06:41 +0000 (23:06 +0100)
committerJohn Johansen <john.johansen@canonical.com>
Wed, 16 Jul 2025 05:39:43 +0000 (22:39 -0700)
commit87cc7b00114f6f751d25f6a5f05128dc27ef64db
treec8acf0039c846af5129c5e09977785033304ebb6
parent37a3741d27b64012ab6a5d9c92b514b977349dbb
apparmor: make __begin_current_label_crit_section() indicate whether put is needed

Same as aa_get_newest_cred_label_condref().

This avoids a bunch of work overall and allows the compiler to note when no
clean up is necessary, allowing for tail calls.

This in particular happens in apparmor_file_permission(), which manages to
tail call aa_file_perm() 105 bytes in (vs a regular call 112 bytes in
followed by branches to figure out if clean up is needed).

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/include/cred.h
security/apparmor/lsm.c
security/apparmor/policy.c