aa_change_hat(9)
okay bestie, welcome to aa_change_hat(9) from the Kernel API Manual β we're doing a whole hat-change-to/from-subprofile moment, and yes the manual name is literally right there in the function name, iykyk π
β¨
π NAME π
aa_change_hat β change hat to/from subprofile. That's the whole vibe: it's the function that flips your hat to/from a subprofile, periodt π«Ά
π¦ SYNOPSIS π¦
int aa_change_hat (const char *hats[] , int count , u64 token , int
flags );
β¨ ARGUMENTS β¨
hatsβ vector of hat names to try changing into (MAYBE NULLifcount == 0) β yes, all caps, that's the actual note πcountβ number of hat names inhatsβ the whole count, bestie π’tokenβ magic value to validate the hat change β magic value, literally β¨flagsβ flags affecting behavior of the change β flags doing flag things, highkey important π©
π₯ DESCRIPTION π₯
Returns 0 on success, error otherwise. That's the contract, bestie β 0 is the slay, anything else is the error vibe π
Change to the first profile specified in hats that exists, and store the hat_magic in the current task context. If the count == 0 and the token matches that stored in the current task context, return to the top level profile. Iconic behavior, honestly. β¨
change_hat only applies to profiles in the current ns, and each profile in the ns must make the same transition otherwise change_hat will fail. No cap, that same-transition rule is not optional. π
π SEE ALSO π
Kernel file ./security/apparmor/domain.c may_change_ptraced_domain(9), label_compound_match(9), label_components_match(9), label_match(9), change_profile_perms(9), aa_xattrs_match(9), find_attach(9), x_table_lookup(9), x_to_label(9), apparmor_bprm_creds_for_exec(9), aa_change_profile(9) β a whole friend group of references, go read them if you're nosy π«Ά
mwah π β this page comes from ./security/apparmor, dated October 2026, and it's all about aa_change_hat(9). byeee ππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms