]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - security/integrity/integrity.h
ima: per hook cache integrity appraisal status
[mirror_ubuntu-artful-kernel.git] / security / integrity / integrity.h
CommitLineData
f381c272
MZ
1/*
2 * Copyright (C) 2009-2010 IBM Corporation
3 *
4 * Authors:
5 * Mimi Zohar <zohar@us.ibm.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2 of the
10 * License.
11 *
12 */
13
14#include <linux/types.h>
15#include <linux/integrity.h>
16#include <crypto/sha.h>
17
45e2472e 18/* iint action cache flags */
f578c08e
MZ
19#define IMA_MEASURE 0x00000001
20#define IMA_MEASURED 0x00000002
21#define IMA_APPRAISE 0x00000004
22#define IMA_APPRAISED 0x00000008
23/*#define IMA_COLLECT 0x00000010 do not use this flag */
24#define IMA_COLLECTED 0x00000020
25#define IMA_AUDIT 0x00000040
26#define IMA_AUDITED 0x00000080
45e2472e 27
f381c272 28/* iint cache flags */
f578c08e
MZ
29#define IMA_ACTION_FLAGS 0xff000000
30#define IMA_DIGSIG 0x01000000
31#define IMA_DIGSIG_REQUIRED 0x02000000
45e2472e 32
d79d72e0
MZ
33#define IMA_DO_MASK (IMA_MEASURE | IMA_APPRAISE | IMA_AUDIT | \
34 IMA_APPRAISE_SUBMASK)
35#define IMA_DONE_MASK (IMA_MEASURED | IMA_APPRAISED | IMA_AUDITED | \
36 IMA_COLLECTED | IMA_APPRAISED_SUBMASK)
37
38/* iint subaction appraise cache flags */
39#define IMA_FILE_APPRAISE 0x00000100
40#define IMA_FILE_APPRAISED 0x00000200
41#define IMA_MMAP_APPRAISE 0x00000400
42#define IMA_MMAP_APPRAISED 0x00000800
43#define IMA_BPRM_APPRAISE 0x00001000
44#define IMA_BPRM_APPRAISED 0x00002000
45#define IMA_MODULE_APPRAISE 0x00004000
46#define IMA_MODULE_APPRAISED 0x00008000
47#define IMA_APPRAISE_SUBMASK (IMA_FILE_APPRAISE | IMA_MMAP_APPRAISE | \
48 IMA_BPRM_APPRAISE | IMA_MODULE_APPRAISE)
49#define IMA_APPRAISED_SUBMASK (IMA_FILE_APPRAISED | IMA_MMAP_APPRAISED | \
50 IMA_BPRM_APPRAISED | IMA_MODULE_APPRAISED)
f381c272 51
6be5cc52
DK
52enum evm_ima_xattr_type {
53 IMA_XATTR_DIGEST = 0x01,
54 EVM_XATTR_HMAC,
55 EVM_IMA_XATTR_DIGSIG,
56};
57
58struct evm_ima_xattr_data {
59 u8 type;
60 u8 digest[SHA1_DIGEST_SIZE];
61} __attribute__((packed));
62
f381c272
MZ
63/* integrity data associated with an inode */
64struct integrity_iint_cache {
65 struct rb_node rb_node; /* rooted in integrity_iint_tree */
66 struct inode *inode; /* back pointer to inode in question */
67 u64 version; /* track inode changes */
f578c08e 68 unsigned long flags;
5a44b412 69 struct evm_ima_xattr_data ima_xattr;
d79d72e0
MZ
70 enum integrity_status ima_file_status:4;
71 enum integrity_status ima_mmap_status:4;
72 enum integrity_status ima_bprm_status:4;
73 enum integrity_status ima_module_status:4;
ee866331 74 enum integrity_status evm_status:4;
f381c272
MZ
75};
76
77/* rbtree tree calls to lookup, insert, delete
78 * integrity data associated with an inode.
79 */
80struct integrity_iint_cache *integrity_iint_insert(struct inode *inode);
81struct integrity_iint_cache *integrity_iint_find(struct inode *inode);
4892722e 82
8607c501
DK
83#define INTEGRITY_KEYRING_EVM 0
84#define INTEGRITY_KEYRING_MODULE 1
85#define INTEGRITY_KEYRING_IMA 2
86#define INTEGRITY_KEYRING_MAX 3
87
f1be242c 88#ifdef CONFIG_INTEGRITY_SIGNATURE
8607c501
DK
89
90int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
91 const char *digest, int digestlen);
92
93#else
94
95static inline int integrity_digsig_verify(const unsigned int id,
96 const char *sig, int siglen,
97 const char *digest, int digestlen)
98{
99 return -EOPNOTSUPP;
100}
101
f1be242c 102#endif /* CONFIG_INTEGRITY_SIGNATURE */
8607c501 103
4892722e
JM
104/* set during initialization */
105extern int iint_initialized;