/** * audit_resource - audit setting resource limit * @subj_cred: cred setting the resource * @profile: profile being enforced (NOT NULL) * @resource: rlimit being auditing * @value: value being set * @peer: aa_albel of the task being set * @info: info being auditing * @error: error value * * Returns: 0 or ad->error else other error code on failure
*/ staticint audit_resource(conststruct cred *subj_cred, struct aa_profile *profile, unsignedint resource, unsignedlong value, struct aa_label *peer, constchar *info, int error)
{
DEFINE_AUDIT_DATA(ad, LSM_AUDIT_DATA_NONE, AA_CLASS_RLIMITS,
OP_SETRLIMIT);
/** * aa_map_resource - map compiled policy resource to internal # * @resource: flattened policy resource number * * Returns: resource # for the current architecture. * * rlimit resource can vary based on architecture, map the compiled policy * resource # to the internal representation for the architecture.
*/ int aa_map_resource(int resource)
{ return rlim_map[resource];
}
/** * aa_task_setrlimit - test permission to set an rlimit * @subj_cred: cred setting the limit * @label: label confining the task (NOT NULL) * @task: task the resource is being set on * @resource: the resource being set * @new_rlim: the new resource limit (NOT NULL) * * Control raising the processes hard limit. * * Returns: 0 or error code if setting resource failed
*/ int aa_task_setrlimit(conststruct cred *subj_cred, struct aa_label *label, struct task_struct *task, unsignedint resource, struct rlimit *new_rlim)
{ struct aa_profile *profile; struct aa_label *peer; int error = 0;
/* TODO: extend resource control to handle other (non current) * profiles. AppArmor rules currently have the implicit assumption * that the task is setting the resource of a task confined with * the same profile or that the task setting the resource of another * task has CAP_SYS_RESOURCE.
*/
/** * __aa_transition_rlimits - apply new profile rlimits * @old_l: old label on task (NOT NULL) * @new_l: new label with rlimits to apply (NOT NULL)
*/ void __aa_transition_rlimits(struct aa_label *old_l, struct aa_label *new_l)
{ unsignedint mask = 0; struct rlimit *rlim, *initrlim; struct aa_profile *old, *new; struct label_it i;
old = labels_profile(old_l); new = labels_profile(new_l);
/* for any rlimits the profile controlled, reset the soft limit * to the lesser of the tasks hard limit and the init tasks soft limit
*/
label_for_each_confined(i, old_l, old) { struct aa_ruleset *rules = old->label.rules[0]; if (rules->rlimits.mask) { int j;
/* set any new hard limits as dictated by the new profile */
label_for_each_confined(i, new_l, new) { struct aa_ruleset *rules = new->label.rules[0]; int j;
if (!rules->rlimits.mask) continue; for (j = 0, mask = 1; j < RLIM_NLIMITS; j++, mask <<= 1) { if (!(rules->rlimits.mask & mask)) continue;
rlim = current->signal->rlim + j;
rlim->rlim_max = min(rlim->rlim_max,
rules->rlimits.limits[j].rlim_max); /* soft limit should not exceed hard limit */
rlim->rlim_cur = min(rlim->rlim_cur, rlim->rlim_max);
}
}
}
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.