aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
Diffstat (limited to 'security')
-rw-r--r--security/commoncap.c2
-rw-r--r--security/keys/Makefile4
-rw-r--r--security/keys/encrypted.c (renamed from security/keys/encrypted_defined.c)3
-rw-r--r--security/keys/encrypted.h (renamed from security/keys/encrypted_defined.h)0
-rw-r--r--security/keys/internal.h6
-rw-r--r--security/keys/key.c8
-rw-r--r--security/keys/keyring.c31
-rw-r--r--security/keys/request_key.c2
-rw-r--r--security/keys/trusted.c (renamed from security/keys/trusted_defined.c)3
-rw-r--r--security/keys/trusted.h (renamed from security/keys/trusted_defined.h)0
-rw-r--r--security/security.c7
-rw-r--r--security/selinux/hooks.c6
-rw-r--r--security/selinux/ss/conditional.c2
-rw-r--r--security/selinux/ss/policydb.c4
14 files changed, 45 insertions, 33 deletions
diff --git a/security/commoncap.c b/security/commoncap.c
index 64c2ed9c9015..dbfdaed4cc66 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -93,7 +93,7 @@ int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
93 * Determine whether the current process may set the system clock and timezone 93 * Determine whether the current process may set the system clock and timezone
94 * information, returning 0 if permission granted, -ve if denied. 94 * information, returning 0 if permission granted, -ve if denied.
95 */ 95 */
96int cap_settime(struct timespec *ts, struct timezone *tz) 96int cap_settime(const struct timespec *ts, const struct timezone *tz)
97{ 97{
98 if (!capable(CAP_SYS_TIME)) 98 if (!capable(CAP_SYS_TIME))
99 return -EPERM; 99 return -EPERM;
diff --git a/security/keys/Makefile b/security/keys/Makefile
index 6c941050f573..1bf090a885fe 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -13,8 +13,8 @@ obj-y := \
13 request_key_auth.o \ 13 request_key_auth.o \
14 user_defined.o 14 user_defined.o
15 15
16obj-$(CONFIG_TRUSTED_KEYS) += trusted_defined.o 16obj-$(CONFIG_TRUSTED_KEYS) += trusted.o
17obj-$(CONFIG_ENCRYPTED_KEYS) += encrypted_defined.o 17obj-$(CONFIG_ENCRYPTED_KEYS) += encrypted.o
18obj-$(CONFIG_KEYS_COMPAT) += compat.o 18obj-$(CONFIG_KEYS_COMPAT) += compat.o
19obj-$(CONFIG_PROC_FS) += proc.o 19obj-$(CONFIG_PROC_FS) += proc.o
20obj-$(CONFIG_SYSCTL) += sysctl.o 20obj-$(CONFIG_SYSCTL) += sysctl.o
diff --git a/security/keys/encrypted_defined.c b/security/keys/encrypted.c
index 28791a65740e..9e7e4ce3fae8 100644
--- a/security/keys/encrypted_defined.c
+++ b/security/keys/encrypted.c
@@ -30,7 +30,7 @@
30#include <crypto/sha.h> 30#include <crypto/sha.h>
31#include <crypto/aes.h> 31#include <crypto/aes.h>
32 32
33#include "encrypted_defined.h" 33#include "encrypted.h"
34 34
35static const char KEY_TRUSTED_PREFIX[] = "trusted:"; 35static const char KEY_TRUSTED_PREFIX[] = "trusted:";
36static const char KEY_USER_PREFIX[] = "user:"; 36static const char KEY_USER_PREFIX[] = "user:";
@@ -888,6 +888,7 @@ static int __init init_encrypted(void)
888out: 888out:
889 encrypted_shash_release(); 889 encrypted_shash_release();
890 return ret; 890 return ret;
891
891} 892}
892 893
893static void __exit cleanup_encrypted(void) 894static void __exit cleanup_encrypted(void)
diff --git a/security/keys/encrypted_defined.h b/security/keys/encrypted.h
index cef5e2f2b7d1..cef5e2f2b7d1 100644
--- a/security/keys/encrypted_defined.h
+++ b/security/keys/encrypted.h
diff --git a/security/keys/internal.h b/security/keys/internal.h
index edfa50dbd6f5..a52aa7c88b41 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -87,13 +87,13 @@ extern void key_type_put(struct key_type *ktype);
87extern int __key_link_begin(struct key *keyring, 87extern int __key_link_begin(struct key *keyring,
88 const struct key_type *type, 88 const struct key_type *type,
89 const char *description, 89 const char *description,
90 struct keyring_list **_prealloc); 90 unsigned long *_prealloc);
91extern int __key_link_check_live_key(struct key *keyring, struct key *key); 91extern int __key_link_check_live_key(struct key *keyring, struct key *key);
92extern void __key_link(struct key *keyring, struct key *key, 92extern void __key_link(struct key *keyring, struct key *key,
93 struct keyring_list **_prealloc); 93 unsigned long *_prealloc);
94extern void __key_link_end(struct key *keyring, 94extern void __key_link_end(struct key *keyring,
95 struct key_type *type, 95 struct key_type *type,
96 struct keyring_list *prealloc); 96 unsigned long prealloc);
97 97
98extern key_ref_t __keyring_search_one(key_ref_t keyring_ref, 98extern key_ref_t __keyring_search_one(key_ref_t keyring_ref,
99 const struct key_type *type, 99 const struct key_type *type,
diff --git a/security/keys/key.c b/security/keys/key.c
index 84d4eb568b08..1c2d43dc5107 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -415,7 +415,7 @@ static int __key_instantiate_and_link(struct key *key,
415 size_t datalen, 415 size_t datalen,
416 struct key *keyring, 416 struct key *keyring,
417 struct key *authkey, 417 struct key *authkey,
418 struct keyring_list **_prealloc) 418 unsigned long *_prealloc)
419{ 419{
420 int ret, awaken; 420 int ret, awaken;
421 421
@@ -481,7 +481,7 @@ int key_instantiate_and_link(struct key *key,
481 struct key *keyring, 481 struct key *keyring,
482 struct key *authkey) 482 struct key *authkey)
483{ 483{
484 struct keyring_list *prealloc; 484 unsigned long prealloc;
485 int ret; 485 int ret;
486 486
487 if (keyring) { 487 if (keyring) {
@@ -526,7 +526,7 @@ int key_negate_and_link(struct key *key,
526 struct key *keyring, 526 struct key *keyring,
527 struct key *authkey) 527 struct key *authkey)
528{ 528{
529 struct keyring_list *prealloc; 529 unsigned long prealloc;
530 struct timespec now; 530 struct timespec now;
531 int ret, awaken, link_ret = 0; 531 int ret, awaken, link_ret = 0;
532 532
@@ -814,7 +814,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
814 key_perm_t perm, 814 key_perm_t perm,
815 unsigned long flags) 815 unsigned long flags)
816{ 816{
817 struct keyring_list *prealloc; 817 unsigned long prealloc;
818 const struct cred *cred = current_cred(); 818 const struct cred *cred = current_cred();
819 struct key_type *ktype; 819 struct key_type *ktype;
820 struct key *keyring, *key = NULL; 820 struct key *keyring, *key = NULL;
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 92024ed12e0a..5620f084dede 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -25,6 +25,8 @@
25 (keyring)->payload.subscriptions, \ 25 (keyring)->payload.subscriptions, \
26 rwsem_is_locked((struct rw_semaphore *)&(keyring)->sem))) 26 rwsem_is_locked((struct rw_semaphore *)&(keyring)->sem)))
27 27
28#define KEY_LINK_FIXQUOTA 1UL
29
28/* 30/*
29 * When plumbing the depths of the key tree, this sets a hard limit 31 * When plumbing the depths of the key tree, this sets a hard limit
30 * set on how deep we're willing to go. 32 * set on how deep we're willing to go.
@@ -699,11 +701,11 @@ static void keyring_unlink_rcu_disposal(struct rcu_head *rcu)
699 * Preallocate memory so that a key can be linked into to a keyring. 701 * Preallocate memory so that a key can be linked into to a keyring.
700 */ 702 */
701int __key_link_begin(struct key *keyring, const struct key_type *type, 703int __key_link_begin(struct key *keyring, const struct key_type *type,
702 const char *description, 704 const char *description, unsigned long *_prealloc)
703 struct keyring_list **_prealloc)
704 __acquires(&keyring->sem) 705 __acquires(&keyring->sem)
705{ 706{
706 struct keyring_list *klist, *nklist; 707 struct keyring_list *klist, *nklist;
708 unsigned long prealloc;
707 unsigned max; 709 unsigned max;
708 size_t size; 710 size_t size;
709 int loop, ret; 711 int loop, ret;
@@ -746,6 +748,7 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
746 748
747 /* note replacement slot */ 749 /* note replacement slot */
748 klist->delkey = nklist->delkey = loop; 750 klist->delkey = nklist->delkey = loop;
751 prealloc = (unsigned long)nklist;
749 goto done; 752 goto done;
750 } 753 }
751 } 754 }
@@ -760,6 +763,7 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
760 if (klist && klist->nkeys < klist->maxkeys) { 763 if (klist && klist->nkeys < klist->maxkeys) {
761 /* there's sufficient slack space to append directly */ 764 /* there's sufficient slack space to append directly */
762 nklist = NULL; 765 nklist = NULL;
766 prealloc = KEY_LINK_FIXQUOTA;
763 } else { 767 } else {
764 /* grow the key list */ 768 /* grow the key list */
765 max = 4; 769 max = 4;
@@ -794,8 +798,9 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
794 nklist->keys[nklist->delkey] = NULL; 798 nklist->keys[nklist->delkey] = NULL;
795 } 799 }
796 800
801 prealloc = (unsigned long)nklist | KEY_LINK_FIXQUOTA;
797done: 802done:
798 *_prealloc = nklist; 803 *_prealloc = prealloc;
799 kleave(" = 0"); 804 kleave(" = 0");
800 return 0; 805 return 0;
801 806
@@ -836,12 +841,12 @@ int __key_link_check_live_key(struct key *keyring, struct key *key)
836 * combination. 841 * combination.
837 */ 842 */
838void __key_link(struct key *keyring, struct key *key, 843void __key_link(struct key *keyring, struct key *key,
839 struct keyring_list **_prealloc) 844 unsigned long *_prealloc)
840{ 845{
841 struct keyring_list *klist, *nklist; 846 struct keyring_list *klist, *nklist;
842 847
843 nklist = *_prealloc; 848 nklist = (struct keyring_list *)(*_prealloc & ~KEY_LINK_FIXQUOTA);
844 *_prealloc = NULL; 849 *_prealloc = 0;
845 850
846 kenter("%d,%d,%p", keyring->serial, key->serial, nklist); 851 kenter("%d,%d,%p", keyring->serial, key->serial, nklist);
847 852
@@ -881,20 +886,22 @@ void __key_link(struct key *keyring, struct key *key,
881 * Must be called with __key_link_begin() having being called. 886 * Must be called with __key_link_begin() having being called.
882 */ 887 */
883void __key_link_end(struct key *keyring, struct key_type *type, 888void __key_link_end(struct key *keyring, struct key_type *type,
884 struct keyring_list *prealloc) 889 unsigned long prealloc)
885 __releases(&keyring->sem) 890 __releases(&keyring->sem)
886{ 891{
887 BUG_ON(type == NULL); 892 BUG_ON(type == NULL);
888 BUG_ON(type->name == NULL); 893 BUG_ON(type->name == NULL);
889 kenter("%d,%s,%p", keyring->serial, type->name, prealloc); 894 kenter("%d,%s,%lx", keyring->serial, type->name, prealloc);
890 895
891 if (type == &key_type_keyring) 896 if (type == &key_type_keyring)
892 up_write(&keyring_serialise_link_sem); 897 up_write(&keyring_serialise_link_sem);
893 898
894 if (prealloc) { 899 if (prealloc) {
895 kfree(prealloc); 900 if (prealloc & KEY_LINK_FIXQUOTA)
896 key_payload_reserve(keyring, 901 key_payload_reserve(keyring,
897 keyring->datalen - KEYQUOTA_LINK_BYTES); 902 keyring->datalen -
903 KEYQUOTA_LINK_BYTES);
904 kfree((struct keyring_list *)(prealloc & ~KEY_LINK_FIXQUOTA));
898 } 905 }
899 up_write(&keyring->sem); 906 up_write(&keyring->sem);
900} 907}
@@ -921,7 +928,7 @@ void __key_link_end(struct key *keyring, struct key_type *type,
921 */ 928 */
922int key_link(struct key *keyring, struct key *key) 929int key_link(struct key *keyring, struct key *key)
923{ 930{
924 struct keyring_list *prealloc; 931 unsigned long prealloc;
925 int ret; 932 int ret;
926 933
927 key_check(keyring); 934 key_check(keyring);
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 9a7fb3914b27..a3dc0d460def 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -352,8 +352,8 @@ static int construct_alloc_key(struct key_type *type,
352 struct key_user *user, 352 struct key_user *user,
353 struct key **_key) 353 struct key **_key)
354{ 354{
355 struct keyring_list *prealloc;
356 const struct cred *cred = current_cred(); 355 const struct cred *cred = current_cred();
356 unsigned long prealloc;
357 struct key *key; 357 struct key *key;
358 key_ref_t key_ref; 358 key_ref_t key_ref;
359 int ret; 359 int ret;
diff --git a/security/keys/trusted_defined.c b/security/keys/trusted.c
index 2836c6dc18a3..83fc92e297cd 100644
--- a/security/keys/trusted_defined.c
+++ b/security/keys/trusted.c
@@ -29,7 +29,7 @@
29#include <linux/tpm.h> 29#include <linux/tpm.h>
30#include <linux/tpm_command.h> 30#include <linux/tpm_command.h>
31 31
32#include "trusted_defined.h" 32#include "trusted.h"
33 33
34static const char hmac_alg[] = "hmac(sha1)"; 34static const char hmac_alg[] = "hmac(sha1)";
35static const char hash_alg[] = "sha1"; 35static const char hash_alg[] = "sha1";
@@ -1032,6 +1032,7 @@ static int trusted_update(struct key *key, const void *data, size_t datalen)
1032 ret = datablob_parse(datablob, new_p, new_o); 1032 ret = datablob_parse(datablob, new_p, new_o);
1033 if (ret != Opt_update) { 1033 if (ret != Opt_update) {
1034 ret = -EINVAL; 1034 ret = -EINVAL;
1035 kfree(new_p);
1035 goto out; 1036 goto out;
1036 } 1037 }
1037 /* copy old key values, and reseal with new pcrs */ 1038 /* copy old key values, and reseal with new pcrs */
diff --git a/security/keys/trusted_defined.h b/security/keys/trusted.h
index 3249fbd2b653..3249fbd2b653 100644
--- a/security/keys/trusted_defined.h
+++ b/security/keys/trusted.h
diff --git a/security/security.c b/security/security.c
index 739e40362f44..bb33ecadcf95 100644
--- a/security/security.c
+++ b/security/security.c
@@ -154,10 +154,9 @@ int security_capset(struct cred *new, const struct cred *old,
154 effective, inheritable, permitted); 154 effective, inheritable, permitted);
155} 155}
156 156
157int security_capable(int cap) 157int security_capable(const struct cred *cred, int cap)
158{ 158{
159 return security_ops->capable(current, current_cred(), cap, 159 return security_ops->capable(current, cred, cap, SECURITY_CAP_AUDIT);
160 SECURITY_CAP_AUDIT);
161} 160}
162 161
163int security_real_capable(struct task_struct *tsk, int cap) 162int security_real_capable(struct task_struct *tsk, int cap)
@@ -202,7 +201,7 @@ int security_syslog(int type)
202 return security_ops->syslog(type); 201 return security_ops->syslog(type);
203} 202}
204 203
205int security_settime(struct timespec *ts, struct timezone *tz) 204int security_settime(const struct timespec *ts, const struct timezone *tz)
206{ 205{
207 return security_ops->settime(ts, tz); 206 return security_ops->settime(ts, tz);
208} 207}
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e276eb468536..c8d699270687 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3198,7 +3198,11 @@ static void selinux_cred_free(struct cred *cred)
3198{ 3198{
3199 struct task_security_struct *tsec = cred->security; 3199 struct task_security_struct *tsec = cred->security;
3200 3200
3201 BUG_ON((unsigned long) cred->security < PAGE_SIZE); 3201 /*
3202 * cred->security == NULL if security_cred_alloc_blank() or
3203 * security_prepare_creds() returned an error.
3204 */
3205 BUG_ON(cred->security && (unsigned long) cred->security < PAGE_SIZE);
3202 cred->security = (void *) 0x7UL; 3206 cred->security = (void *) 0x7UL;
3203 kfree(tsec); 3207 kfree(tsec);
3204} 3208}
diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index c3f845cbcd48..a53373207fb4 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -178,7 +178,7 @@ int cond_init_bool_indexes(struct policydb *p)
178 p->bool_val_to_struct = (struct cond_bool_datum **) 178 p->bool_val_to_struct = (struct cond_bool_datum **)
179 kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL); 179 kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL);
180 if (!p->bool_val_to_struct) 180 if (!p->bool_val_to_struct)
181 return -1; 181 return -ENOMEM;
182 return 0; 182 return 0;
183} 183}
184 184
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index be9de3872837..57363562f0f8 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -501,8 +501,8 @@ static int policydb_index(struct policydb *p)
501 if (rc) 501 if (rc)
502 goto out; 502 goto out;
503 503
504 rc = -ENOMEM; 504 rc = cond_init_bool_indexes(p);
505 if (cond_init_bool_indexes(p)) 505 if (rc)
506 goto out; 506 goto out;
507 507
508 for (i = 0; i < SYM_NUM; i++) { 508 for (i = 0; i < SYM_NUM; i++) {