#include <linux/init.h>
#include <linux/list.h>
#include <linux/kernel_read_file.h>
#include <linux/fs.h>
#include <linux/security.h>
#include <linux/magic.h>
#include <linux/parser.h>
#include <linux/slab.h>
#include <linux/rculist.h>
#include <linux/seq_file.h>
#include <linux/ima.h>
#include "ima.h"
#define IMA_FUNC …
#define IMA_MASK …
#define IMA_FSMAGIC …
#define IMA_UID …
#define IMA_FOWNER …
#define IMA_FSUUID …
#define IMA_INMASK …
#define IMA_EUID …
#define IMA_PCR …
#define IMA_FSNAME …
#define IMA_KEYRINGS …
#define IMA_LABEL …
#define IMA_VALIDATE_ALGOS …
#define IMA_GID …
#define IMA_EGID …
#define IMA_FGROUP …
#define UNKNOWN …
#define MEASURE …
#define DONT_MEASURE …
#define APPRAISE …
#define DONT_APPRAISE …
#define AUDIT …
#define HASH …
#define DONT_HASH …
#define INVALID_PCR(a) …
int ima_policy_flag;
static int temp_ima_appraise;
static int build_ima_appraise __ro_after_init;
atomic_t ima_setxattr_allowed_hash_algorithms;
#define MAX_LSM_RULES …
enum lsm_rule_types { … };
enum policy_types { … };
enum policy_rule_list { … };
struct ima_rule_opt_list { … };
static inline bool vfsuid_gt_kuid(vfsuid_t vfsuid, kuid_t kuid)
{ … }
static inline bool vfsgid_gt_kgid(vfsgid_t vfsgid, kgid_t kgid)
{ … }
static inline bool vfsuid_lt_kuid(vfsuid_t vfsuid, kuid_t kuid)
{ … }
static inline bool vfsgid_lt_kgid(vfsgid_t vfsgid, kgid_t kgid)
{ … }
struct ima_rule_entry { … };
static_assert(…);
static struct ima_rule_entry dont_measure_rules[] __ro_after_init = …;
static struct ima_rule_entry original_measurement_rules[] __ro_after_init = …;
static struct ima_rule_entry default_measurement_rules[] __ro_after_init = …;
static struct ima_rule_entry default_appraise_rules[] __ro_after_init = …;
static struct ima_rule_entry build_appraise_rules[] __ro_after_init = …;
static struct ima_rule_entry secure_boot_rules[] __ro_after_init = …;
static struct ima_rule_entry critical_data_rules[] __ro_after_init = …;
static struct ima_rule_entry *arch_policy_entry __ro_after_init;
static LIST_HEAD(ima_default_rules);
static LIST_HEAD(ima_policy_rules);
static LIST_HEAD(ima_temp_rules);
static struct list_head __rcu *ima_rules = …;
static int ima_policy __initdata;
static int __init default_measure_policy_setup(char *str)
{ … }
__setup(…);
static bool ima_use_appraise_tcb __initdata;
static bool ima_use_secure_boot __initdata;
static bool ima_use_critical_data __initdata;
static bool ima_fail_unverifiable_sigs __ro_after_init;
static int __init policy_setup(char *str)
{ … }
__setup(…);
static int __init default_appraise_policy_setup(char *str)
{ … }
__setup(…);
static struct ima_rule_opt_list *ima_alloc_rule_opt_list(const substring_t *src)
{ … }
static void ima_free_rule_opt_list(struct ima_rule_opt_list *opt_list)
{ … }
static void ima_lsm_free_rule(struct ima_rule_entry *entry)
{ … }
static void ima_free_rule(struct ima_rule_entry *entry)
{ … }
static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry,
gfp_t gfp)
{ … }
static int ima_lsm_update_rule(struct ima_rule_entry *entry)
{ … }
static bool ima_rule_contains_lsm_cond(struct ima_rule_entry *entry)
{ … }
static void ima_lsm_update_rules(void)
{ … }
int ima_lsm_policy_change(struct notifier_block *nb, unsigned long event,
void *lsm_data)
{ … }
static bool ima_match_rule_data(struct ima_rule_entry *rule,
const char *func_data,
const struct cred *cred)
{ … }
static bool ima_match_rules(struct ima_rule_entry *rule,
struct mnt_idmap *idmap,
struct inode *inode, const struct cred *cred,
u32 secid, enum ima_hooks func, int mask,
const char *func_data)
{ … }
static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func)
{ … }
int ima_match_policy(struct mnt_idmap *idmap, struct inode *inode,
const struct cred *cred, u32 secid, enum ima_hooks func,
int mask, int flags, int *pcr,
struct ima_template_desc **template_desc,
const char *func_data, unsigned int *allowed_algos)
{ … }
void ima_update_policy_flags(void)
{ … }
static int ima_appraise_flag(enum ima_hooks func)
{ … }
static void add_rules(struct ima_rule_entry *entries, int count,
enum policy_rule_list policy_rule)
{ … }
static int ima_parse_rule(char *rule, struct ima_rule_entry *entry);
static int __init ima_init_arch_policy(void)
{ … }
void __init ima_init_policy(void)
{ … }
int ima_check_policy(void)
{ … }
void ima_update_policy(void)
{ … }
enum policy_opt { … };
static const match_table_t policy_tokens = …;
static int ima_lsm_rule_init(struct ima_rule_entry *entry,
substring_t *args, int lsm_rule, int audit_type)
{ … }
static void ima_log_string_op(struct audit_buffer *ab, char *key, char *value,
enum policy_opt rule_operator)
{ … }
static void ima_log_string(struct audit_buffer *ab, char *key, char *value)
{ … }
static void check_template_modsig(const struct ima_template_desc *template)
{ … }
static void check_template_field(const struct ima_template_desc *template,
const char *field, const char *msg)
{ … }
static bool ima_validate_rule(struct ima_rule_entry *entry)
{ … }
static unsigned int ima_parse_appraise_algos(char *arg)
{ … }
static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
{ … }
ssize_t ima_parse_add_rule(char *rule)
{ … }
void ima_delete_rules(void)
{ … }
#define __ima_hook_stringify(func, str) …
const char *const func_tokens[] = …;
#ifdef CONFIG_IMA_READ_POLICY
enum { … };
static const char *const mask_tokens[] = …;
void *ima_policy_start(struct seq_file *m, loff_t *pos)
{ … }
void *ima_policy_next(struct seq_file *m, void *v, loff_t *pos)
{ … }
void ima_policy_stop(struct seq_file *m, void *v)
{ … }
#define pt(token) …
#define mt(token) …
static void policy_func_show(struct seq_file *m, enum ima_hooks func)
{ … }
static void ima_show_rule_opt_list(struct seq_file *m,
const struct ima_rule_opt_list *opt_list)
{ … }
static void ima_policy_show_appraise_algos(struct seq_file *m,
unsigned int allowed_hashes)
{ … }
int ima_policy_show(struct seq_file *m, void *v)
{ … }
#endif
#if defined(CONFIG_IMA_APPRAISE) && defined(CONFIG_INTEGRITY_TRUSTED_KEYRING)
bool ima_appraise_signature(enum kernel_read_file_id id)
{ … }
#endif