blob: f8e8e980454c40a3b16ccd1f8b366a3e42ab866e [file] [log] [blame]
Mickaël Salaün385975d2021-04-22 17:41:13 +02001// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Landlock LSM - Security framework setup
4 *
5 * Copyright © 2016-2020 Mickaël Salaün <mic@digikod.net>
6 * Copyright © 2018-2020 ANSSI
7 */
8
9#include <linux/init.h>
10#include <linux/lsm_hooks.h>
11
12#include "common.h"
13#include "cred.h"
Mickaël Salaüncb2c7d12021-04-22 17:41:17 +020014#include "fs.h"
Mickaël Salaünafe81f72021-04-22 17:41:14 +020015#include "ptrace.h"
Mickaël Salaün385975d2021-04-22 17:41:13 +020016#include "setup.h"
17
Mickaël Salaüncb2c7d12021-04-22 17:41:17 +020018bool landlock_initialized __lsm_ro_after_init = false;
19
Mickaël Salaün385975d2021-04-22 17:41:13 +020020struct lsm_blob_sizes landlock_blob_sizes __lsm_ro_after_init = {
21 .lbs_cred = sizeof(struct landlock_cred_security),
Mickaël Salaüncb2c7d12021-04-22 17:41:17 +020022 .lbs_inode = sizeof(struct landlock_inode_security),
23 .lbs_superblock = sizeof(struct landlock_superblock_security),
Mickaël Salaün385975d2021-04-22 17:41:13 +020024};
25
26static int __init landlock_init(void)
27{
28 landlock_add_cred_hooks();
Mickaël Salaünafe81f72021-04-22 17:41:14 +020029 landlock_add_ptrace_hooks();
Mickaël Salaüncb2c7d12021-04-22 17:41:17 +020030 landlock_add_fs_hooks();
31 landlock_initialized = true;
Mickaël Salaün385975d2021-04-22 17:41:13 +020032 pr_info("Up and running.\n");
33 return 0;
34}
35
36DEFINE_LSM(LANDLOCK_NAME) = {
37 .name = LANDLOCK_NAME,
38 .init = landlock_init,
39 .blobs = &landlock_blob_sizes,
40};