diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-13 10:39:39 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-13 10:39:39 -0400 |
| commit | aa569fa0ea32d1c24fb801a07d2d9174cbbdde23 (patch) | |
| tree | 54c211a790684e0a93d6139634251152c703bbc2 /security | |
| parent | 6d87c225f5d82d29243dc124f1ffcbb0e14ec358 (diff) | |
| parent | 0430e49b6e7c6b5e076be8fefdee089958c9adad (diff) | |
Merge branch 'serge-next-2' of git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux-security
Pull more security layer updates from Serge Hallyn:
"A few more commits had previously failed to make it through
security-next into linux-next but this week made it into linux-next.
At least commit "ima: introduce ima_kernel_read()" was deemed critical
by Mimi to make this merge window.
This is a temporary tree just for this request. Mimi has pointed me
to some previous threads about keeping maintainer trees at the
previous release, which I'll certainly do for anything long-term,
after talking with James"
* 'serge-next-2' of git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux-security:
ima: introduce ima_kernel_read()
evm: prohibit userspace writing 'security.evm' HMAC value
ima: check inode integrity cache in violation check
ima: prevent unnecessary policy checking
evm: provide option to protect additional SMACK xattrs
evm: replace HMAC version with attribute mask
ima: prevent new digsig xattr from being replaced
Diffstat (limited to 'security')
| -rw-r--r-- | security/integrity/evm/Kconfig | 42 | ||||
| -rw-r--r-- | security/integrity/evm/evm.h | 5 | ||||
| -rw-r--r-- | security/integrity/evm/evm_crypto.c | 2 | ||||
| -rw-r--r-- | security/integrity/evm/evm_main.c | 29 | ||||
| -rw-r--r-- | security/integrity/ima/ima_appraise.c | 10 | ||||
| -rw-r--r-- | security/integrity/ima/ima_crypto.c | 32 | ||||
| -rw-r--r-- | security/integrity/ima/ima_main.c | 22 |
7 files changed, 114 insertions, 28 deletions
diff --git a/security/integrity/evm/Kconfig b/security/integrity/evm/Kconfig index d35b4915b00d..d606f3d12d6b 100644 --- a/security/integrity/evm/Kconfig +++ b/security/integrity/evm/Kconfig | |||
| @@ -12,15 +12,41 @@ config EVM | |||
| 12 | 12 | ||
| 13 | If you are unsure how to answer this question, answer N. | 13 | If you are unsure how to answer this question, answer N. |
| 14 | 14 | ||
| 15 | config EVM_HMAC_VERSION | 15 | if EVM |
| 16 | int "EVM HMAC version" | 16 | |
| 17 | menu "EVM options" | ||
| 18 | |||
| 19 | config EVM_ATTR_FSUUID | ||
| 20 | bool "FSUUID (version 2)" | ||
| 21 | default y | ||
| 17 | depends on EVM | 22 | depends on EVM |
| 18 | default 2 | ||
| 19 | help | 23 | help |
| 20 | This options adds EVM HMAC version support. | 24 | Include filesystem UUID for HMAC calculation. |
| 21 | 1 - original version | 25 | |
| 22 | 2 - add per filesystem unique identifier (UUID) (default) | 26 | Default value is 'selected', which is former version 2. |
| 27 | if 'not selected', it is former version 1 | ||
| 23 | 28 | ||
| 24 | WARNING: changing the HMAC calculation method or adding | 29 | WARNING: changing the HMAC calculation method or adding |
| 25 | additional info to the calculation, requires existing EVM | 30 | additional info to the calculation, requires existing EVM |
| 26 | labeled file systems to be relabeled. | 31 | labeled file systems to be relabeled. |
| 32 | |||
| 33 | config EVM_EXTRA_SMACK_XATTRS | ||
| 34 | bool "Additional SMACK xattrs" | ||
| 35 | depends on EVM && SECURITY_SMACK | ||
| 36 | default n | ||
| 37 | help | ||
| 38 | Include additional SMACK xattrs for HMAC calculation. | ||
| 39 | |||
| 40 | In addition to the original security xattrs (eg. security.selinux, | ||
| 41 | security.SMACK64, security.capability, and security.ima) included | ||
| 42 | in the HMAC calculation, enabling this option includes newly defined | ||
| 43 | Smack xattrs: security.SMACK64EXEC, security.SMACK64TRANSMUTE and | ||
| 44 | security.SMACK64MMAP. | ||
| 45 | |||
| 46 | WARNING: changing the HMAC calculation method or adding | ||
| 47 | additional info to the calculation, requires existing EVM | ||
| 48 | labeled file systems to be relabeled. | ||
| 49 | |||
| 50 | endmenu | ||
| 51 | |||
| 52 | endif | ||
diff --git a/security/integrity/evm/evm.h b/security/integrity/evm/evm.h index 37c88ddb3cfe..88bfe77efa1c 100644 --- a/security/integrity/evm/evm.h +++ b/security/integrity/evm/evm.h | |||
| @@ -24,7 +24,10 @@ | |||
| 24 | extern int evm_initialized; | 24 | extern int evm_initialized; |
| 25 | extern char *evm_hmac; | 25 | extern char *evm_hmac; |
| 26 | extern char *evm_hash; | 26 | extern char *evm_hash; |
| 27 | extern int evm_hmac_version; | 27 | |
| 28 | #define EVM_ATTR_FSUUID 0x0001 | ||
| 29 | |||
| 30 | extern int evm_hmac_attrs; | ||
| 28 | 31 | ||
| 29 | extern struct crypto_shash *hmac_tfm; | 32 | extern struct crypto_shash *hmac_tfm; |
| 30 | extern struct crypto_shash *hash_tfm; | 33 | extern struct crypto_shash *hash_tfm; |
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c index 6b540f1822e0..5e9687f02e1b 100644 --- a/security/integrity/evm/evm_crypto.c +++ b/security/integrity/evm/evm_crypto.c | |||
| @@ -112,7 +112,7 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode, | |||
| 112 | hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid); | 112 | hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid); |
| 113 | hmac_misc.mode = inode->i_mode; | 113 | hmac_misc.mode = inode->i_mode; |
| 114 | crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc)); | 114 | crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc)); |
| 115 | if (evm_hmac_version > 1) | 115 | if (evm_hmac_attrs & EVM_ATTR_FSUUID) |
| 116 | crypto_shash_update(desc, inode->i_sb->s_uuid, | 116 | crypto_shash_update(desc, inode->i_sb->s_uuid, |
| 117 | sizeof(inode->i_sb->s_uuid)); | 117 | sizeof(inode->i_sb->s_uuid)); |
| 118 | crypto_shash_final(desc, digest); | 118 | crypto_shash_final(desc, digest); |
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 6e0bd933b6a9..3bcb80df4d01 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c | |||
| @@ -32,7 +32,7 @@ static char *integrity_status_msg[] = { | |||
| 32 | }; | 32 | }; |
| 33 | char *evm_hmac = "hmac(sha1)"; | 33 | char *evm_hmac = "hmac(sha1)"; |
| 34 | char *evm_hash = "sha1"; | 34 | char *evm_hash = "sha1"; |
| 35 | int evm_hmac_version = CONFIG_EVM_HMAC_VERSION; | 35 | int evm_hmac_attrs; |
| 36 | 36 | ||
| 37 | char *evm_config_xattrnames[] = { | 37 | char *evm_config_xattrnames[] = { |
| 38 | #ifdef CONFIG_SECURITY_SELINUX | 38 | #ifdef CONFIG_SECURITY_SELINUX |
| @@ -40,6 +40,11 @@ char *evm_config_xattrnames[] = { | |||
| 40 | #endif | 40 | #endif |
| 41 | #ifdef CONFIG_SECURITY_SMACK | 41 | #ifdef CONFIG_SECURITY_SMACK |
| 42 | XATTR_NAME_SMACK, | 42 | XATTR_NAME_SMACK, |
| 43 | #ifdef CONFIG_EVM_EXTRA_SMACK_XATTRS | ||
| 44 | XATTR_NAME_SMACKEXEC, | ||
| 45 | XATTR_NAME_SMACKTRANSMUTE, | ||
| 46 | XATTR_NAME_SMACKMMAP, | ||
| 47 | #endif | ||
| 43 | #endif | 48 | #endif |
| 44 | #ifdef CONFIG_IMA_APPRAISE | 49 | #ifdef CONFIG_IMA_APPRAISE |
| 45 | XATTR_NAME_IMA, | 50 | XATTR_NAME_IMA, |
| @@ -57,6 +62,14 @@ static int __init evm_set_fixmode(char *str) | |||
| 57 | } | 62 | } |
| 58 | __setup("evm=", evm_set_fixmode); | 63 | __setup("evm=", evm_set_fixmode); |
| 59 | 64 | ||
| 65 | static void __init evm_init_config(void) | ||
| 66 | { | ||
| 67 | #ifdef CONFIG_EVM_ATTR_FSUUID | ||
| 68 | evm_hmac_attrs |= EVM_ATTR_FSUUID; | ||
| 69 | #endif | ||
| 70 | pr_info("HMAC attrs: 0x%x\n", evm_hmac_attrs); | ||
| 71 | } | ||
| 72 | |||
| 60 | static int evm_find_protected_xattrs(struct dentry *dentry) | 73 | static int evm_find_protected_xattrs(struct dentry *dentry) |
| 61 | { | 74 | { |
| 62 | struct inode *inode = dentry->d_inode; | 75 | struct inode *inode = dentry->d_inode; |
| @@ -287,12 +300,20 @@ out: | |||
| 287 | * @xattr_value: pointer to the new extended attribute value | 300 | * @xattr_value: pointer to the new extended attribute value |
| 288 | * @xattr_value_len: pointer to the new extended attribute value length | 301 | * @xattr_value_len: pointer to the new extended attribute value length |
| 289 | * | 302 | * |
| 290 | * Updating 'security.evm' requires CAP_SYS_ADMIN privileges and that | 303 | * Before allowing the 'security.evm' protected xattr to be updated, |
| 291 | * the current value is valid. | 304 | * verify the existing value is valid. As only the kernel should have |
| 305 | * access to the EVM encrypted key needed to calculate the HMAC, prevent | ||
| 306 | * userspace from writing HMAC value. Writing 'security.evm' requires | ||
| 307 | * requires CAP_SYS_ADMIN privileges. | ||
| 292 | */ | 308 | */ |
| 293 | int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name, | 309 | int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name, |
| 294 | const void *xattr_value, size_t xattr_value_len) | 310 | const void *xattr_value, size_t xattr_value_len) |
| 295 | { | 311 | { |
| 312 | const struct evm_ima_xattr_data *xattr_data = xattr_value; | ||
| 313 | |||
| 314 | if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0) | ||
| 315 | && (xattr_data->type == EVM_XATTR_HMAC)) | ||
| 316 | return -EPERM; | ||
| 296 | return evm_protect_xattr(dentry, xattr_name, xattr_value, | 317 | return evm_protect_xattr(dentry, xattr_name, xattr_value, |
| 297 | xattr_value_len); | 318 | xattr_value_len); |
| 298 | } | 319 | } |
| @@ -432,6 +453,8 @@ static int __init init_evm(void) | |||
| 432 | { | 453 | { |
| 433 | int error; | 454 | int error; |
| 434 | 455 | ||
| 456 | evm_init_config(); | ||
| 457 | |||
| 435 | error = evm_init_secfs(); | 458 | error = evm_init_secfs(); |
| 436 | if (error < 0) { | 459 | if (error < 0) { |
| 437 | pr_info("Error registering secfs\n"); | 460 | pr_info("Error registering secfs\n"); |
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 291bf0f3a46d..d3113d4aaa3c 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c | |||
| @@ -341,7 +341,7 @@ static int ima_protect_xattr(struct dentry *dentry, const char *xattr_name, | |||
| 341 | return 0; | 341 | return 0; |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | static void ima_reset_appraise_flags(struct inode *inode) | 344 | static void ima_reset_appraise_flags(struct inode *inode, int digsig) |
| 345 | <|||
