// SPDX-License-Identifier: GPL-2.0-only1/*2* Copyright (C) 2008 IBM Corporation3*4* Authors:5* Mimi Zohar <[email protected]>6*7* File: integrity_iint.c8* - initialize the integrity directory in securityfs9* - load IMA and EVM keys10*/11#include <linux/security.h>12#include "integrity.h"1314struct dentry *integrity_dir;1516/*17* integrity_kernel_read - read data from the file18*19* This is a function for reading file content instead of kernel_read().20* It does not perform locking checks to ensure it cannot be blocked.21* It does not perform security checks because it is irrelevant for IMA.22*23*/24int integrity_kernel_read(struct file *file, loff_t offset,25void *addr, unsigned long count)26{27return __kernel_read(file, addr, count, &offset);28}2930/*31* integrity_load_keys - load integrity keys hook32*33* Hooks is called from init/main.c:kernel_init_freeable()34* when rootfs is ready35*/36void __init integrity_load_keys(void)37{38ima_load_x509();3940if (!IS_ENABLED(CONFIG_IMA_LOAD_X509))41evm_load_x509();42}4344static int __init integrity_fs_init(void)45{46integrity_dir = securityfs_create_dir("integrity", NULL);47if (IS_ERR(integrity_dir)) {48int ret = PTR_ERR(integrity_dir);4950if (ret != -ENODEV)51pr_err("Unable to create integrity sysfs dir: %d\n",52ret);53integrity_dir = NULL;54return ret;55}5657return 0;58}5960late_initcall(integrity_fs_init)616263