/** * struct landlock_cred_security - Credential security blob * * This structure is packed to minimize the size of struct * landlock_file_security. However, it is always aligned in the LSM cred blob, * see lsm_set_blob_size().
*/ struct landlock_cred_security { /** * @domain: Immutable ruleset enforced on a task.
*/ struct landlock_ruleset *domain;
#ifdef CONFIG_AUDIT /** * @domain_exec: Bitmask identifying the domain layers that were enforced by * the current task's executed file (i.e. no new execve(2) since * landlock_restrict_self(2)).
*/
u16 domain_exec; /** * @log_subdomains_off: Set if the domain descendants's log_status should be * set to %LANDLOCK_LOG_DISABLED. This is not a landlock_hierarchy * configuration because it applies to future descendant domains and it does * not require a current domain.
*/
u8 log_subdomains_off : 1; #endif/* CONFIG_AUDIT */
} __packed;
#ifdef CONFIG_AUDIT
/* Makes sure all layer executions can be stored. */
static_assert(BITS_PER_TYPE(typeof_member(struct landlock_cred_security,
domain_exec)) >=
LANDLOCK_MAX_NUM_LAYERS);
/* * The call needs to come from an RCU read-side critical section.
*/ staticinlineconststruct landlock_ruleset *
landlock_get_task_domain(conststruct task_struct *const task)
{ return landlock_cred(__task_cred(task))->domain;
}
/** * landlock_get_applicable_subject - Return the subject's Landlock credential * if its enforced domain applies to (i.e. * handles) at least one of the access rights * specified in @masks * * @cred: credential * @masks: access masks * @handle_layer: returned youngest layer handling a subset of @masks. Not set * if the function returns NULL. * * Returns: landlock_cred(@cred) if any access rights specified in @masks is * handled, or NULL otherwise.
*/ staticinlineconststruct landlock_cred_security *
landlock_get_applicable_subject(conststruct cred *const cred, conststruct access_masks masks,
size_t *const handle_layer)
{ constunion access_masks_all masks_all = {
.masks = masks,
}; conststruct landlock_ruleset *domain;
ssize_t layer_level;
if (!cred) return NULL;
domain = landlock_cred(cred)->domain; if (!domain) return NULL;
for (layer_level = domain->num_layers - 1; layer_level >= 0;
layer_level--) { union access_masks_all layer = {
.masks = domain->access_masks[layer_level],
};
if (layer.all & masks_all.all) { if (handle_layer)
*handle_layer = layer_level;
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.