#define LOCAL_VEC_ENTRIES 8 #define DEFINE_VEC(T, V) \ struct aa_ ## T *(_ ## V ## _localtmp)[LOCAL_VEC_ENTRIES]; \ struct aa_ ## T **(V)
#define vec_setup(T, V, N, GFP) \
({ \ if ((N) <= LOCAL_VEC_ENTRIES) { \
typeof(N) i; \
(V) = (_ ## V ## _localtmp); \ for (i = 0; i < (N); i++) \
(V)[i] = NULL; \
} else \
(V) = kzalloc(sizeof(struct aa_ ## T *) * (N), (GFP)); \
(V) ? 0 : -ENOMEM; \
})
#define vec_cleanup(T, V, N) \ do { \ int i; \ for (i = 0; i < (N); i++) { \ if (!IS_ERR_OR_NULL((V)[i])) \
aa_put_ ## T((V)[i]); \
} \ if ((V) != _ ## V ## _localtmp) \
kfree(V); \
} while (0)
struct aa_profile; #define VEC_FLAG_TERMINATE 1 int aa_vec_unique(struct aa_profile **vec, int n, int flags); struct aa_label *aa_vec_find_or_create_label(struct aa_profile **vec, int len,
gfp_t gfp); #define aa_sort_and_merge_vec(N, V) \
aa_sort_and_merge_profiles((N), (struct aa_profile **)(V))
/* struct aa_labelset - set of labels for a namespace * * Labels are reference counted; aa_labelset does not contribute to label * reference counts. Once a label's last refcount is put it is removed from * the set.
*/ struct aa_labelset {
rwlock_t lock;
/* struct aa_label_base - base info of label * @count: ref count of active users * @node: rbtree position * @rcu: rcu callback struct * @proxy: is set to the label that replaced this label * @hname: text representation of the label (MAYBE_NULL) * @flags: stale and other flags - values may change under label set lock * @secid: secid that references this label * @size: number of entries in @ent[] * @mediates: bitmask for label_mediates * profile: label vec when embedded in a profile FLAG_PROFILE is set * rules: variable length rules in a profile FLAG_PROFILE is set * vec: vector of profiles comprising the compound label
*/ struct aa_label { struct kref count; struct rb_node node; struct rcu_head rcu; struct aa_proxy *proxy;
__counted char *hname; long flags;
u32 secid; int size;
u64 mediates; union { struct { /* only used is the label is a profile, size of * rules[] is determined by the profile * profile[1] is poison or null as guard
*/ struct aa_profile *profile[2];
DECLARE_FLEX_ARRAY(struct aa_ruleset *, rules);
};
DECLARE_FLEX_ARRAY(struct aa_profile *, vec);
};
};
#define last_error(E, FN) \ do { \ int __subE = (FN); \ if (__subE) \
(E) = __subE; \
} while (0)
/* for each profile that is enforcing confinement in a label */ #define label_for_each_confined(I, L, P) \ for ((I).i = aa_label_next_confined((L), 0); \
((P) = (L)->vec[(I).i]); \
(I).i = aa_label_next_confined((L), (I).i + 1))
#define label_for_each_in_merge(I, A, B, P) \ for ((I).i = (I).j = 0; \
((P) = aa_label_next_in_merge(&(I), (A), (B))); \
)
/** * __aa_get_label - get a reference count to uncounted label reference * @l: reference to get a count on * * Returns: pointer to reference OR NULL if race is lost and reference is * being repeated. * Requires: lock held, and the return code MUST be checked
*/ staticinlinestruct aa_label *__aa_get_label(struct aa_label *l)
{ if (l && kref_get_unless_zero(&l->count)) return l;
return NULL;
}
staticinlinestruct aa_label *aa_get_label(struct aa_label *l)
{ if (l)
kref_get(&(l->count));
return l;
}
/** * aa_get_label_rcu - increment refcount on a label that can be replaced * @l: pointer to label that can be replaced (NOT NULL) * * Returns: pointer to a refcounted label. * else NULL if no label
*/ staticinlinestruct aa_label *aa_get_label_rcu(struct aa_label __rcu **l)
{ struct aa_label *c;
rcu_read_lock(); do {
c = rcu_dereference(*l);
} while (c && !kref_get_unless_zero(&c->count));
rcu_read_unlock();
return c;
}
/** * aa_get_newest_label - find the newest version of @l * @l: the label to check for newer versions of * * Returns: refcounted newest version of @l taking into account * replacement, renames and removals * return @l.
*/ staticinlinestruct aa_label *aa_get_newest_label(struct aa_label *l)
{ if (!l) return NULL;
if (label_is_stale(l)) { struct aa_label *tmp;
AA_BUG(!l->proxy);
AA_BUG(!l->proxy->label); /* BUG: only way this can happen is @l ref count and its * replacement count have gone to 0 and are on their way * to destruction. ie. we have a refcounting error
*/
tmp = aa_get_label_rcu(&l->proxy->label);
AA_BUG(!tmp);
return tmp;
}
return aa_get_label(l);
}
staticinlinevoid aa_put_label(struct aa_label *l)
{ if (l)
kref_put(&l->count, aa_label_kref);
}
/* wrapper fn to indicate semantics of the check */ staticinlinebool __aa_subj_label_is_cached(struct aa_label *subj_label, struct aa_label *obj_label)
{ return aa_label_is_subset(obj_label, subj_label);
}
¤ 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.0.11Bemerkung:
(vorverarbeitet)
¤
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.