diff options
author | John W. Linville <linville@tuxdriver.com> | 2012-02-15 16:24:37 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-02-15 16:24:37 -0500 |
commit | ca994a36f585432458ead9133fcfe05440edbb7b (patch) | |
tree | be05512153a9cd5cbe1f1234bc09fd9cd388ec58 /security | |
parent | 12325280dfeba18164f9c47e226a40ab34e23ee7 (diff) | |
parent | 2504a6423b9ab4c36df78227055995644de19edb (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless
Conflicts:
net/mac80211/debugfs_sta.c
net/mac80211/sta_info.h
Diffstat (limited to 'security')
-rw-r--r-- | security/apparmor/include/apparmor.h | 10 | ||||
-rw-r--r-- | security/apparmor/lsm.c | 20 | ||||
-rw-r--r-- | security/capability.c | 1 | ||||
-rw-r--r-- | security/commoncap.c | 24 | ||||
-rw-r--r-- | security/integrity/Kconfig | 4 | ||||
-rw-r--r-- | security/integrity/Makefile | 2 | ||||
-rw-r--r-- | security/integrity/ima/ima_audit.c | 8 | ||||
-rw-r--r-- | security/integrity/ima/ima_policy.c | 3 | ||||
-rw-r--r-- | security/integrity/integrity.h | 4 | ||||
-rw-r--r-- | security/keys/encrypted-keys/encrypted.c | 6 | ||||
-rw-r--r-- | security/keys/encrypted-keys/masterkey_trusted.c | 4 | ||||
-rw-r--r-- | security/keys/gc.c | 4 | ||||
-rw-r--r-- | security/keys/internal.h | 1 | ||||
-rw-r--r-- | security/keys/key.c | 1 | ||||
-rw-r--r-- | security/keys/keyring.c | 22 | ||||
-rw-r--r-- | security/keys/trusted.c | 4 | ||||
-rw-r--r-- | security/keys/user_defined.c | 43 | ||||
-rw-r--r-- | security/lsm_audit.c | 27 | ||||
-rw-r--r-- | security/security.c | 35 | ||||
-rw-r--r-- | security/selinux/hooks.c | 44 | ||||
-rw-r--r-- | security/tomoyo/util.c | 6 |
21 files changed, 136 insertions, 137 deletions
diff --git a/security/apparmor/include/apparmor.h b/security/apparmor/include/apparmor.h index 38ccaea08204..df3649560818 100644 --- a/security/apparmor/include/apparmor.h +++ b/security/apparmor/include/apparmor.h | |||
@@ -21,11 +21,11 @@ | |||
21 | 21 | ||
22 | /* Control parameters settable through module/boot flags */ | 22 | /* Control parameters settable through module/boot flags */ |
23 | extern enum audit_mode aa_g_audit; | 23 | extern enum audit_mode aa_g_audit; |
24 | extern int aa_g_audit_header; | 24 | extern bool aa_g_audit_header; |
25 | extern int aa_g_debug; | 25 | extern bool aa_g_debug; |
26 | extern int aa_g_lock_policy; | 26 | extern bool aa_g_lock_policy; |
27 | extern int aa_g_logsyscall; | 27 | extern bool aa_g_logsyscall; |
28 | extern int aa_g_paranoid_load; | 28 | extern bool aa_g_paranoid_load; |
29 | extern unsigned int aa_g_path_max; | 29 | extern unsigned int aa_g_path_max; |
30 | 30 | ||
31 | /* | 31 | /* |
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index d7f06f8b2837..97ce8fae49b3 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c | |||
@@ -136,16 +136,16 @@ static int apparmor_capget(struct task_struct *target, kernel_cap_t *effective, | |||
136 | return 0; | 136 | return 0; |
137 | } | 137 | } |
138 | 138 | ||
139 | static int apparmor_capable(struct task_struct *task, const struct cred *cred, | 139 | static int apparmor_capable(const struct cred *cred, struct user_namespace *ns, |
140 | struct user_namespace *ns, int cap, int audit) | 140 | int cap, int audit) |
141 | { | 141 | { |
142 | struct aa_profile *profile; | 142 | struct aa_profile *profile; |
143 | /* cap_capable returns 0 on success, else -EPERM */ | 143 | /* cap_capable returns 0 on success, else -EPERM */ |
144 | int error = cap_capable(task, cred, ns, cap, audit); | 144 | int error = cap_capable(cred, ns, cap, audit); |
145 | if (!error) { | 145 | if (!error) { |
146 | profile = aa_cred_profile(cred); | 146 | profile = aa_cred_profile(cred); |
147 | if (!unconfined(profile)) | 147 | if (!unconfined(profile)) |
148 | error = aa_capable(task, profile, cap, audit); | 148 | error = aa_capable(current, profile, cap, audit); |
149 | } | 149 | } |
150 | return error; | 150 | return error; |
151 | } | 151 | } |
@@ -708,7 +708,7 @@ module_param_call(mode, param_set_mode, param_get_mode, | |||
708 | &aa_g_profile_mode, S_IRUSR | S_IWUSR); | 708 | &aa_g_profile_mode, S_IRUSR | S_IWUSR); |
709 | 709 | ||
710 | /* Debug mode */ | 710 | /* Debug mode */ |
711 | int aa_g_debug; | 711 | bool aa_g_debug; |
712 | module_param_named(debug, aa_g_debug, aabool, S_IRUSR | S_IWUSR); | 712 | module_param_named(debug, aa_g_debug, aabool, S_IRUSR | S_IWUSR); |
713 | 713 | ||
714 | /* Audit mode */ | 714 | /* Audit mode */ |
@@ -719,7 +719,7 @@ module_param_call(audit, param_set_audit, param_get_audit, | |||
719 | /* Determines if audit header is included in audited messages. This | 719 | /* Determines if audit header is included in audited messages. This |
720 | * provides more context if the audit daemon is not running | 720 | * provides more context if the audit daemon is not running |
721 | */ | 721 | */ |
722 | int aa_g_audit_header = 1; | 722 | bool aa_g_audit_header = 1; |
723 | module_param_named(audit_header, aa_g_audit_header, aabool, | 723 | module_param_named(audit_header, aa_g_audit_header, aabool, |
724 | S_IRUSR | S_IWUSR); | 724 | S_IRUSR | S_IWUSR); |
725 | 725 | ||
@@ -727,12 +727,12 @@ module_param_named(audit_header, aa_g_audit_header, aabool, | |||
727 | * TODO: add in at boot loading of policy, which is the only way to | 727 | * TODO: add in at boot loading of policy, which is the only way to |
728 | * load policy, if lock_policy is set | 728 | * load policy, if lock_policy is set |
729 | */ | 729 | */ |
730 | int aa_g_lock_policy; | 730 | bool aa_g_lock_policy; |
731 | module_param_named(lock_policy, aa_g_lock_policy, aalockpolicy, | 731 | module_param_named(lock_policy, aa_g_lock_policy, aalockpolicy, |
732 | S_IRUSR | S_IWUSR); | 732 | S_IRUSR | S_IWUSR); |
733 | 733 | ||
734 | /* Syscall logging mode */ | 734 | /* Syscall logging mode */ |
735 | int aa_g_logsyscall; | 735 | bool aa_g_logsyscall; |
736 | module_param_named(logsyscall, aa_g_logsyscall, aabool, S_IRUSR | S_IWUSR); | 736 | module_param_named(logsyscall, aa_g_logsyscall, aabool, S_IRUSR | S_IWUSR); |
737 | 737 | ||
738 | /* Maximum pathname length before accesses will start getting rejected */ | 738 | /* Maximum pathname length before accesses will start getting rejected */ |
@@ -742,12 +742,12 @@ module_param_named(path_max, aa_g_path_max, aauint, S_IRUSR | S_IWUSR); | |||
742 | /* Determines how paranoid loading of policy is and how much verification | 742 | /* Determines how paranoid loading of policy is and how much verification |
743 | * on the loaded policy is done. | 743 | * on the loaded policy is done. |
744 | */ | 744 | */ |
745 | int aa_g_paranoid_load = 1; | 745 | bool aa_g_paranoid_load = 1; |
746 | module_param_named(paranoid_load, aa_g_paranoid_load, aabool, | 746 | module_param_named(paranoid_load, aa_g_paranoid_load, aabool, |
747 | S_IRUSR | S_IWUSR); | 747 | S_IRUSR | S_IWUSR); |
748 | 748 | ||
749 | /* Boot time disable flag */ | 749 | /* Boot time disable flag */ |
750 | static unsigned int apparmor_enabled = CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE; | 750 | static bool apparmor_enabled = CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE; |
751 | module_param_named(enabled, apparmor_enabled, aabool, S_IRUSR); | 751 | module_param_named(enabled, apparmor_enabled, aabool, S_IRUSR); |
752 | 752 | ||
753 | static int __init apparmor_enabled_setup(char *str) | 753 | static int __init apparmor_enabled_setup(char *str) |
diff --git a/security/capability.c b/security/capability.c index 3b5883b7179f..2f680eb02b59 100644 --- a/security/capability.c +++ b/security/capability.c | |||
@@ -998,7 +998,6 @@ void __init security_fixup_ops(struct security_operations *ops) | |||
998 | set_to_cap_if_null(ops, sem_semctl); | 998 | set_to_cap_if_null(ops, sem_semctl); |
999 | set_to_cap_if_null(ops, sem_semop); | 999 | set_to_cap_if_null(ops, sem_semop); |
1000 | set_to_cap_if_null(ops, netlink_send); | 1000 | set_to_cap_if_null(ops, netlink_send); |
1001 | set_to_cap_if_null(ops, netlink_recv); | ||
1002 | set_to_cap_if_null(ops, d_instantiate); | 1001 | set_to_cap_if_null(ops, d_instantiate); |
1003 | set_to_cap_if_null(ops, getprocattr); | 1002 | set_to_cap_if_null(ops, getprocattr); |
1004 | set_to_cap_if_null(ops, setprocattr); | 1003 | set_to_cap_if_null(ops, setprocattr); |
diff --git a/security/commoncap.c b/security/commoncap.c index ee4f8486e5f5..7ce191ea29a0 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
@@ -56,17 +56,8 @@ int cap_netlink_send(struct sock *sk, struct sk_buff *skb) | |||
56 | return 0; | 56 | return 0; |
57 | } | 57 | } |
58 | 58 | ||
59 | int cap_netlink_recv(struct sk_buff *skb, int cap) | ||
60 | { | ||
61 | if (!cap_raised(current_cap(), cap)) | ||
62 | return -EPERM; | ||
63 | return 0; | ||
64 | } | ||
65 | EXPORT_SYMBOL(cap_netlink_recv); | ||
66 | |||
67 | /** | 59 | /** |
68 | * cap_capable - Determine whether a task has a particular effective capability | 60 | * cap_capable - Determine whether a task has a particular effective capability |
69 | * @tsk: The task to query | ||
70 | * @cred: The credentials to use | 61 | * @cred: The credentials to use |
71 | * @ns: The user namespace in which we need the capability | 62 | * @ns: The user namespace in which we need the capability |
72 | * @cap: The capability to check for | 63 | * @cap: The capability to check for |
@@ -80,8 +71,8 @@ EXPORT_SYMBOL(cap_netlink_recv); | |||
80 | * cap_has_capability() returns 0 when a task has a capability, but the | 71 | * cap_has_capability() returns 0 when a task has a capability, but the |
81 | * kernel's capable() and has_capability() returns 1 for this case. | 72 | * kernel's capable() and has_capability() returns 1 for this case. |
82 | */ | 73 | */ |
83 | int cap_capable(struct task_struct *tsk, const struct cred *cred, | 74 | int cap_capable(const struct cred *cred, struct user_namespace *targ_ns, |
84 | struct user_namespace *targ_ns, int cap, int audit) | 75 | int cap, int audit) |
85 | { | 76 | { |
86 | for (;;) { | 77 | for (;;) { |
87 | /* The creator of the user namespace has all caps. */ | 78 | /* The creator of the user namespace has all caps. */ |
@@ -222,9 +213,8 @@ static inline int cap_inh_is_capped(void) | |||
222 | /* they are so limited unless the current task has the CAP_SETPCAP | 213 | /* they are so limited unless the current task has the CAP_SETPCAP |
223 | * capability | 214 | * capability |
224 | */ | 215 | */ |
225 | if (cap_capable(current, current_cred(), | 216 | if (cap_capable(current_cred(), current_cred()->user->user_ns, |
226 | current_cred()->user->user_ns, CAP_SETPCAP, | 217 | CAP_SETPCAP, SECURITY_CAP_AUDIT) == 0) |
227 | SECURITY_CAP_AUDIT) == 0) | ||
228 | return 0; | 218 | return 0; |
229 | return 1; | 219 | return 1; |
230 | } | 220 | } |
@@ -874,7 +864,7 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, | |||
874 | & (new->securebits ^ arg2)) /*[1]*/ | 864 | & (new->securebits ^ arg2)) /*[1]*/ |
875 | || ((new->securebits & SECURE_ALL_LOCKS & ~arg2)) /*[2]*/ | 865 | || ((new->securebits & SECURE_ALL_LOCKS & ~arg2)) /*[2]*/ |
876 | || (arg2 & ~(SECURE_ALL_LOCKS | SECURE_ALL_BITS)) /*[3]*/ | 866 | || (arg2 & ~(SECURE_ALL_LOCKS | SECURE_ALL_BITS)) /*[3]*/ |
877 | || (cap_capable(current, current_cred(), | 867 | || (cap_capable(current_cred(), |
878 | current_cred()->user->user_ns, CAP_SETPCAP, | 868 | current_cred()->user->user_ns, CAP_SETPCAP, |
879 | SECURITY_CAP_AUDIT) != 0) /*[4]*/ | 869 | SECURITY_CAP_AUDIT) != 0) /*[4]*/ |
880 | /* | 870 | /* |
@@ -940,7 +930,7 @@ int cap_vm_enough_memory(struct mm_struct *mm, long pages) | |||
940 | { | 930 | { |
941 | int cap_sys_admin = 0; | 931 | int cap_sys_admin = 0; |
942 | 932 | ||
943 | if (cap_capable(current, current_cred(), &init_user_ns, CAP_SYS_ADMIN, | 933 | if (cap_capable(current_cred(), &init_user_ns, CAP_SYS_ADMIN, |
944 | SECURITY_CAP_NOAUDIT) == 0) | 934 | SECURITY_CAP_NOAUDIT) == 0) |
945 | cap_sys_admin = 1; | 935 | cap_sys_admin = 1; |
946 | return __vm_enough_memory(mm, pages, cap_sys_admin); | 936 | return __vm_enough_memory(mm, pages, cap_sys_admin); |
@@ -967,7 +957,7 @@ int cap_file_mmap(struct file *file, unsigned long reqprot, | |||
967 | int ret = 0; | 957 | int ret = 0; |
968 | 958 | ||
969 | if (addr < dac_mmap_min_addr) { | 959 | if (addr < dac_mmap_min_addr) { |
970 | ret = cap_capable(current, current_cred(), &init_user_ns, CAP_SYS_RAWIO, | 960 | ret = cap_capable(current_cred(), &init_user_ns, CAP_SYS_RAWIO, |
971 | SECURITY_CAP_AUDIT); | 961 | SECURITY_CAP_AUDIT); |
972 | /* set PF_SUPERPRIV if it turns out we allow the low mmap */ | 962 | /* set PF_SUPERPRIV if it turns out we allow the low mmap */ |
973 | if (ret == 0) | 963 | if (ret == 0) |
diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig index d384ea921482..5bd1cc1b4a54 100644 --- a/security/integrity/Kconfig +++ b/security/integrity/Kconfig | |||
@@ -3,11 +3,11 @@ config INTEGRITY | |||
3 | def_bool y | 3 | def_bool y |
4 | depends on IMA || EVM | 4 | depends on IMA || EVM |
5 | 5 | ||
6 | config INTEGRITY_DIGSIG | 6 | config INTEGRITY_SIGNATURE |
7 | boolean "Digital signature verification using multiple keyrings" | 7 | boolean "Digital signature verification using multiple keyrings" |
8 | depends on INTEGRITY && KEYS | 8 | depends on INTEGRITY && KEYS |
9 | default n | 9 | default n |
10 | select DIGSIG | 10 | select SIGNATURE |
11 | help | 11 | help |
12 | This option enables digital signature verification support | 12 | This option enables digital signature verification support |
13 | using multiple keyrings. It defines separate keyrings for each | 13 | using multiple keyrings. It defines separate keyrings for each |
diff --git a/security/integrity/Makefile b/security/integrity/Makefile index bece0563ee5e..d43799cc14f6 100644 --- a/security/integrity/Makefile +++ b/security/integrity/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_INTEGRITY) += integrity.o | 5 | obj-$(CONFIG_INTEGRITY) += integrity.o |
6 | obj-$(CONFIG_INTEGRITY_DIGSIG) += digsig.o | 6 | obj-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o |
7 | 7 | ||
8 | integrity-y := iint.o | 8 | integrity-y := iint.o |
9 | 9 | ||
diff --git a/security/integrity/ima/ima_audit.c b/security/integrity/ima/ima_audit.c index c5c5a72c30be..2ad942fb1e23 100644 --- a/security/integrity/ima/ima_audit.c +++ b/security/integrity/ima/ima_audit.c | |||
@@ -56,9 +56,11 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, | |||
56 | audit_log_format(ab, " name="); | 56 | audit_log_format(ab, " name="); |
57 | audit_log_untrustedstring(ab, fname); | 57 | audit_log_untrustedstring(ab, fname); |
58 | } | 58 | } |
59 | if (inode) | 59 | if (inode) { |
60 | audit_log_format(ab, " dev=%s ino=%lu", | 60 | audit_log_format(ab, " dev="); |
61 | inode->i_sb->s_id, inode->i_ino); | 61 | audit_log_untrustedstring(ab, inode->i_sb->s_id); |
62 | audit_log_format(ab, " ino=%lu", inode->i_ino); | ||
63 | } | ||
62 | audit_log_format(ab, " res=%d", !result ? 0 : 1); | 64 | audit_log_format(ab, " res=%d", !result ? 0 : 1); |
63 | audit_log_end(ab); | 65 | audit_log_end(ab); |
64 | } | 66 | } |
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index d661afbe474c..d45061d02fee 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c | |||
@@ -99,6 +99,7 @@ static bool ima_match_rules(struct ima_measure_rule_entry *rule, | |||
99 | struct inode *inode, enum ima_hooks func, int mask) | 99 | struct inode *inode, enum ima_hooks func, int mask) |
100 | { | 100 | { |
101 | struct task_struct *tsk = current; | 101 | struct task_struct *tsk = current; |
102 | const struct cred *cred = current_cred(); | ||
102 | int i; | 103 | int i; |
103 | 104 | ||
104 | if ((rule->flags & IMA_FUNC) && rule->func != func) | 105 | if ((rule->flags & IMA_FUNC) && rule->func != func) |
@@ -108,7 +109,7 @@ static bool ima_match_rules(struct ima_measure_rule_entry *rule, | |||
108 | if ((rule->flags & IMA_FSMAGIC) | 109 | if ((rule->flags & IMA_FSMAGIC) |
109 | && rule->fsmagic != inode->i_sb->s_magic) | 110 | && rule->fsmagic != inode->i_sb->s_magic) |
110 | return false; | 111 | return false; |
111 | if ((rule->flags & IMA_UID) && rule->uid != tsk->cred->uid) | 112 | if ((rule->flags & IMA_UID) && rule->uid != cred->uid) |
112 | return false; | 113 | return false; |
113 | for (i = 0; i < MAX_LSM_RULES; i++) { | 114 | for (i = 0; i < MAX_LSM_RULES; i++) { |
114 | int rc = 0; | 115 | int rc = 0; |
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 4da6ba81d153..7a25ecec5aaa 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h | |||
@@ -51,7 +51,7 @@ struct integrity_iint_cache *integrity_iint_find(struct inode *inode); | |||
51 | #define INTEGRITY_KEYRING_IMA 2 | 51 | #define INTEGRITY_KEYRING_IMA 2 |
52 | #define INTEGRITY_KEYRING_MAX 3 | 52 | #define INTEGRITY_KEYRING_MAX 3 |
53 | 53 | ||
54 | #ifdef CONFIG_INTEGRITY_DIGSIG | 54 | #ifdef CONFIG_INTEGRITY_SIGNATURE |
55 | 55 | ||
56 | int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, | 56 | int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen, |
57 | const char *digest, int digestlen); | 57 | const char *digest, int digestlen); |
@@ -65,7 +65,7 @@ static inline int integrity_digsig_verify(const unsigned int id, | |||
65 | return -EOPNOTSUPP; | 65 | return -EOPNOTSUPP; |
66 | } | 66 | } |
67 | 67 | ||
68 | #endif /* CONFIG_INTEGRITY_DIGSIG */ | 68 | #endif /* CONFIG_INTEGRITY_SIGNATURE */ |
69 | 69 | ||
70 | /* set during initialization */ | 70 | /* set during initialization */ |
71 | extern int iint_initialized; | 71 | extern int iint_initialized; |
diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c index 41144f71d615..2d1bb8af7696 100644 --- a/security/keys/encrypted-keys/encrypted.c +++ b/security/keys/encrypted-keys/encrypted.c | |||
@@ -314,7 +314,7 @@ static struct key *request_user_key(const char *master_desc, u8 **master_key, | |||
314 | goto error; | 314 | goto error; |
315 | 315 | ||
316 | down_read(&ukey->sem); | 316 | down_read(&ukey->sem); |
317 | upayload = rcu_dereference(ukey->payload.data); | 317 | upayload = ukey->payload.data; |
318 | *master_key = upayload->data; | 318 | *master_key = upayload->data; |
319 | *master_keylen = upayload->datalen; | 319 | *master_keylen = upayload->datalen; |
320 | error: | 320 | error: |
@@ -810,7 +810,7 @@ static int encrypted_instantiate(struct key *key, const void *data, | |||
810 | goto out; | 810 | goto out; |
811 | } | 811 | } |
812 | 812 | ||
813 | rcu_assign_pointer(key->payload.data, epayload); | 813 | rcu_assign_keypointer(key, epayload); |
814 | out: | 814 | out: |
815 | kfree(datablob); | 815 | kfree(datablob); |
816 | return ret; | 816 | return ret; |
@@ -874,7 +874,7 @@ static int encrypted_update(struct key *key, const void *data, size_t datalen) | |||
874 | memcpy(new_epayload->payload_data, epayload->payload_data, | 874 | memcpy(new_epayload->payload_data, epayload->payload_data, |
875 | epayload->payload_datalen); | 875 | epayload->payload_datalen); |
876 | 876 | ||
877 | rcu_assign_pointer(key->payload.data, new_epayload); | 877 | rcu_assign_keypointer(key, new_epayload); |
878 | call_rcu(&epayload->rcu, encrypted_rcu_free); | 878 | call_rcu(&epayload->rcu, encrypted_rcu_free); |
879 | out: | 879 | out: |
880 | kfree(buf); | 880 | kfree(buf); |
diff --git a/security/keys/encrypted-keys/masterkey_trusted.c b/security/keys/encrypted-keys/masterkey_trusted.c index df87272e3f51..013f7e5d3a2f 100644 --- a/security/keys/encrypted-keys/masterkey_trusted.c +++ b/security/keys/encrypted-keys/masterkey_trusted.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/err.h> | 19 | #include <linux/err.h> |
20 | #include <keys/trusted-type.h> | 20 | #include <keys/trusted-type.h> |
21 | #include <keys/encrypted-type.h> | ||
22 | #include "encrypted.h" | ||
21 | 23 | ||
22 | /* | 24 | /* |
23 | * request_trusted_key - request the trusted key | 25 | * request_trusted_key - request the trusted key |
@@ -37,7 +39,7 @@ struct key *request_trusted_key(const char *trusted_desc, | |||
37 | goto error; | 39 | goto error; |
38 | 40 | ||
39 | down_read(&tkey->sem); | 41 | down_read(&tkey->sem); |
40 | tpayload = rcu_dereference(tkey->payload.data); | 42 | tpayload = tkey->payload.data; |
41 | *master_key = tpayload->key; | 43 | *master_key = tpayload->key; |
42 | *master_keylen = tpayload->key_len; | 44 | *master_keylen = tpayload->key_len; |
43 | error: | 45 | error: |
diff --git a/security/keys/gc.c b/security/keys/gc.c index bf4d8da5a795..a42b45531aac 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c | |||
@@ -145,7 +145,9 @@ static void key_gc_keyring(struct key *keyring, time_t limit) | |||
145 | if (!klist) | 145 | if (!klist) |
146 | goto unlock_dont_gc; | 146 | goto unlock_dont_gc; |
147 | 147 | ||
148 | for (loop = klist->nkeys - 1; loop >= 0; loop--) { | 148 | loop = klist->nkeys; |
149 | smp_rmb(); | ||
150 | for (loop--; loop >= 0; loop--) { | ||
149 | key = klist->keys[loop]; | 151 | key = klist->keys[loop]; |
150 | if (test_bit(KEY_FLAG_DEAD, &key->flags) || | 152 | if (test_bit(KEY_FLAG_DEAD, &key->flags) || |
151 | (key->expiry > 0 && key->expiry <= limit)) | 153 | (key->expiry > 0 && key->expiry <= limit)) |
diff --git a/security/keys/internal.h b/security/keys/internal.h index c7a7caec4830..65647f825584 100644 --- a/security/keys/internal.h +++ b/security/keys/internal.h | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | extern struct key_type key_type_dead; | 34 | extern struct key_type key_type_dead; |
35 | extern struct key_type key_type_user; | 35 | extern struct key_type key_type_user; |
36 | extern struct key_type key_type_logon; | ||
36 | 37 | ||
37 | /*****************************************************************************/ | 38 | /*****************************************************************************/ |
38 | /* | 39 | /* |
diff --git a/security/keys/key.c b/security/keys/key.c index 4f64c7267afb..7ada8019be1f 100644 --- a/security/keys/key.c +++ b/security/keys/key.c | |||
@@ -999,6 +999,7 @@ void __init key_init(void) | |||
999 | list_add_tail(&key_type_keyring.link, &key_types_list); | 999 | list_add_tail(&key_type_keyring.link, &key_types_list); |
1000 | list_add_tail(&key_type_dead.link, &key_types_list); | 1000 | list_add_tail(&key_type_dead.link, &key_types_list); |
1001 | list_add_tail(&key_type_user.link, &key_types_list); | 1001 | list_add_tail(&key_type_user.link, &key_types_list); |
1002 | list_add_tail(&key_type_logon.link, &key_types_list); | ||
1002 | 1003 | ||
1003 | /* record the root user tracking */ | 1004 | /* record the root user tracking */ |
1004 | rb_link_node(&root_key_user.node, | 1005 | rb_link_node(&root_key_user.node, |
diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 37a7f3b28852..d605f75292e4 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c | |||
@@ -319,7 +319,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, | |||
319 | struct key *keyring, *key; | 319 | struct key *keyring, *key; |
320 | key_ref_t key_ref; | 320 | key_ref_t key_ref; |
321 | long err; | 321 | long err; |
322 | int sp, kix; | 322 | int sp, nkeys, kix; |
323 | 323 | ||
324 | keyring = key_ref_to_ptr(keyring_ref); | 324 | keyring = key_ref_to_ptr(keyring_ref); |
325 | possessed = is_key_possessed(keyring_ref); | 325 | possessed = is_key_possessed(keyring_ref); |
@@ -380,7 +380,9 @@ descend: | |||
380 | goto not_this_keyring; | 380 | goto not_this_keyring; |
381 | 381 | ||
382 | /* iterate through the keys in this keyring first */ | 382 | /* iterate through the keys in this keyring first */ |
383 | for (kix = 0; kix < keylist->nkeys; kix++) { | 383 | nkeys = keylist->nkeys; |
384 | smp_rmb(); | ||
385 | for (kix = 0; kix < nkeys; kix++) { | ||
384 | key = keylist->keys[kix]; | 386 | key = keylist->keys[kix]; |
385 | kflags = key->flags; | 387 | kflags = key->flags; |
386 | 388 | ||
@@ -421,7 +423,9 @@ descend: | |||
421 | /* search through the keyrings nested in this one */ | 423 | /* search through the keyrings nested in this one */ |
422 | kix = 0; | 424 | kix = 0; |
423 | ascend: | 425 | ascend: |
424 | for (; kix < keylist->nkeys; kix++) { | 426 | nkeys = keylist->nkeys; |
427 | smp_rmb(); | ||
428 | for (; kix < nkeys; kix++) { | ||
425 | key = keylist->keys[kix]; | 429 | key = keylist->keys[kix]; |
426 | if (key->type != &key_type_keyring) | 430 | if (key->type != &key_type_keyring) |
427 | continue; | 431 | continue; |
@@ -515,7 +519,7 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref, | |||
515 | struct keyring_list *klist; | 519 | struct keyring_list *klist; |
516 | unsigned long possessed; | 520 | unsigned long possessed; |
517 | struct key *keyring, *key; | 521 | struct key *keyring, *key; |
518 | int loop; | 522 | int nkeys, loop; |
519 | 523 | ||
520 | keyring = key_ref_to_ptr(keyring_ref); | 524 | keyring = key_ref_to_ptr(keyring_ref); |
521 | possessed = is_key_possessed(keyring_ref); | 525 | possessed = is_key_possessed(keyring_ref); |
@@ -524,7 +528,9 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref, | |||
524 | 528 | ||
525 | klist = rcu_dereference(keyring->payload.subscriptions); | 529 | klist = rcu_dereference(keyring->payload.subscriptions); |
526 | if (klist) { | 530 | if (klist) { |
527 | for (loop = 0; loop < klist->nkeys; loop++) { | 531 | nkeys = klist->nkeys; |
532 | smp_rmb(); | ||
533 | for (loop = 0; loop < nkeys ; loop++) { | ||
528 | key = klist->keys[loop]; | 534 | key = klist->keys[loop]; |
529 | 535 | ||
530 | if (key->type == ktype && | 536 | if (key->type == ktype && |
@@ -622,7 +628,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B) | |||
622 | 628 | ||
623 | struct keyring_list *keylist; | 629 | struct keyring_list *keylist; |
624 | struct key *subtree, *key; | 630 | struct key *subtree, *key; |
625 | int sp, kix, ret; | 631 | int sp, nkeys, kix, ret; |
626 | 632 | ||
627 | rcu_read_lock(); | 633 | rcu_read_lock(); |
628 | 634 | ||
@@ -645,7 +651,9 @@ descend: | |||
645 | 651 | ||
646 | ascend: | 652 | ascend: |
647 | /* iterate through the remaining keys in this keyring */ | 653 | /* iterate through the remaining keys in this keyring */ |
648 | for (; kix < keylist->nkeys; kix++) { | 654 | nkeys = keylist->nkeys; |
655 | smp_rmb(); | ||
656 | for (; kix < nkeys; kix++) { | ||
649 | key = keylist->keys[kix]; | 657 | key = keylist->keys[kix]; |
650 | 658 | ||
651 | if (key == A) | 659 | if (key == A) |
diff --git a/security/keys/trusted.c b/security/keys/trusted.c index 0ed5fdf238a2..2d5d041f2049 100644 --- a/security/keys/trusted.c +++ b/security/keys/trusted.c | |||
@@ -993,7 +993,7 @@ out: | |||
993 | kfree(datablob); | 993 | kfree(datablob); |
994 | kfree(options); | 994 | kfree(options); |
995 | if (!ret) | 995 | if (!ret) |
996 | rcu_assign_pointer(key->payload.data, payload); | 996 | rcu_assign_keypointer(key, payload); |
997 | else | 997 | else |
998 | kfree(payload); | 998 | kfree(payload); |
999 | return ret; | 999 | return ret; |
@@ -1067,7 +1067,7 @@ static int trusted_update(struct key *key, const void *data, size_t datalen) | |||
1067 | goto out; | 1067 | goto out; |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | rcu_assign_pointer(key->payload.data, new_p); | 1070 | rcu_assign_keypointer(key, new_p); |
1071 | call_rcu(&p->rcu, trusted_rcu_free); | 1071 | call_rcu(&p->rcu, trusted_rcu_free); |
1072 | out: | 1072 | out: |
1073 | kfree(datablob); | 1073 | kfree(datablob); |
diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c index 69ff52c08e97..c7660a25a3e4 100644 --- a/security/keys/user_defined.c +++ b/security/keys/user_defined.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
19 | #include "internal.h" | 19 | #include "internal.h" |
20 | 20 | ||
21 | static int logon_vet_description(const char *desc); | ||
22 | |||
21 | /* | 23 | /* |
22 | * user defined keys take an arbitrary string as the description and an | 24 | * user defined keys take an arbitrary string as the description and an |
23 | * arbitrary blob of data as the payload | 25 | * arbitrary blob of data as the payload |
@@ -36,6 +38,24 @@ struct key_type key_type_user = { | |||
36 | EXPORT_SYMBOL_GPL(key_type_user); | 38 | EXPORT_SYMBOL_GPL(key_type_user); |
37 | 39 | ||
38 | /* | 40 | /* |
41 | * This key type is essentially the same as key_type_user, but it does | ||
42 | * not define a .read op. This is suitable for storing username and | ||
43 | * password pairs in the keyring that you do not want to be readable | ||
44 | * from userspace. | ||
45 | */ | ||
46 | struct key_type key_type_logon = { | ||
47 | .name = "logon", | ||
48 | .instantiate = user_instantiate, | ||
49 | .update = user_update, | ||
50 | .match = user_match, | ||
51 | .revoke = user_revoke, | ||
52 | .destroy = user_destroy, | ||
53 | .describe = user_describe, | ||
54 | .vet_description = logon_vet_description, | ||
55 | }; | ||
56 | EXPORT_SYMBOL_GPL(key_type_logon); | ||
57 | |||
58 | /* | ||
39 | * instantiate a user defined key | 59 | * instantiate a user defined key |
40 | */ | 60 | */ |
41 | int user_instantiate(struct key *key, const void *data, size_t datalen) | 61 | int user_instantiate(struct key *key, const void *data, size_t datalen) |
@@ -59,7 +79,7 @@ int user_instantiate(struct key *key, const void *data, size_t datalen) | |||
59 | /* attach the data */ | 79 | /* attach the data */ |
60 | upayload->datalen = datalen; | 80 | upayload->datalen = datalen; |
61 | memcpy(upayload->data, data, datalen); | 81 | memcpy(upayload->data, data, datalen); |
62 | rcu_assign_pointer(key->payload.data, upayload); | 82 | rcu_assign_keypointer(key, upayload); |
63 | ret = 0; | 83 | ret = 0; |
64 | 84 | ||
65 | error: | 85 | error: |
@@ -98,7 +118,7 @@ int user_update(struct key *key, const void *data, size_t datalen) | |||
98 | if (ret == 0) { | 118 | if (ret == 0) { |
99 | /* attach the new data, displacing the old */ | 119 | /* attach the new data, displacing the old */ |
100 | zap = key->payload.data; | 120 | zap = key->payload.data; |
101 | rcu_assign_pointer(key->payload.data, upayload); | 121 | rcu_assign_keypointer(key, upayload); |
102 | key->expiry = 0; | 122 | key->expiry = 0; |
103 | } | 123 | } |
104 | 124 | ||
@@ -133,7 +153,7 @@ void user_revoke(struct key *key) | |||
133 | key_payload_reserve(key, 0); | 153 | key_payload_reserve(key, 0); |
134 | 154 | ||
135 | if (upayload) { | 155 | if (upayload) { |
136 | rcu_assign_pointer(key->payload.data, NULL); | 156 | rcu_assign_keypointer(key, NULL); |
137 | kfree_rcu(upayload, rcu); | 157 | kfree_rcu(upayload, rcu); |
138 | } | 158 | } |
139 | } | 159 | } |
@@ -189,3 +209,20 @@ long user_read(const struct key *key, char __user *buffer, size_t buflen) | |||
189 | } | 209 | } |
190 | 210 | ||
191 | EXPORT_SYMBOL_GPL(user_read); | 211 | EXPORT_SYMBOL_GPL(user_read); |
212 | |||
213 | /* Vet the description for a "logon" key */ | ||
214 | static int logon_vet_description(const char *desc) | ||
215 | { | ||
216 | char *p; | ||
217 | |||
218 | /* require a "qualified" description string */ | ||
219 | p = strchr(desc, ':'); | ||
220 | if (!p) | ||
221 | return -EINVAL; | ||
222 | |||
223 | /* also reject description with ':' as first char */ | ||
224 | if (p == desc) | ||
225 | return -EINVAL; | ||
226 | |||
227 | return 0; | ||
228 | } | ||
diff --git a/security/lsm_audit.c b/security/lsm_audit.c index 7bd6f138236b..293b8c45b1d1 100644 --- a/security/lsm_audit.c +++ b/security/lsm_audit.c | |||
@@ -232,13 +232,14 @@ static void dump_common_audit_data(struct audit_buffer *ab, | |||
232 | case LSM_AUDIT_DATA_PATH: { | 232 | case LSM_AUDIT_DATA_PATH: { |
233 | struct inode *inode; | 233 | struct inode *inode; |
234 | 234 | ||
235 | audit_log_d_path(ab, "path=", &a->u.path); | 235 | audit_log_d_path(ab, " path=", &a->u.path); |
236 | 236 | ||
237 | inode = a->u.path.dentry->d_inode; | 237 | inode = a->u.path.dentry->d_inode; |
238 | if (inode) | 238 | if (inode) { |
239 | audit_log_format(ab, " dev=%s ino=%lu", | 239 | audit_log_format(ab, " dev="); |
240 | inode->i_sb->s_id, | 240 | audit_log_untrustedstring(ab, inode->i_sb->s_id); |
241 | inode->i_ino); | 241 | audit_log_format(ab, " ino=%lu", inode->i_ino); |
242 | } | ||
242 | break; | 243 | break; |
243 | } | 244 | } |
244 | case LSM_AUDIT_DATA_DENTRY: { | 245 | case LSM_AUDIT_DATA_DENTRY: { |
@@ -248,10 +249,11 @@ static void dump_common_audit_data(struct audit_buffer *ab, | |||
248 | audit_log_untrustedstring(ab, a->u.dentry->d_name.name); | 249 | audit_log_untrustedstring(ab, a->u.dentry->d_name.name); |
249 | 250 | ||
250 | inode = a->u.dentry->d_inode; | 251 | inode = a->u.dentry->d_inode; |
251 | if (inode) | 252 | if (inode) { |
252 | audit_log_format(ab, " dev=%s ino=%lu", | 253 | audit_log_format(ab, " dev="); |
253 | inode->i_sb->s_id, | 254 | audit_log_untrustedstring(ab, inode->i_sb->s_id); |
254 | inode->i_ino); | 255 | audit_log_format(ab, " ino=%lu", inode->i_ino); |
256 | } | ||
255 | break; | 257 | break; |
256 | } | 258 | } |
257 | case LSM_AUDIT_DATA_INODE: { | 259 | case LSM_AUDIT_DATA_INODE: { |
@@ -266,8 +268,9 @@ static void dump_common_audit_data(struct audit_buffer *ab, | |||
266 | dentry->d_name.name); | 268 | dentry->d_name.name); |
267 | dput(dentry); | 269 | dput(dentry); |
268 | } | 270 | } |
269 | audit_log_format(ab, " dev=%s ino=%lu", inode->i_sb->s_id, | 271 | audit_log_format(ab, " dev="); |
270 | inode->i_ino); | 272 | audit_log_untrustedstring(ab, inode->i_sb->s_id); |
273 | audit_log_format(ab, " ino=%lu", inode->i_ino); | ||
271 | break; | 274 | break; |
272 | } | 275 | } |
273 | case LSM_AUDIT_DATA_TASK: | 276 | case LSM_AUDIT_DATA_TASK: |
@@ -315,7 +318,7 @@ static void dump_common_audit_data(struct audit_buffer *ab, | |||
315 | .dentry = u->dentry, | 318 | .dentry = u->dentry, |
316 | .mnt = u->mnt | 319 | .mnt = u->mnt |
317 | }; | 320 | }; |
318 | audit_log_d_path(ab, "path=", &path); | 321 | audit_log_d_path(ab, " path=", &path); |
319 | break; | 322 | break; |
320 | } | 323 | } |
321 | if (!u->addr) | 324 | if (!u->addr) |
diff --git a/security/security.c b/security/security.c index 214502c772ab..d7542493454d 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -155,35 +155,16 @@ int security_capset(struct cred *new, const struct cred *old, | |||
155 | effective, inheritable, permitted); | 155 | effective, inheritable, permitted); |
156 | } | 156 | } |
157 | 157 | ||
158 | int security_capable(struct user_namespace *ns, const struct cred *cred, | 158 | int security_capable(const struct cred *cred, struct user_namespace *ns, |
159 | int cap) | 159 | int cap) |
160 | { | 160 | { |
161 | return security_ops->capable(current, cred, ns, cap, | 161 | return security_ops->capable(cred, ns, cap, SECURITY_CAP_AUDIT); |
162 | SECURITY_CAP_AUDIT); | ||
163 | } | 162 | } |
164 | 163 | ||
165 | int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, | 164 | int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns, |
166 | int cap) | 165 | int cap) |
167 | { | 166 | { |
168 | const struct cred *cred; | 167 | return security_ops->capable(cred, ns, cap, SECURITY_CAP_NOAUDIT); |
169 | int ret; | ||
170 | |||
171 | cred = get_task_cred(tsk); | ||
172 | ret = security_ops->capable(tsk, cred, ns, cap, SECURITY_CAP_AUDIT); | ||
173 | put_cred(cred); | ||
174 | return ret; | ||
175 | } | ||
176 | |||
177 | int security_real_capable_noaudit(struct task_struct *tsk, | ||
178 | struct user_namespace *ns, int cap) | ||
179 | { | ||
180 | const struct cred *cred; | ||
181 | int ret; | ||
182 | |||
183 | cred = get_task_cred(tsk); | ||
184 | ret = security_ops->capable(tsk, cred, ns, cap, SECURITY_CAP_NOAUDIT); | ||
185 | put_cred(cred); | ||
186 | return ret; | ||
187 | } | 168 | } |
188 | 169 | ||
189 | int security_quotactl(int cmds, int type, int id, struct super_block *sb) | 170 | int security_quotactl(int cmds, int type, int id, struct super_block *sb) |
@@ -994,12 +975,6 @@ int security_netlink_send(struct sock *sk, struct sk_buff *skb) | |||
994 | return security_ops->netlink_send(sk, skb); | 975 | return security_ops->netlink_send(sk, skb); |
995 | } | 976 | } |
996 | 977 | ||
997 | int security_netlink_recv(struct sk_buff *skb, int cap) | ||
998 | { | ||
999 | return security_ops->netlink_recv(skb, cap); | ||
1000 | } | ||
1001 | EXPORT_SYMBOL(security_netlink_recv); | ||
1002 | |||
1003 | int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) | 978 | int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) |
1004 | { | 979 | { |
1005 | return security_ops->secid_to_secctx(secid, secdata, seclen); | 980 | return security_ops->secid_to_secctx(secid, secdata, seclen); |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 7cd4c3affac8..6a3683e28426 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -1415,8 +1415,7 @@ static int current_has_perm(const struct task_struct *tsk, | |||
1415 | #endif | 1415 | #endif |
1416 | 1416 | ||
1417 | /* Check whether a task is allowed to use a capability. */ | 1417 | /* Check whether a task is allowed to use a capability. */ |
1418 | static int task_has_capability(struct task_struct *tsk, | 1418 | static int cred_has_capability(const struct cred *cred, |
1419 | const struct cred *cred, | ||
1420 | int cap, int audit) | 1419 | int cap, int audit) |
1421 | { | 1420 | { |
1422 | struct common_audit_data ad; | 1421 | struct common_audit_data ad; |
@@ -1427,7 +1426,7 @@ static int task_has_capability(struct task_struct *tsk, | |||
1427 | int rc; | 1426 | int rc; |
1428 | 1427 | ||
1429 | COMMON_AUDIT_DATA_INIT(&ad, CAP); | 1428 | COMMON_AUDIT_DATA_INIT(&ad, CAP); |
1430 | ad.tsk = tsk; | 1429 | ad.tsk = current; |
1431 | ad.u.cap = cap; | 1430 | ad.u.cap = cap; |
1432 | 1431 | ||
1433 | switch (CAP_TO_INDEX(cap)) { | 1432 | switch (CAP_TO_INDEX(cap)) { |
@@ -1811,7 +1810,7 @@ static int selinux_ptrace_access_check(struct task_struct *child, | |||
1811 | if (rc) | 1810 | if (rc) |
1812 | return rc; | 1811 | return rc; |
1813 | 1812 | ||
1814 | if (mode == PTRACE_MODE_READ) { | 1813 | if (mode & PTRACE_MODE_READ) { |
1815 | u32 sid = current_sid(); | 1814 | u32 sid = current_sid(); |
1816 | u32 csid = task_sid(child); | 1815 | u32 csid = task_sid(child); |
1817 | return avc_has_perm(sid, csid, SECCLASS_FILE, FILE__READ, NULL); | 1816 | return avc_has_perm(sid, csid, SECCLASS_FILE, FILE__READ, NULL); |
@@ -1868,16 +1867,16 @@ static int selinux_capset(struct cred *new, const struct cred *old, | |||
1868 | * the CAP_SETUID and CAP_SETGID capabilities using the capable hook. | 1867 | * the CAP_SETUID and CAP_SETGID capabilities using the capable hook. |
1869 | */ | 1868 | */ |
1870 | 1869 | ||
1871 | static int selinux_capable(struct task_struct *tsk, const struct cred *cred, | 1870 | static int selinux_capable(const struct cred *cred, struct user_namespace *ns, |
1872 | struct user_namespace *ns, int cap, int audit) | 1871 | int cap, int audit) |
1873 | { | 1872 | { |
1874 | int rc; | 1873 | int rc; |
1875 | 1874 | ||
1876 | rc = cap_capable(tsk, cred, ns, cap, audit); | 1875 | rc = cap_capable(cred, ns, cap, audit); |
1877 | if (rc) | 1876 | if (rc) |
1878 | return rc; | 1877 | return rc; |
1879 | 1878 | ||
1880 | return task_has_capability(tsk, cred, cap, audit); | 1879 | return cred_has_capability(cred, cap, audit); |
1881 | } | 1880 | } |
1882 | 1881 | ||
1883 | static int selinux_quotactl(int cmds, int type, int id, struct super_block *sb) | 1882 | static int selinux_quotactl(int cmds, int type, int id, struct super_block *sb) |
@@ -1954,8 +1953,7 @@ static int selinux_vm_enough_memory(struct mm_struct *mm, long pages) | |||
1954 | { | 1953 | { |
1955 | int rc, cap_sys_admin = 0; | 1954 | int rc, cap_sys_admin = 0; |
1956 | 1955 | ||
1957 | rc = selinux_capable(current, current_cred(), | 1956 | rc = selinux_capable(current_cred(), &init_user_ns, CAP_SYS_ADMIN, |
1958 | &init_user_ns, CAP_SYS_ADMIN, | ||
1959 | SECURITY_CAP_NOAUDIT); | 1957 | SECURITY_CAP_NOAUDIT); |
1960 | if (rc == 0) | 1958 | if (rc == 0) |
1961 | cap_sys_admin = 1; | 1959 | cap_sys_admin = 1; |
@@ -2859,8 +2857,7 @@ static int selinux_inode_getsecurity(const struct inode *inode, const char *name | |||
2859 | * and lack of permission just means that we fall back to the | 2857 | * and lack of permission just means that we fall back to the |
2860 | * in-core context value, not a denial. | 2858 | * in-core context value, not a denial. |
2861 | */ | 2859 | */ |
2862 | error = selinux_capable(current, current_cred(), | 2860 | error = selinux_capable(current_cred(), &init_user_ns, CAP_MAC_ADMIN, |
2863 | &init_user_ns, CAP_MAC_ADMIN, | ||
2864 | SECURITY_CAP_NOAUDIT); | 2861 | SECURITY_CAP_NOAUDIT); |
2865 | if (!error) | 2862 | if (!error) |
2866 | error = security_sid_to_context_force(isec->sid, &context, | 2863 | error = security_sid_to_context_force(isec->sid, &context, |
@@ -2993,8 +2990,8 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd, | |||
2993 | 2990 | ||
2994 | case KDSKBENT: | 2991 | case KDSKBENT: |
2995 | case KDSKBSENT: | 2992 | case KDSKBSENT: |
2996 | error = task_has_capability(current, cred, CAP_SYS_TTY_CONFIG, | 2993 | error = cred_has_capability(cred, CAP_SYS_TTY_CONFIG, |
2997 | SECURITY_CAP_AUDIT); | 2994 | SECURITY_CAP_AUDIT); |
2998 | break; | 2995 | break; |
2999 | 2996 | ||
3000 | /* default case assumes that the command will go | 2997 | /* default case assumes that the command will go |
@@ -4718,24 +4715,6 @@ static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb) | |||
4718 | return selinux_nlmsg_perm(sk, skb); | 4715 | return selinux_nlmsg_perm(sk, skb); |
4719 | } | 4716 | } |
4720 | 4717 | ||
4721 | static int selinux_netlink_recv(struct sk_buff *skb, int capability) | ||
4722 | { | ||
4723 | int err; | ||
4724 | struct common_audit_data ad; | ||
4725 | u32 sid; | ||
4726 | |||
4727 | err = cap_netlink_recv(skb, capability); | ||
4728 | if (err) | ||
4729 | return err; | ||
4730 | |||
4731 | COMMON_AUDIT_DATA_INIT(&ad, CAP); | ||
4732 | ad.u.cap = capability; | ||
4733 | |||
4734 | security_task_getsecid(current, &sid); | ||
4735 | return avc_has_perm(sid, sid, SECCLASS_CAPABILITY, | ||
4736 | CAP_TO_MASK(capability), &ad); | ||
4737 | } | ||
4738 | |||
4739 | static int ipc_alloc_security(struct task_struct *task, | 4718 | static int ipc_alloc_security(struct task_struct *task, |
4740 | struct kern_ipc_perm *perm, | 4719 | struct kern_ipc_perm *perm, |
4741 | u16 sclass) | 4720 | u16 sclass) |
@@ -5464,7 +5443,6 @@ static struct security_operations selinux_ops = { | |||
5464 | .vm_enough_memory = selinux_vm_enough_memory, | 5443 | .vm_enough_memory = selinux_vm_enough_memory, |
5465 | 5444 | ||
5466 | .netlink_send = selinux_netlink_send, | 5445 | .netlink_send = selinux_netlink_send, |
5467 | .netlink_recv = selinux_netlink_recv, | ||
5468 | 5446 | ||
5469 | .bprm_set_creds = selinux_bprm_set_creds, | 5447 | .bprm_set_creds = selinux_bprm_set_creds, |
5470 | .bprm_committing_creds = selinux_bprm_committing_creds, | 5448 | .bprm_committing_creds = selinux_bprm_committing_creds, |
diff --git a/security/tomoyo/util.c b/security/tomoyo/util.c index 4a9b4b2eb755..867558c98334 100644 --- a/security/tomoyo/util.c +++ b/security/tomoyo/util.c | |||
@@ -492,13 +492,13 @@ static bool tomoyo_correct_word2(const char *string, size_t len) | |||
492 | if (d < '0' || d > '7' || e < '0' || e > '7') | 492 | if (d < '0' || d > '7' || e < '0' || e > '7') |
493 | break; | 493 | break; |
494 | c = tomoyo_make_byte(c, d, e); | 494 | c = tomoyo_make_byte(c, d, e); |
495 | if (tomoyo_invalid(c)) | 495 | if (c <= ' ' || c >= 127) |
496 | continue; /* pattern is not \000 */ | 496 | continue; |
497 | } | 497 | } |
498 | goto out; | 498 | goto out; |
499 | } else if (in_repetition && c == '/') { | 499 | } else if (in_repetition && c == '/') { |
500 | goto out; | 500 | goto out; |
501 | } else if (tomoyo_invalid(c)) { | 501 | } else if (c <= ' ' || c >= 127) { |
502 | goto out; | 502 | goto out; |
503 | } | 503 | } |
504 | } | 504 | } |