diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 14:08:27 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 14:08:27 -0400 |
| commit | d488d3a4ce08e96dad5cb3b6117517d57ccec98f (patch) | |
| tree | 169b09c589e38f6d5f2ea0a9e25c6a9fb3ebf783 /security | |
| parent | cb906953d2c3fd450655d9fa833f03690ad50c23 (diff) | |
| parent | 5deeb5cece3f9b30c8129786726b9d02c412c8ca (diff) | |
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem updates from James Morris:
"Highlights for this window:
- improved AVC hashing for SELinux by John Brooks and Stephen Smalley
- addition of an unconfined label to Smack
- Smack documentation update
- TPM driver updates"
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (28 commits)
lsm: copy comm before calling audit_log to avoid race in string printing
tomoyo: Do not generate empty policy files
tomoyo: Use if_changed when generating builtin-policy.h
tomoyo: Use bin2c to generate builtin-policy.h
selinux: increase avtab max buckets
selinux: Use a better hash function for avtab
selinux: convert avtab hash table to flex_array
selinux: reconcile security_netlbl_secattr_to_sid() and mls_import_netlbl_cat()
selinux: remove unnecessary pointer reassignment
Smack: Updates for Smack documentation
tpm/st33zp24/spi: Add missing device table for spi phy.
tpm/st33zp24: Add proper wait for ordinal duration in case of irq mode
smack: Fix gcc warning from unused smack_syslog_lock mutex in smackfs.c
Smack: Allow an unconfined label in bringup mode
Smack: getting the Smack security context of keys
Smack: Assign smack_known_web as default smk_in label for kernel thread's socket
tpm/tpm_infineon: Use struct dev_pm_ops for power management
MAINTAINERS: Add Jason as designated reviewer for TPM
tpm: Update KConfig text to include TPM2.0 FIFO chips
tpm/st33zp24/dts/st33zp24-spi: Add dts documentation for st33zp24 spi phy
...
Diffstat (limited to 'security')
| -rw-r--r-- | security/lsm_audit.c | 15 | ||||
| -rw-r--r-- | security/selinux/avc.c | 6 | ||||
| -rw-r--r-- | security/selinux/ss/avtab.c | 72 | ||||
| -rw-r--r-- | security/selinux/ss/avtab.h | 8 | ||||
| -rw-r--r-- | security/selinux/ss/mls.c | 10 | ||||
| -rw-r--r-- | security/selinux/ss/services.c | 6 | ||||
| -rw-r--r-- | security/smack/smack.h | 8 | ||||
| -rw-r--r-- | security/smack/smack_access.c | 43 | ||||
| -rw-r--r-- | security/smack/smack_lsm.c | 99 | ||||
| -rw-r--r-- | security/smack/smackfs.c | 97 | ||||
| -rw-r--r-- | security/tomoyo/.gitignore | 2 | ||||
| -rw-r--r-- | security/tomoyo/Kconfig | 1 | ||||
| -rw-r--r-- | security/tomoyo/Makefile | 55 | ||||
| -rw-r--r-- | security/tomoyo/policy/exception_policy.conf.default | 2 | ||||
| -rw-r--r-- | security/yama/Kconfig | 2 | ||||
| -rw-r--r-- | security/yama/yama_lsm.c | 13 |
16 files changed, 324 insertions, 115 deletions
diff --git a/security/lsm_audit.c b/security/lsm_audit.c index 69fdf3bc765b..b526ddc3add5 100644 --- a/security/lsm_audit.c +++ b/security/lsm_audit.c | |||
| @@ -211,7 +211,7 @@ static inline void print_ipv4_addr(struct audit_buffer *ab, __be32 addr, | |||
| 211 | static void dump_common_audit_data(struct audit_buffer *ab, | 211 | static void dump_common_audit_data(struct audit_buffer *ab, |
| 212 | struct common_audit_data *a) | 212 | struct common_audit_data *a) |
| 213 | { | 213 | { |
| 214 | struct task_struct *tsk = current; | 214 | char comm[sizeof(current->comm)]; |
| 215 | 215 | ||
| 216 | /* | 216 | /* |
| 217 | * To keep stack sizes in check force programers to notice if they | 217 | * To keep stack sizes in check force programers to notice if they |
| @@ -220,8 +220,8 @@ static void dump_common_audit_data(struct audit_buffer *ab, | |||
| 220 | */ | 220 | */ |
| 221 | BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2); | 221 | BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2); |
| 222 | 222 | ||
| 223 | audit_log_format(ab, " pid=%d comm=", task_pid_nr(tsk)); | 223 | audit_log_format(ab, " pid=%d comm=", task_pid_nr(current)); |
| 224 | audit_log_untrustedstring(ab, tsk->comm); | 224 | audit_log_untrustedstring(ab, memcpy(comm, current->comm, sizeof(comm))); |
| 225 | 225 | ||
| 226 | switch (a->type) { | 226 | switch (a->type) { |
| 227 | case LSM_AUDIT_DATA_NONE: | 227 | case LSM_AUDIT_DATA_NONE: |
| @@ -276,16 +276,19 @@ static void dump_common_audit_data(struct audit_buffer *ab, | |||
| 276 | audit_log_format(ab, " ino=%lu", inode->i_ino); | 276 | audit_log_format(ab, " ino=%lu", inode->i_ino); |
| 277 | break; | 277 | break; |
| 278 | } | 278 | } |
| 279 | case LSM_AUDIT_DATA_TASK: | 279 | case LSM_AUDIT_DATA_TASK: { |
| 280 | tsk = a->u.tsk; | 280 | struct task_struct *tsk = a->u.tsk; |
| 281 | if (tsk) { | 281 | if (tsk) { |
| 282 | pid_t pid = task_pid_nr(tsk); | 282 | pid_t pid = task_pid_nr(tsk); |
| 283 | if (pid) { | 283 | if (pid) { |
| 284 | char comm[sizeof(tsk->comm)]; | ||
| 284 | audit_log_format(ab, " pid=%d comm=", pid); | 285 | audit_log_format(ab, " pid=%d comm=", pid); |
| 285 | audit_log_untrustedstring(ab, tsk->comm); | 286 | audit_log_untrustedstring(ab, |
| 287 | memcpy(comm, tsk->comm, sizeof(comm))); | ||
| 286 | } | 288 | } |
| 287 | } | 289 | } |
| 288 | break; | 290 | break; |
| 291 | } | ||
| 289 | case LSM_AUDIT_DATA_NET: | 292 | case LSM_AUDIT_DATA_NET: |
| 290 | if (a->u.net->sk) { | 293 | if (a->u.net->sk) { |
| 291 | struct sock *sk = a->u.net->sk; | 294 | struct sock *sk = a->u.net->sk; |
diff --git a/security/selinux/avc.c b/security/selinux/avc.c index afcc0aed9393..3c17dda9571d 100644 --- a/security/selinux/avc.c +++ b/security/selinux/avc.c | |||
| @@ -724,12 +724,10 @@ inline int avc_has_perm_noaudit(u32 ssid, u32 tsid, | |||
| 724 | rcu_read_lock(); | 724 | rcu_read_lock(); |
| 725 | 725 | ||
| 726 | node = avc_lookup(ssid, tsid, tclass); | 726 | node = avc_lookup(ssid, tsid, tclass); |
| 727 | if (unlikely(!node)) { | 727 | if (unlikely(!node)) |
| 728 | node = avc_compute_av(ssid, tsid, tclass, avd); | 728 | node = avc_compute_av(ssid, tsid, tclass, avd); |
| 729 | } else { | 729 | else |
| 730 | memcpy(avd, &node->ae.avd, sizeof(*avd)); | 730 | memcpy(avd, &node->ae.avd, sizeof(*avd)); |
| 731 | avd = &node->ae.avd; | ||
| 732 | } | ||
| 733 | 731 | ||
| 734 | denied = requested & ~(avd->allowed); | 732 | denied = requested & ~(avd->allowed); |
| 735 | if (unlikely(denied)) | 733 | if (unlikely(denied)) |
diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c index a3dd9faa19c0..b64f2772b030 100644 --- a/security/selinux/ss/avtab.c +++ b/security/selinux/ss/avtab.c | |||
| @@ -25,10 +25,43 @@ | |||
| 25 | 25 | ||
| 26 | static struct kmem_cache *avtab_node_cachep; | 26 | static struct kmem_cache *avtab_node_cachep; |
| 27 | 27 | ||
| 28 | static inline int avtab_hash(struct avtab_key *keyp, u16 mask) | 28 | /* Based on MurmurHash3, written by Austin Appleby and placed in the |
| 29 | * public domain. | ||
| 30 | */ | ||
| 31 | static inline int avtab_hash(struct avtab_key *keyp, u32 mask) | ||
| 29 | { | 32 | { |
| 30 | return ((keyp->target_class + (keyp->target_type << 2) + | 33 | static const u32 c1 = 0xcc9e2d51; |
| 31 | (keyp->source_type << 9)) & mask); | 34 | static const u32 c2 = 0x1b873593; |
| 35 | static const u32 r1 = 15; | ||
| 36 | static const u32 r2 = 13; | ||
| 37 | static const u32 m = 5; | ||
| 38 | static const u32 n = 0xe6546b64; | ||
| 39 | |||
| 40 | u32 hash = 0; | ||
| 41 | |||
| 42 | #define mix(input) { \ | ||
| 43 | u32 v = input; \ | ||
| 44 | v *= c1; \ | ||
| 45 | v = (v << r1) | (v >> (32 - r1)); \ | ||
| 46 | v *= c2; \ | ||
| 47 | hash ^= v; \ | ||
| 48 | hash = (hash << r2) | (hash >> (32 - r2)); \ | ||
| 49 | hash = hash * m + n; \ | ||
| 50 | } | ||
| 51 | |||
| 52 | mix(keyp->target_class); | ||
| 53 | mix(keyp->target_type); | ||
| 54 | mix(keyp->source_type); | ||
| 55 | |||
| 56 | #undef mix | ||
| 57 | |||
| 58 | hash ^= hash >> 16; | ||
| 59 | hash *= 0x85ebca6b; | ||
| 60 | hash ^= hash >> 13; | ||
| 61 | hash *= 0xc2b2ae35; | ||
| 62 | hash ^= hash >> 16; | ||
| 63 | |||
| 64 | return hash & mask; | ||
| 32 | } | 65 | } |
| 33 | 66 | ||
| 34 | static struct avtab_node* | 67 | static struct avtab_node* |
| @@ -46,8 +79,12 @@ avtab_insert_node(struct avtab *h, int hvalue, | |||
| 46 | newnode->next = prev->next; | 79 | newnode->next = prev->next; |
| 47 | prev->next = newnode; | 80 | prev->next = newnode; |
| 48 | } else { | 81 | } else { |
| 49 | newnode->next = h->htable[hvalue]; | 82 | newnode->next = flex_array_get_ptr(h->htable, hvalue); |
| 50 | h->htable[hvalue] = newnode; | 83 | if (flex_array_put_ptr(h->htable, hvalue, newnode, |
| 84 | GFP_KERNEL|__GFP_ZERO)) { | ||
| 85 | kmem_cache_free(avtab_node_cachep, newnode); | ||
| 86 | return NULL; | ||
| 87 | } | ||
| 51 | } | 88 | } |
| 52 | 89 | ||
| 53 | h->nel++; | 90 | h->nel++; |
| @@ -64,7 +101,7 @@ static int avtab_insert(struct avtab *h, struct avtab_key *key, struct avtab_dat | |||
| 64 | return -EINVAL; | 101 | return -EINVAL; |
| 65 | 102 | ||
| 66 | hvalue = avtab_hash(key, h->mask); | 103 | hvalue = avtab_hash(key, h->mask); |
| 67 | for (prev = NULL, cur = h->htable[hvalue]; | 104 | for (prev = NULL, cur = flex_array_get_ptr(h->htable, hvalue); |
| 68 | cur; | 105 | cur; |
| 69 | prev = cur, cur = cur->next) { | 106 | prev = cur, cur = cur->next) { |
| 70 | if (key->source_type == cur->key.source_type && | 107 | if (key->source_type == cur->key.source_type && |
| @@ -104,7 +141,7 @@ avtab_insert_nonunique(struct avtab *h, struct avtab_key *key, struct avtab_datu | |||
| 104 | if (!h || !h->htable) | 141 | if (!h || !h->htable) |
| 105 | return NULL; | 142 | return NULL; |
| 106 | hvalue = avtab_hash(key, h->mask); | 143 | hvalue = avtab_hash(key, h->mask); |
| 107 | for (prev = NULL, cur = h->htable[hvalue]; | 144 | for (prev = NULL, cur = flex_array_get_ptr(h->htable, hvalue); |
| 108 | cur; | 145 | cur; |
