2019-06-01 08:08:55 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2011-03-09 19:13:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 IBM Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Mimi Zohar <zohar@us.ibm.com>
|
|
|
|
*
|
|
|
|
* File: integrity_iint.c
|
2024-02-15 10:31:13 +00:00
|
|
|
* - initialize the integrity directory in securityfs
|
|
|
|
* - load IMA and EVM keys
|
2011-03-09 19:13:22 +00:00
|
|
|
*/
|
2018-05-11 23:12:34 +00:00
|
|
|
#include <linux/security.h>
|
2011-03-09 19:13:22 +00:00
|
|
|
#include "integrity.h"
|
|
|
|
|
2018-05-11 23:12:34 +00:00
|
|
|
struct dentry *integrity_dir;
|
|
|
|
|
2014-11-05 15:01:12 +00:00
|
|
|
/*
|
|
|
|
* integrity_kernel_read - read data from the file
|
|
|
|
*
|
|
|
|
* This is a function for reading file content instead of kernel_read().
|
|
|
|
* It does not perform locking checks to ensure it cannot be blocked.
|
|
|
|
* It does not perform security checks because it is irrelevant for IMA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int integrity_kernel_read(struct file *file, loff_t offset,
|
2017-06-08 01:49:10 +00:00
|
|
|
void *addr, unsigned long count)
|
2014-11-05 15:01:12 +00:00
|
|
|
{
|
2020-05-08 06:54:27 +00:00
|
|
|
return __kernel_read(file, addr, count, &offset);
|
2014-11-05 15:01:12 +00:00
|
|
|
}
|
|
|
|
|
2014-11-05 15:01:15 +00:00
|
|
|
/*
|
|
|
|
* integrity_load_keys - load integrity keys hook
|
|
|
|
*
|
|
|
|
* Hooks is called from init/main.c:kernel_init_freeable()
|
|
|
|
* when rootfs is ready
|
|
|
|
*/
|
|
|
|
void __init integrity_load_keys(void)
|
|
|
|
{
|
|
|
|
ima_load_x509();
|
2021-05-14 15:27:43 +00:00
|
|
|
|
|
|
|
if (!IS_ENABLED(CONFIG_IMA_LOAD_X509))
|
|
|
|
evm_load_x509();
|
2014-11-05 15:01:15 +00:00
|
|
|
}
|
2018-05-11 23:12:34 +00:00
|
|
|
|
|
|
|
static int __init integrity_fs_init(void)
|
|
|
|
{
|
|
|
|
integrity_dir = securityfs_create_dir("integrity", NULL);
|
|
|
|
if (IS_ERR(integrity_dir)) {
|
2018-06-05 10:25:45 +00:00
|
|
|
int ret = PTR_ERR(integrity_dir);
|
|
|
|
|
|
|
|
if (ret != -ENODEV)
|
|
|
|
pr_err("Unable to create integrity sysfs dir: %d\n",
|
|
|
|
ret);
|
2018-05-11 23:12:34 +00:00
|
|
|
integrity_dir = NULL;
|
2018-06-05 10:25:45 +00:00
|
|
|
return ret;
|
2018-05-11 23:12:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
late_initcall(integrity_fs_init)
|