/** * get_current_exe - Get the current's executable path, if any * * @exe_str: Returned pointer to a path string with a lifetime tied to the * returned buffer, if any. * @exe_size: Returned size of @exe_str (including the trailing null * character), if any. * * Returns: A pointer to an allocated buffer where @exe_str point to, %NULL if * there is no executable path, or an error otherwise.
*/ staticconstvoid *get_current_exe(constchar **const exe_str,
size_t *const exe_size)
{ const size_t buffer_size = LANDLOCK_PATH_MAX_SIZE; struct mm_struct *mm = current->mm; struct file *file __free(fput) = NULL; char *buffer __free(kfree) = NULL; constchar *exe;
ssize_t size;
if (!mm) return NULL;
file = get_mm_exe_file(mm); if (!file) return NULL;
buffer = kmalloc(buffer_size, GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM);
exe = d_path(&file->f_path, buffer, buffer_size); if (WARN_ON_ONCE(IS_ERR(exe))) /* Should never happen according to LANDLOCK_PATH_MAX_SIZE. */ return ERR_CAST(exe);
buffer = get_current_exe(&path_str, &path_size); if (IS_ERR(buffer)) return ERR_CAST(buffer);
/* * Create the new details according to the path's length. Do not * allocate with GFP_KERNEL_ACCOUNT because it is independent from the * caller.
*/
details =
kzalloc(struct_size(details, exe_path, path_size), GFP_KERNEL); if (!details) return ERR_PTR(-ENOMEM);
/** * landlock_init_hierarchy_log - Partially initialize landlock_hierarchy * * @hierarchy: The hierarchy to initialize. * * The current task is referenced as the domain that is enforcing the * restriction. The subjective credentials must not be in an overridden state. * * @hierarchy->parent and @hierarchy->usage should already be set.
*/ int landlock_init_hierarchy_log(struct landlock_hierarchy *const hierarchy)
{ struct landlock_details *details;
details = get_current_details(); if (IS_ERR(details)) return PTR_ERR(details);
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.