avc_has_perm(9)
π
avc_has_perm β a.k.a. the Kernel API Manual's avc_has_perm(9) page
okay so bestie, picture this: you're in the SELinux access vector cache (the AVC, iconic behavior) and you need to know if a thing is allowed to do a thing to another thing. That's literally this function. It checks permissions and does the auditing. Both. Multitasking queen. π
β¨ NAME β¨
avc_has_perm β check permissions and perform any appropriate auditing.
Like, it doesn't just peek β it also snitches to the audit log per policy. Periodt.
π SYNOPSIS π
int avc_has_perm (u32 ssid , u32 tsid , u16 tclass , u32 requested ,
struct common_audit_data *auditdata );
πΈ ARGUMENTS πΈ
ssidβ source security identifier. it's giving "who's asking" πtsidβ target security identifier. the main character being asked about π―tclassβ target security class. the category the target lives in, and it's what decides howrequestedgets interpretedrequestedβ the requested permissions, interpreted based ontclass(yes,tclassis the vibe check here β same bits mean different things depending on it)auditdataβ auxiliary audit data. the extra receipts π
π₯ DESCRIPTION π₯
So here's the tea: it checks the AVC to figure out whether the requested permissions are granted for the SID pair (ssid, tsid), interpreting the permissions based on tclass. And if that's a cache miss? Not me being unprepared β it calls the security server to obtain a new decision and add it to the cache. Lowkey a whole glow-up for the cache every time. β¨
Then it audits the granting or denial of permissions in accordance with the policy. No cap, everything gets logged the way policy says it should. π
Return value deets, because you know we care:
- returns
0if all requested permissions are granted β slay π - returns
-EACCESif any permissions are denied β denied, but make it documented π - or another
-errnoupon other errors β yeah, other stuff can go wrong too
fr fr though: a denial is not a crash.-EACCESis a normal answer here, so don't be dramatic about it. (Be dramatic about the other-errnovalues instead. π)
π¦ SEE ALSO π¦
Kernel file ./security/selinux/avc.c, plus the whole friend group: avc_init(9), avc_lookup(9), avc_insert(9), avc_audit_pre_callback(9), avc_audit_post_callback(9), avc_add_callback(9), avc_update_node(9), avc_flush(9), avc_ss_reset(9), avc_compute_av(9), avc_perm_nonode(9), avc_has_perm_noaudit(9).
and that's the whole page, bestie π brought to you by <./security/selinux> and dated October 2026 β signed off with avc_has_perm(9) energy, mwah π«Ά
π¦ 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