aboutsummaryrefslogtreecommitdiffstats
path: root/security/smack
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 23:36:37 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 23:36:37 -0500
commit67e2c3883828b39548cee2091b36656787775d95 (patch)
tree975a0f546a604beda30d4ede34f8e9cca9a88b71 /security/smack
parent6ae840e7cc4be0be3aa40d9f67c35c75cfc67d83 (diff)
parentb2d1965dcea148100ffc4e7199470bf5fad13871 (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security layer updates from James Morris: "In terms of changes, there's general maintenance to the Smack, SELinux, and integrity code. The IMA code adds a new kconfig option, IMA_APPRAISE_SIGNED_INIT, which allows IMA appraisal to require signatures. Support for reading keys from rootfs before init is call is also added" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (23 commits) selinux: Remove security_ops extern security: smack: fix out-of-bounds access in smk_parse_smack() VFS: refactor vfs_read() ima: require signature based appraisal integrity: provide a hook to load keys when rootfs is ready ima: load x509 certificate from the kernel integrity: provide a function to load x509 certificate from the kernel integrity: define a new function integrity_read_file() Security: smack: replace kzalloc with kmem_cache for inode_smack Smack: Lock mode for the floor and hat labels ima: added support for new kernel cmdline parameter ima_template_fmt ima: allocate field pointers array on demand in template_desc_init_fields() ima: don't allocate a copy of template_fmt in template_desc_init_fields() ima: display template format in meas. list if template name length is zero ima: added error messages to template-related functions ima: use atomic bit operations to protect policy update interface ima: ignore empty and with whitespaces policy lines ima: no need to allocate entry for comment ima: report policy load status ima: use path names cache ...
Diffstat (limited to 'security/smack')
-rw-r--r--security/smack/smack_access.c17
-rw-r--r--security/smack/smack_lsm.c13
2 files changed, 18 insertions, 12 deletions
diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index 5b970ffde024..1158430f5bb9 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -142,8 +142,7 @@ int smk_access(struct smack_known *subject, struct smack_known *object,
142 * Tasks cannot be assigned the internet label. 142 * Tasks cannot be assigned the internet label.
143 * An internet subject can access any object. 143 * An internet subject can access any object.
144 */ 144 */
145 if (object == &smack_known_web || 145 if (object == &smack_known_web || subject == &smack_known_web)
146 subject == &smack_known_web)
147 goto out_audit; 146 goto out_audit;
148 /* 147 /*
149 * A star object can be accessed by any subject. 148 * A star object can be accessed by any subject.
@@ -157,10 +156,11 @@ int smk_access(struct smack_known *subject, struct smack_known *object,
157 if (subject->smk_known == object->smk_known) 156 if (subject->smk_known == object->smk_known)
158 goto out_audit; 157 goto out_audit;
159 /* 158 /*
160 * A hat subject can read any object. 159 * A hat subject can read or lock any object.
161 * A floor object can be read by any subject. 160 * A floor object can be read or locked by any subject.
162 */ 161 */
163 if ((request & MAY_ANYREAD) == request) { 162 if ((request & MAY_ANYREAD) == request ||
163 (request & MAY_LOCK) == request) {
164 if (object == &smack_known_floor) 164 if (object == &smack_known_floor)
165 goto out_audit; 165 goto out_audit;
166 if (subject == &smack_known_hat) 166 if (subject == &smack_known_hat)
@@ -452,10 +452,9 @@ char *smk_parse_smack(const char *string, int len)
452 return NULL; 452 return NULL;
453 453
454 smack = kzalloc(i + 1, GFP_KERNEL); 454 smack = kzalloc(i + 1, GFP_KERNEL);
455 if (smack != NULL) { 455 if (smack != NULL)
456 strncpy(smack, string, i + 1); 456 strncpy(smack, string, i);
457 smack[i] = '\0'; 457
458 }
459 return smack; 458 return smack;
460} 459}
461 460
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 433ae61e7f42..f1b17a476e12 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -53,6 +53,7 @@
53#define SMK_SENDING 2 53#define SMK_SENDING 2
54 54
55LIST_HEAD(smk_ipv6_port_list); 55LIST_HEAD(smk_ipv6_port_list);
56static struct kmem_cache *smack_inode_cache;
56 57
57#ifdef CONFIG_SECURITY_SMACK_BRINGUP 58#ifdef CONFIG_SECURITY_SMACK_BRINGUP
58static void smk_bu_mode(int mode, char *s) 59static void smk_bu_mode(int mode, char *s)
@@ -240,7 +241,7 @@ struct inode_smack *new_inode_smack(struct smack_known *skp)
240{ 241{
241 struct inode_smack *isp; 242 struct inode_smack *isp;
242 243
243 isp = kzalloc(sizeof(struct inode_smack), GFP_NOFS); 244 isp = kmem_cache_zalloc(smack_inode_cache, GFP_NOFS);
244 if (isp == NULL) 245 if (isp == NULL)
245 return NULL; 246 return NULL;
246 247
@@ -767,7 +768,7 @@ static int smack_inode_alloc_security(struct inode *inode)
767 */ 768 */
768static void smack_inode_free_security(struct inode *inode) 769static void smack_inode_free_security(struct inode *inode)
769{ 770{
770 kfree(inode->i_security); 771 kmem_cache_free(smack_inode_cache, inode->i_security);
771 inode->i_security = NULL; 772 inode->i_security = NULL;
772} 773}
773 774
@@ -4264,10 +4265,16 @@ static __init int smack_init(void)
4264 if (!security_module_enable(&smack_ops)) 4265 if (!security_module_enable(&smack_ops))
4265 return 0; 4266 return 0;
4266 4267
4268 smack_inode_cache = KMEM_CACHE(inode_smack, 0);
4269 if (!smack_inode_cache)
4270 return -ENOMEM;
4271
4267 tsp = new_task_smack(&smack_known_floor, &smack_known_floor, 4272 tsp = new_task_smack(&smack_known_floor, &smack_known_floor,
4268 GFP_KERNEL); 4273 GFP_KERNEL);
4269 if (tsp == NULL) 4274 if (tsp == NULL) {
4275 kmem_cache_destroy(smack_inode_cache);
4270 return -ENOMEM; 4276 return -ENOMEM;
4277 }
4271 4278
4272 printk(KERN_INFO "Smack: Initializing.\n"); 4279 printk(KERN_INFO "Smack: Initializing.\n");
4273 4280