/* flags in the dfa accept2 table */ enum dfa_accept_flags {
ACCEPT_FLAG_OWNER = 1,
};
/* * FIXME: currently need a clean way to replace and remove profiles as a * set. It should be done at the namespace level. * Either, with a set of profiles loaded at the namespace level or via * a mark and remove marked interface.
*/ enum profile_mode {
APPARMOR_ENFORCE, /* enforce access rules */
APPARMOR_COMPLAIN, /* allow and log access violations */
APPARMOR_KILL, /* kill task on access violation */
APPARMOR_UNCONFINED, /* profile set to unconfined */
APPARMOR_USER, /* modified complain mode to userspace */
};
/* struct aa_policydb - match engine for a policy * count: refcount for the pdb * dfa: dfa pattern match * perms: table of permissions * strs: table of strings, index by x * start: set of start states for the different classes of data
*/ struct aa_policydb { struct kref count; struct aa_dfa *dfa; struct { struct aa_perms *perms;
u32 size;
}; struct aa_str_table trans;
aa_state_t start[AA_CLASS_LAST + 1];
};
/** * aa_get_pdb - increment refcount on @pdb * @pdb: policydb (MAYBE NULL) * * Returns: pointer to @pdb if @pdb is NULL will return NULL * Requires: @pdb must be held with valid refcount when called
*/ staticinlinestruct aa_policydb *aa_get_pdb(struct aa_policydb *pdb)
{ if (pdb)
kref_get(&(pdb->count));
return pdb;
}
/** * aa_put_pdb - put a pdb refcount * @pdb: pdb to put refcount (MAYBE NULL) * * Requires: if @pdb != NULL that a valid refcount be held
*/ staticinlinevoid aa_put_pdb(struct aa_policydb *pdb)
{ if (pdb)
kref_put(&pdb->count, aa_pdb_free_kref);
}
/* lookup perm that doesn't have and object conditional */ staticinlinestruct aa_perms *aa_lookup_perms(struct aa_policydb *policy,
aa_state_t state)
{ unsignedint index = ACCEPT_TABLE(policy->dfa)[state];
if (!(policy->perms)) return &default_perms;
return &(policy->perms[index]);
}
/* struct aa_data - generic data structure * key: name for retrieving this data * size: size of data in bytes * data: binary data * head: reserved for rhashtable
*/ struct aa_data { char *key;
u32 size; char *data; struct rhash_head head;
};
/* struct aa_ruleset - data covering mediation rules * @list: list the rule is on * @size: the memory consumed by this ruleset * @policy: general match rules governing policy * @file: The set of rules governing basic file access and domain transitions * @caps: capabilities for the profile * @rlimits: rlimits for the profile * @secmark_count: number of secmark entries * @secmark: secmark label match info
*/ struct aa_ruleset { int size;
/* struct aa_attachment - data and rules for a profiles attachment * @list: * @xmatch_str: human readable attachment string * @xmatch: optional extended matching for unconfined executables names * @xmatch_len: xmatch prefix len, used to determine xmatch priority * @xattr_count: number of xattrs in table * @xattrs: table of xattrs
*/ struct aa_attachment { constchar *xmatch_str; struct aa_policydb *xmatch; unsignedint xmatch_len; int xattr_count; char **xattrs;
};
/* struct aa_profile - basic confinement data * @base - base components of the profile (name, refcount, lists, lock ...) * @parent: parent of profile * @ns: namespace the profile is in * @rename: optional profile name that this profile renamed * * @audit: the auditing mode of the profile * @mode: the enforcement mode of the profile * @path_flags: flags controlling path generation behavior * @signal: the signal that should be used when kill is used * @disconnected: what to prepend if attach_disconnected is specified * @attach: attachment rules for the profile * @rules: rules to be enforced * * learning_cache: the accesses learned in complain mode * raw_data: rawdata of the loaded profile policy * hash: cryptographic hash of the profile * @dents: dentries for the profiles file entries in apparmorfs * @dirname: name of the profile dir in apparmorfs * @dents: set of dentries associated with the profile * @data: hashtable for free-form policy aa_data * @label - label this profile is an extension of * @rules - label with the rule vec on its end * * The AppArmor profile contains the basic confinement data. Each profile * has a name, and exists in a namespace. The @name and @exec_match are * used to determine profile attachment against unconfined tasks. All other * attachments are determined by profile X transition rules. * * Profiles have a hierarchy where hats and children profiles keep * a reference to their parent. * * Profile names can not begin with a : and can not contain the \0 * character. If a profile name begins with / it will be considered when * determining profile attachment on "unconfined" tasks.
*/ struct aa_profile { struct aa_policy base; struct aa_profile __rcu *parent;
struct aa_ns *ns; constchar *rename;
enum audit_mode audit; long mode;
u32 path_flags; int signal; constchar *disconnected;
/** * aa_get_newest_profile - simple wrapper fn to wrap the label version * @p: profile (NOT NULL) * * Returns refcount to newest version of the profile (maybe @p) * * Requires: @p must be held with a valid refcount
*/ staticinlinestruct aa_profile *aa_get_newest_profile(struct aa_profile *p)
{ return labels_profile(aa_get_newest_label(&p->label));
}
staticinline aa_state_t RULE_MEDIATES_NET(struct aa_ruleset *rules)
{ /* can not use RULE_MEDIATE_v9AF here, because AF match fail * can not be distiguished from class match fail, and we only * fallback to checking older class on class match failure
*/
aa_state_t state = RULE_MEDIATES(rules, AA_CLASS_NETV9);
/* fallback and check v7/8 if v9 is NOT mediated */ if (!state)
state = RULE_MEDIATES(rules, AA_CLASS_NET);
/** * aa_get_profile - increment refcount on profile @p * @p: profile (MAYBE NULL) * * Returns: pointer to @p if @p is NULL will return NULL * Requires: @p must be held with valid refcount when called
*/ staticinlinestruct aa_profile *aa_get_profile(struct aa_profile *p)
{ if (p)
kref_get(&(p->label.count));
return p;
}
/** * aa_get_profile_not0 - increment refcount on profile @p found via lookup * @p: profile (MAYBE NULL) * * Returns: pointer to @p if @p is NULL will return NULL * Requires: @p must be held with valid refcount when called
*/ staticinlinestruct aa_profile *aa_get_profile_not0(struct aa_profile *p)
{ if (p && kref_get_unless_zero(&p->label.count)) return p;
return NULL;
}
/** * aa_get_profile_rcu - increment a refcount profile that can be replaced * @p: pointer to profile that can be replaced (NOT NULL) * * Returns: pointer to a refcounted profile. * else NULL if no profile
*/ staticinlinestruct aa_profile *aa_get_profile_rcu(struct aa_profile __rcu **p)
{ struct aa_profile *c;
rcu_read_lock(); do {
c = rcu_dereference(*p);
} while (c && !kref_get_unless_zero(&c->label.count));
rcu_read_unlock();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.