mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-17 17:53:56 +08:00
cb2c7d1a17
Using Landlock objects and ruleset, it is possible to tag inodes according to a process's domain. To enable an unprivileged process to express a file hierarchy, it first needs to open a directory (or a file) and pass this file descriptor to the kernel through landlock_add_rule(2). When checking if a file access request is allowed, we walk from the requested dentry to the real root, following the different mount layers. The access to each "tagged" inodes are collected according to their rule layer level, and ANDed to create access to the requested file hierarchy. This makes possible to identify a lot of files without tagging every inodes nor modifying the filesystem, while still following the view and understanding the user has from the filesystem. Add a new ARCH_EPHEMERAL_INODES for UML because it currently does not keep the same struct inodes for the same inodes whereas these inodes are in use. This commit adds a minimal set of supported filesystem access-control which doesn't enable to restrict all file-related actions. This is the result of multiple discussions to minimize the code of Landlock to ease review. Thanks to the Landlock design, extending this access-control without breaking user space will not be a problem. Moreover, seccomp filters can be used to restrict the use of syscall families which may not be currently handled by Landlock. Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: James Morris <jmorris@namei.org> Cc: Jann Horn <jannh@google.com> Cc: Jeff Dike <jdike@addtoit.com> Cc: Kees Cook <keescook@chromium.org> Cc: Richard Weinberger <richard@nod.at> Cc: Serge E. Hallyn <serge@hallyn.com> Signed-off-by: Mickaël Salaün <mic@linux.microsoft.com> Link: https://lore.kernel.org/r/20210422154123.13086-8-mic@digikod.net Signed-off-by: James Morris <jamorris@linux.microsoft.com>
41 lines
944 B
C
41 lines
944 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Landlock LSM - Security framework setup
|
|
*
|
|
* Copyright © 2016-2020 Mickaël Salaün <mic@digikod.net>
|
|
* Copyright © 2018-2020 ANSSI
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/lsm_hooks.h>
|
|
|
|
#include "common.h"
|
|
#include "cred.h"
|
|
#include "fs.h"
|
|
#include "ptrace.h"
|
|
#include "setup.h"
|
|
|
|
bool landlock_initialized __lsm_ro_after_init = false;
|
|
|
|
struct lsm_blob_sizes landlock_blob_sizes __lsm_ro_after_init = {
|
|
.lbs_cred = sizeof(struct landlock_cred_security),
|
|
.lbs_inode = sizeof(struct landlock_inode_security),
|
|
.lbs_superblock = sizeof(struct landlock_superblock_security),
|
|
};
|
|
|
|
static int __init landlock_init(void)
|
|
{
|
|
landlock_add_cred_hooks();
|
|
landlock_add_ptrace_hooks();
|
|
landlock_add_fs_hooks();
|
|
landlock_initialized = true;
|
|
pr_info("Up and running.\n");
|
|
return 0;
|
|
}
|
|
|
|
DEFINE_LSM(LANDLOCK_NAME) = {
|
|
.name = LANDLOCK_NAME,
|
|
.init = landlock_init,
|
|
.blobs = &landlock_blob_sizes,
|
|
};
|