diff options
author | Sage Weil <sage@inktank.com> | 2013-08-15 14:11:45 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-08-15 14:11:45 -0400 |
commit | ee3e542fec6e69bc9fb668698889a37d93950ddf (patch) | |
tree | e74ee766a4764769ef1d3d45d266b4dea64101d3 /security/integrity | |
parent | fe2a801b50c0bb8039d627e5ae1fec249d10ff39 (diff) | |
parent | f1d6e17f540af37bb1891480143669ba7636c4cf (diff) |
Merge remote-tracking branch 'linus/master' into testing
Diffstat (limited to 'security/integrity')
-rw-r--r-- | security/integrity/Kconfig | 15 | ||||
-rw-r--r-- | security/integrity/Makefile | 1 | ||||
-rw-r--r-- | security/integrity/evm/evm_main.c | 15 | ||||
-rw-r--r-- | security/integrity/ima/Kconfig | 12 | ||||
-rw-r--r-- | security/integrity/ima/Makefile | 1 | ||||
-rw-r--r-- | security/integrity/ima/ima.h | 14 | ||||
-rw-r--r-- | security/integrity/ima/ima_main.c | 2 | ||||
-rw-r--r-- | security/integrity/integrity.h | 14 | ||||
-rw-r--r-- | security/integrity/integrity_audit.c (renamed from security/integrity/ima/ima_audit.c) | 12 |
9 files changed, 51 insertions, 35 deletions
diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig index 4bb3a775a996..245c6d92065b 100644 --- a/security/integrity/Kconfig +++ b/security/integrity/Kconfig | |||
@@ -17,6 +17,21 @@ config INTEGRITY_SIGNATURE | |||
17 | This is useful for evm and module keyrings, when keys are | 17 | This is useful for evm and module keyrings, when keys are |
18 | usually only added from initramfs. | 18 | usually only added from initramfs. |
19 | 19 | ||
20 | config INTEGRITY_AUDIT | ||
21 | bool "Enables integrity auditing support " | ||
22 | depends on INTEGRITY && AUDIT | ||
23 | default y | ||
24 | help | ||
25 | In addition to enabling integrity auditing support, this | ||
26 | option adds a kernel parameter 'integrity_audit', which | ||
27 | controls the level of integrity auditing messages. | ||
28 | 0 - basic integrity auditing messages (default) | ||
29 | 1 - additional integrity auditing messages | ||
30 | |||
31 | Additional informational integrity auditing messages would | ||
32 | be enabled by specifying 'integrity_audit=1' on the kernel | ||
33 | command line. | ||
34 | |||
20 | config INTEGRITY_ASYMMETRIC_KEYS | 35 | config INTEGRITY_ASYMMETRIC_KEYS |
21 | boolean "Enable asymmetric keys support" | 36 | boolean "Enable asymmetric keys support" |
22 | depends on INTEGRITY_SIGNATURE | 37 | depends on INTEGRITY_SIGNATURE |
diff --git a/security/integrity/Makefile b/security/integrity/Makefile index ebb6409b3fcb..0f9cffb1f9ad 100644 --- a/security/integrity/Makefile +++ b/security/integrity/Makefile | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_INTEGRITY) += integrity.o | 5 | obj-$(CONFIG_INTEGRITY) += integrity.o |
6 | obj-$(CONFIG_INTEGRITY_AUDIT) += integrity_audit.o | ||
6 | obj-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o | 7 | obj-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o |
7 | obj-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o | 8 | obj-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o |
8 | 9 | ||
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index cdbde1762189..df0fa451a871 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/crypto.h> | 18 | #include <linux/crypto.h> |
19 | #include <linux/audit.h> | ||
19 | #include <linux/xattr.h> | 20 | #include <linux/xattr.h> |
20 | #include <linux/integrity.h> | 21 | #include <linux/integrity.h> |
21 | #include <linux/evm.h> | 22 | #include <linux/evm.h> |
@@ -24,6 +25,9 @@ | |||
24 | 25 | ||
25 | int evm_initialized; | 26 | int evm_initialized; |
26 | 27 | ||
28 | static char *integrity_status_msg[] = { | ||
29 | "pass", "fail", "no_label", "no_xattrs", "unknown" | ||
30 | }; | ||
27 | char *evm_hmac = "hmac(sha1)"; | 31 | char *evm_hmac = "hmac(sha1)"; |
28 | char *evm_hash = "sha1"; | 32 | char *evm_hash = "sha1"; |
29 | int evm_hmac_version = CONFIG_EVM_HMAC_VERSION; | 33 | int evm_hmac_version = CONFIG_EVM_HMAC_VERSION; |
@@ -262,9 +266,15 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name, | |||
262 | if ((evm_status == INTEGRITY_PASS) || | 266 | if ((evm_status == INTEGRITY_PASS) || |
263 | (evm_status == INTEGRITY_NOXATTRS)) | 267 | (evm_status == INTEGRITY_NOXATTRS)) |
264 | return 0; | 268 | return 0; |
265 | return -EPERM; | 269 | goto out; |
266 | } | 270 | } |
267 | evm_status = evm_verify_current_integrity(dentry); | 271 | evm_status = evm_verify_current_integrity(dentry); |
272 | out: | ||
273 | if (evm_status != INTEGRITY_PASS) | ||
274 | integrity_audit_msg(AUDIT_INTEGRITY_METADATA, dentry->d_inode, | ||
275 | dentry->d_name.name, "appraise_metadata", | ||
276 | integrity_status_msg[evm_status], | ||
277 | -EPERM, 0); | ||
268 | return evm_status == INTEGRITY_PASS ? 0 : -EPERM; | 278 | return evm_status == INTEGRITY_PASS ? 0 : -EPERM; |
269 | } | 279 | } |
270 | 280 | ||
@@ -357,6 +367,9 @@ int evm_inode_setattr(struct dentry *dentry, struct iattr *attr) | |||
357 | if ((evm_status == INTEGRITY_PASS) || | 367 | if ((evm_status == INTEGRITY_PASS) || |
358 | (evm_status == INTEGRITY_NOXATTRS)) | 368 | (evm_status == INTEGRITY_NOXATTRS)) |
359 | return 0; | 369 | return 0; |
370 | integrity_audit_msg(AUDIT_INTEGRITY_METADATA, dentry->d_inode, | ||
371 | dentry->d_name.name, "appraise_metadata", | ||
372 | integrity_status_msg[evm_status], -EPERM, 0); | ||
360 | return -EPERM; | 373 | return -EPERM; |
361 | } | 374 | } |
362 | 375 | ||
diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig index d232c73647ae..39196abaff0d 100644 --- a/security/integrity/ima/Kconfig +++ b/security/integrity/ima/Kconfig | |||
@@ -38,18 +38,6 @@ config IMA_MEASURE_PCR_IDX | |||
38 | that IMA uses to maintain the integrity aggregate of the | 38 | that IMA uses to maintain the integrity aggregate of the |
39 | measurement list. If unsure, use the default 10. | 39 | measurement list. If unsure, use the default 10. |
40 | 40 | ||
41 | config IMA_AUDIT | ||
42 | bool "Enables auditing support" | ||
43 | depends on IMA | ||
44 | depends on AUDIT | ||
45 | default y | ||
46 | help | ||
47 | This option adds a kernel parameter 'ima_audit', which | ||
48 | allows informational auditing messages to be enabled | ||
49 | at boot. If this option is selected, informational integrity | ||
50 | auditing messages can be enabled with 'ima_audit=1' on | ||
51 | the kernel command line. | ||
52 | |||
53 | config IMA_LSM_RULES | 41 | config IMA_LSM_RULES |
54 | bool | 42 | bool |
55 | depends on IMA && AUDIT && (SECURITY_SELINUX || SECURITY_SMACK) | 43 | depends on IMA && AUDIT && (SECURITY_SELINUX || SECURITY_SMACK) |
diff --git a/security/integrity/ima/Makefile b/security/integrity/ima/Makefile index 3f2ca6bdc384..56dfee7cbf61 100644 --- a/security/integrity/ima/Makefile +++ b/security/integrity/ima/Makefile | |||
@@ -7,5 +7,4 @@ obj-$(CONFIG_IMA) += ima.o | |||
7 | 7 | ||
8 | ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ | 8 | ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ |
9 | ima_policy.o | 9 | ima_policy.o |
10 | ima-$(CONFIG_IMA_AUDIT) += ima_audit.o | ||
11 | ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o | 10 | ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o |
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index a41c9c18e5e0..b3dd616560f7 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h | |||
@@ -62,20 +62,6 @@ struct ima_queue_entry { | |||
62 | }; | 62 | }; |
63 | extern struct list_head ima_measurements; /* list of all measurements */ | 63 | extern struct list_head ima_measurements; /* list of all measurements */ |
64 | 64 | ||
65 | #ifdef CONFIG_IMA_AUDIT | ||
66 | /* declarations */ | ||
67 | void integrity_audit_msg(int audit_msgno, struct inode *inode, | ||
68 | const unsigned char *fname, const char *op, | ||
69 | const char *cause, int result, int info); | ||
70 | #else | ||
71 | static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, | ||
72 | const unsigned char *fname, | ||
73 | const char *op, const char *cause, | ||
74 | int result, int info) | ||
75 | { | ||
76 | } | ||
77 | #endif | ||
78 | |||
79 | /* Internal IMA function definitions */ | 65 | /* Internal IMA function definitions */ |
80 | int ima_init(void); | 66 | int ima_init(void); |
81 | void ima_cleanup(void); | 67 | void ima_cleanup(void); |
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 6c491a63128e..e9508d5bbfcf 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c | |||
@@ -57,7 +57,7 @@ __setup("ima_hash=", hash_setup); | |||
57 | static void ima_rdwr_violation_check(struct file *file) | 57 | static void ima_rdwr_violation_check(struct file *file) |
58 | { | 58 | { |
59 | struct dentry *dentry = file->f_path.dentry; | 59 | struct dentry *dentry = file->f_path.dentry; |
60 | struct inode *inode = dentry->d_inode; | 60 | struct inode *inode = file_inode(file); |
61 | fmode_t mode = file->f_mode; | 61 | fmode_t mode = file->f_mode; |
62 | int must_measure; | 62 | int must_measure; |
63 | bool send_tomtou = false, send_writers = false; | 63 | bool send_tomtou = false, send_writers = false; |
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 84c37c4db914..c42fb7a70dee 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h | |||
@@ -113,5 +113,19 @@ static inline int asymmetric_verify(struct key *keyring, const char *sig, | |||
113 | } | 113 | } |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | #ifdef CONFIG_INTEGRITY_AUDIT | ||
117 | /* declarations */ | ||
118 | void integrity_audit_msg(int audit_msgno, struct inode *inode, | ||
119 | const unsigned char *fname, const char *op, | ||
120 | const char *cause, int result, int info); | ||
121 | #else | ||
122 | static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, | ||
123 | const unsigned char *fname, | ||
124 | const char *op, const char *cause, | ||
125 | int result, int info) | ||
126 | { | ||
127 | } | ||
128 | #endif | ||
129 | |||
116 | /* set during initialization */ | 130 | /* set during initialization */ |
117 | extern int iint_initialized; | 131 | extern int iint_initialized; |
diff --git a/security/integrity/ima/ima_audit.c b/security/integrity/integrity_audit.c index c586faae8fd6..d7efb30404aa 100644 --- a/security/integrity/ima/ima_audit.c +++ b/security/integrity/integrity_audit.c | |||
@@ -13,20 +13,20 @@ | |||
13 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
14 | #include <linux/gfp.h> | 14 | #include <linux/gfp.h> |
15 | #include <linux/audit.h> | 15 | #include <linux/audit.h> |
16 | #include "ima.h" | 16 | #include "integrity.h" |
17 | 17 | ||
18 | static int ima_audit; | 18 | static int integrity_audit_info; |
19 | 19 | ||
20 | /* ima_audit_setup - enable informational auditing messages */ | 20 | /* ima_audit_setup - enable informational auditing messages */ |
21 | static int __init ima_audit_setup(char *str) | 21 | static int __init integrity_audit_setup(char *str) |
22 | { | 22 | { |
23 | unsigned long audit; | 23 | unsigned long audit; |
24 | 24 | ||
25 | if (!strict_strtoul(str, 0, &audit)) | 25 | if (!strict_strtoul(str, 0, &audit)) |
26 | ima_audit = audit ? 1 : 0; | 26 | integrity_audit_info = audit ? 1 : 0; |
27 | return 1; | 27 | return 1; |
28 | } | 28 | } |
29 | __setup("ima_audit=", ima_audit_setup); | 29 | __setup("integrity_audit=", integrity_audit_setup); |
30 | 30 | ||
31 | void integrity_audit_msg(int audit_msgno, struct inode *inode, | 31 | void integrity_audit_msg(int audit_msgno, struct inode *inode, |
32 | const unsigned char *fname, const char *op, | 32 | const unsigned char *fname, const char *op, |
@@ -34,7 +34,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, | |||
34 | { | 34 | { |
35 | struct audit_buffer *ab; | 35 | struct audit_buffer *ab; |
36 | 36 | ||
37 | if (!ima_audit && audit_info == 1) /* Skip informational messages */ | 37 | if (!integrity_audit_info && audit_info == 1) /* Skip info messages */ |
38 | return; | 38 | return; |
39 | 39 | ||
40 | ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno); | 40 | ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno); |