case LANDLOCK_REQUEST_FS_CHANGE_TOPOLOGY:
WARN_ON_ONCE(access_bit != -1); return"fs.change_topology";
case LANDLOCK_REQUEST_FS_ACCESS: if (WARN_ON_ONCE(access_bit >= ARRAY_SIZE(fs_access_strings))) return"unknown"; return fs_access_strings[access_bit];
case LANDLOCK_REQUEST_NET_ACCESS: if (WARN_ON_ONCE(access_bit >= ARRAY_SIZE(net_access_strings))) return"unknown"; return net_access_strings[access_bit];
case LANDLOCK_REQUEST_SCOPE_ABSTRACT_UNIX_SOCKET:
WARN_ON_ONCE(access_bit != -1); return"scope.abstract_unix_socket";
case LANDLOCK_REQUEST_SCOPE_SIGNAL:
WARN_ON_ONCE(access_bit != -1); return"scope.signal";
}
/* * There may be race condition leading to logging of the same domain * several times but that is OK.
*/
WRITE_ONCE(hierarchy->log_status, LANDLOCK_LOG_RECORDED);
}
if (WARN_ON_ONCE(!(!!request->layer_plus_one ^ !!request->access))) returnfalse;
if (request->access) { if (WARN_ON_ONCE(!(!!request->layer_masks ^
!!request->all_existing_optional_access))) returnfalse;
} else { if (WARN_ON_ONCE(request->layer_masks ||
request->all_existing_optional_access)) returnfalse;
}
if (WARN_ON_ONCE(!!request->layer_masks ^ !!request->layer_masks_size)) returnfalse;
if (request->deny_masks) { if (WARN_ON_ONCE(!request->all_existing_optional_access)) returnfalse;
}
returntrue;
}
/** * landlock_log_denial - Create audit records related to a denial * * @subject: The Landlock subject's credential denying an action. * @request: Detail of the user space request.
*/ void landlock_log_denial(conststruct landlock_cred_security *const subject, conststruct landlock_request *const request)
{ struct audit_buffer *ab; struct landlock_hierarchy *youngest_denied;
size_t youngest_layer;
access_mask_t missing;
if (WARN_ON_ONCE(!subject || !subject->domain ||
!subject->domain->hierarchy || !request)) return;
if (READ_ONCE(youngest_denied->log_status) == LANDLOCK_LOG_DISABLED) return;
/* * Consistently keeps track of the number of denied access requests * even if audit is currently disabled, or if audit rules currently * exclude this record type, or if landlock_restrict_self(2)'s flags * quiet logs.
*/
atomic64_inc(&youngest_denied->num_denials);
if (!audit_enabled) return;
/* Checks if the current exec was restricting itself. */ if (subject->domain_exec & BIT(youngest_layer)) { /* Ignores denials for the same execution. */ if (!youngest_denied->log_same_exec) return;
} else { /* Ignores denials after a new execution. */ if (!youngest_denied->log_new_exec) return;
}
/* Uses consistent allocation flags wrt common_lsm_audit(). */
ab = audit_log_start(audit_context(), GFP_ATOMIC | __GFP_NOWARN,
AUDIT_LANDLOCK_ACCESS); if (!ab) return;
/* Logs this domain the first time it shows in log. */
log_domain(youngest_denied);
}
/** * landlock_log_drop_domain - Create an audit record on domain deallocation * * @hierarchy: The domain's hierarchy being deallocated. * * Only domains which previously appeared in the audit logs are logged again. * This is useful to know when a domain will never show again in the audit log. * * Called in a work queue scheduled by landlock_put_ruleset_deferred() called * by hook_cred_free().
*/ void landlock_log_drop_domain(conststruct landlock_hierarchy *const hierarchy)
{ struct audit_buffer *ab;
if (WARN_ON_ONCE(!hierarchy)) return;
if (!audit_enabled) return;
/* Ignores domains that were not logged. */ if (READ_ONCE(hierarchy->log_status) != LANDLOCK_LOG_RECORDED) return;
/* * If logging of domain allocation succeeded, warns about failure to log * domain deallocation to highlight unbalanced domain lifetime logs.
*/
ab = audit_log_start(audit_context(), GFP_KERNEL,
AUDIT_LANDLOCK_DOMAIN); if (!ab) return;
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.