]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
apparmor: add fn to test if profile supports a given mediation class
authorJohn Johansen <john.johansen@canonical.com>
Mon, 29 May 2017 18:45:29 +0000 (11:45 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Sun, 11 Jun 2017 00:11:29 +0000 (17:11 -0700)
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/include/policy.h

index 97bfbddef7b2dc6426b116c05e298229e1aaf940..d93f475bfd8ba5f31ade5b8749a726beff739200 100644 (file)
@@ -222,6 +222,16 @@ void __aa_profile_list_release(struct list_head *head);
 
 #define unconfined(X) ((X)->mode == APPARMOR_UNCONFINED)
 
+#define PROFILE_MEDIATES(P, T)  ((P)->policy.start[(T)])
+/* safe version of POLICY_MEDIATES for full range input */
+static inline unsigned int PROFILE_MEDIATES_SAFE(struct aa_profile *profile,
+                                                unsigned char class)
+{
+       if (profile->policy.dfa)
+               return aa_dfa_match_len(profile->policy.dfa,
+                                       profile->policy.start[0], &class, 1);
+       return 0;
+}
 
 /**
  * aa_get_profile - increment refcount on profile @p