diff options
author | Felix Blyakher <felixb@sgi.com> | 2009-06-10 18:07:47 -0400 |
---|---|---|
committer | Felix Blyakher <felixb@sgi.com> | 2009-06-10 18:07:47 -0400 |
commit | 4e73e0eb633f8a1b5cbf20e7f42c6dbfec1d1ca7 (patch) | |
tree | 0cea46e43f0625244c3d06a71d6559e5ec5419ca /security | |
parent | 4156e735d3abde8e9243b5d22f7999dd3fffab2e (diff) | |
parent | 07a2039b8eb0af4ff464efd3dfd95de5c02648c6 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'security')
-rw-r--r-- | security/commoncap.c | 1 | ||||
-rw-r--r-- | security/device_cgroup.c | 21 | ||||
-rw-r--r-- | security/keys/request_key.c | 9 | ||||
-rw-r--r-- | security/security.c | 2 | ||||
-rw-r--r-- | security/selinux/hooks.c | 2 | ||||
-rw-r--r-- | security/smack/smack_lsm.c | 11 | ||||
-rw-r--r-- | security/tomoyo/common.c | 19 | ||||
-rw-r--r-- | security/tomoyo/common.h | 10 | ||||
-rw-r--r-- | security/tomoyo/domain.c | 92 | ||||
-rw-r--r-- | security/tomoyo/file.c | 2 | ||||
-rw-r--r-- | security/tomoyo/realpath.c | 19 | ||||
-rw-r--r-- | security/tomoyo/realpath.h | 2 | ||||
-rw-r--r-- | security/tomoyo/tomoyo.c | 8 | ||||
-rw-r--r-- | security/tomoyo/tomoyo.h | 2 |
14 files changed, 61 insertions, 139 deletions
diff --git a/security/commoncap.c b/security/commoncap.c index 7cd61a5f5205..beac0258c2a8 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
@@ -916,7 +916,6 @@ changed: | |||
916 | return commit_creds(new); | 916 | return commit_creds(new); |
917 | 917 | ||
918 | no_change: | 918 | no_change: |
919 | error = 0; | ||
920 | error: | 919 | error: |
921 | abort_creds(new); | 920 | abort_creds(new); |
922 | return error; | 921 | return error; |
diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 3aacd0fe7179..5fda7df19723 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/uaccess.h> | 11 | #include <linux/uaccess.h> |
12 | #include <linux/seq_file.h> | 12 | #include <linux/seq_file.h> |
13 | #include <linux/rcupdate.h> | 13 | #include <linux/rcupdate.h> |
14 | #include <linux/mutex.h> | ||
14 | 15 | ||
15 | #define ACC_MKNOD 1 | 16 | #define ACC_MKNOD 1 |
16 | #define ACC_READ 2 | 17 | #define ACC_READ 2 |
@@ -21,9 +22,11 @@ | |||
21 | #define DEV_CHAR 2 | 22 | #define DEV_CHAR 2 |
22 | #define DEV_ALL 4 /* this represents all devices */ | 23 | #define DEV_ALL 4 /* this represents all devices */ |
23 | 24 | ||
25 | static DEFINE_MUTEX(devcgroup_mutex); | ||
26 | |||
24 | /* | 27 | /* |
25 | * whitelist locking rules: | 28 | * whitelist locking rules: |
26 | * hold cgroup_lock() for update/read. | 29 | * hold devcgroup_mutex for update/read. |
27 | * hold rcu_read_lock() for read. | 30 | * hold rcu_read_lock() for read. |
28 | */ | 31 | */ |
29 | 32 | ||
@@ -67,7 +70,7 @@ static int devcgroup_can_attach(struct cgroup_subsys *ss, | |||
67 | } | 70 | } |
68 | 71 | ||
69 | /* | 72 | /* |
70 | * called under cgroup_lock() | 73 | * called under devcgroup_mutex |
71 | */ | 74 | */ |
72 | static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig) | 75 | static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig) |
73 | { | 76 | { |
@@ -92,7 +95,7 @@ free_and_exit: | |||
92 | 95 | ||
93 | /* Stupid prototype - don't bother combining existing entries */ | 96 | /* Stupid prototype - don't bother combining existing entries */ |
94 | /* | 97 | /* |
95 | * called under cgroup_lock() | 98 | * called under devcgroup_mutex |
96 | */ | 99 | */ |
97 | static int dev_whitelist_add(struct dev_cgroup *dev_cgroup, | 100 | static int dev_whitelist_add(struct dev_cgroup *dev_cgroup, |
98 | struct dev_whitelist_item *wh) | 101 | struct dev_whitelist_item *wh) |
@@ -130,7 +133,7 @@ static void whitelist_item_free(struct rcu_head *rcu) | |||
130 | } | 133 | } |
131 | 134 | ||
132 | /* | 135 | /* |
133 | * called under cgroup_lock() | 136 | * called under devcgroup_mutex |
134 | */ | 137 | */ |
135 | static void dev_whitelist_rm(struct dev_cgroup *dev_cgroup, | 138 | static void dev_whitelist_rm(struct dev_cgroup *dev_cgroup, |
136 | struct dev_whitelist_item *wh) | 139 | struct dev_whitelist_item *wh) |
@@ -185,8 +188,10 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup_subsys *ss, | |||
185 | list_add(&wh->list, &dev_cgroup->whitelist); | 188 | list_add(&wh->list, &dev_cgroup->whitelist); |
186 | } else { | 189 | } else { |
187 | parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup); | 190 | parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup); |
191 | mutex_lock(&devcgroup_mutex); | ||
188 | ret = dev_whitelist_copy(&dev_cgroup->whitelist, | 192 | ret = dev_whitelist_copy(&dev_cgroup->whitelist, |
189 | &parent_dev_cgroup->whitelist); | 193 | &parent_dev_cgroup->whitelist); |
194 | mutex_unlock(&devcgroup_mutex); | ||
190 | if (ret) { | 195 | if (ret) { |
191 | kfree(dev_cgroup); | 196 | kfree(dev_cgroup); |
192 | return ERR_PTR(ret); | 197 | return ERR_PTR(ret); |
@@ -273,7 +278,7 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft, | |||
273 | * does the access granted to dev_cgroup c contain the access | 278 | * does the access granted to dev_cgroup c contain the access |
274 | * requested in whitelist item refwh. | 279 | * requested in whitelist item refwh. |
275 | * return 1 if yes, 0 if no. | 280 | * return 1 if yes, 0 if no. |
276 | * call with c->lock held | 281 | * call with devcgroup_mutex held |
277 | */ | 282 | */ |
278 | static int may_access_whitelist(struct dev_cgroup *c, | 283 | static int may_access_whitelist(struct dev_cgroup *c, |
279 | struct dev_whitelist_item *refwh) | 284 | struct dev_whitelist_item *refwh) |
@@ -426,11 +431,11 @@ static int devcgroup_access_write(struct cgroup *cgrp, struct cftype *cft, | |||
426 | const char *buffer) | 431 | const char *buffer) |
427 | { | 432 | { |
428 | int retval; | 433 | int retval; |
429 | if (!cgroup_lock_live_group(cgrp)) | 434 | |
430 | return -ENODEV; | 435 | mutex_lock(&devcgroup_mutex); |
431 | retval = devcgroup_update_access(cgroup_to_devcgroup(cgrp), | 436 | retval = devcgroup_update_access(cgroup_to_devcgroup(cgrp), |
432 | cft->private, buffer); | 437 | cft->private, buffer); |
433 | cgroup_unlock(); | 438 | mutex_unlock(&devcgroup_mutex); |
434 | return retval; | 439 | return retval; |
435 | } | 440 | } |
436 | 441 | ||
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 22a31582bfaa..03fe63ed55bd 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c | |||
@@ -311,7 +311,8 @@ static int construct_alloc_key(struct key_type *type, | |||
311 | 311 | ||
312 | set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); | 312 | set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); |
313 | 313 | ||
314 | down_write(&dest_keyring->sem); | 314 | if (dest_keyring) |
315 | down_write(&dest_keyring->sem); | ||
315 | 316 | ||
316 | /* attach the key to the destination keyring under lock, but we do need | 317 | /* attach the key to the destination keyring under lock, but we do need |
317 | * to do another check just in case someone beat us to it whilst we | 318 | * to do another check just in case someone beat us to it whilst we |
@@ -322,10 +323,12 @@ static int construct_alloc_key(struct key_type *type, | |||
322 | if (!IS_ERR(key_ref)) | 323 | if (!IS_ERR(key_ref)) |
323 | goto key_already_present; | 324 | goto key_already_present; |
324 | 325 | ||
325 | __key_link(dest_keyring, key); | 326 | if (dest_keyring) |
327 | __key_link(dest_keyring, key); | ||
326 | 328 | ||
327 | mutex_unlock(&key_construction_mutex); | 329 | mutex_unlock(&key_construction_mutex); |
328 | up_write(&dest_keyring->sem); | 330 | if (dest_keyring) |
331 | up_write(&dest_keyring->sem); | ||
329 | mutex_unlock(&user->cons_lock); | 332 | mutex_unlock(&user->cons_lock); |
330 | *_key = key; | 333 | *_key = key; |
331 | kleave(" = 0 [%d]", key_serial(key)); | 334 | kleave(" = 0 [%d]", key_serial(key)); |
diff --git a/security/security.c b/security/security.c index 206e53844d2f..5284255c5cdf 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -445,6 +445,7 @@ int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) | |||
445 | return 0; | 445 | return 0; |
446 | return security_ops->inode_create(dir, dentry, mode); | 446 | return security_ops->inode_create(dir, dentry, mode); |
447 | } | 447 | } |
448 | EXPORT_SYMBOL_GPL(security_inode_create); | ||
448 | 449 | ||
449 | int security_inode_link(struct dentry *old_dentry, struct inode *dir, | 450 | int security_inode_link(struct dentry *old_dentry, struct inode *dir, |
450 | struct dentry *new_dentry) | 451 | struct dentry *new_dentry) |
@@ -475,6 +476,7 @@ int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
475 | return 0; | 476 | return 0; |
476 | return security_ops->inode_mkdir(dir, dentry, mode); | 477 | return security_ops->inode_mkdir(dir, dentry, mode); |
477 | } | 478 | } |
479 | EXPORT_SYMBOL_GPL(security_inode_mkdir); | ||
478 | 480 | ||
479 | int security_inode_rmdir(struct inode *dir, struct dentry *dentry) | 481 | int security_inode_rmdir(struct inode *dir, struct dentry *dentry) |
480 | { | 482 | { |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index ba808ef6babb..2fcad7c33eaf 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -3153,7 +3153,7 @@ static int selinux_file_send_sigiotask(struct task_struct *tsk, | |||
3153 | struct fown_struct *fown, int signum) | 3153 | struct fown_struct *fown, int signum) |
3154 | { | 3154 | { |
3155 | struct file *file; | 3155 | struct file *file; |
3156 | u32 sid = current_sid(); | 3156 | u32 sid = task_sid(tsk); |
3157 | u32 perm; | 3157 | u32 perm; |
3158 | struct file_security_struct *fsec; | 3158 | struct file_security_struct *fsec; |
3159 | 3159 | ||
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 921514902eca..98b3195347ab 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
@@ -609,8 +609,12 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name, | |||
609 | strcmp(name, XATTR_NAME_SMACKIPOUT) == 0) { | 609 | strcmp(name, XATTR_NAME_SMACKIPOUT) == 0) { |
610 | if (!capable(CAP_MAC_ADMIN)) | 610 | if (!capable(CAP_MAC_ADMIN)) |
611 | rc = -EPERM; | 611 | rc = -EPERM; |
612 | /* a label cannot be void and cannot begin with '-' */ | 612 | /* |
613 | if (size == 0 || (size > 0 && ((char *)value)[0] == '-')) | 613 | * check label validity here so import wont fail on |
614 | * post_setxattr | ||
615 | */ | ||
616 | if (size == 0 || size >= SMK_LABELLEN || | ||
617 | smk_import(value, size) == NULL) | ||
614 | rc = -EINVAL; | 618 | rc = -EINVAL; |
615 | } else | 619 | } else |
616 | rc = cap_inode_setxattr(dentry, name, value, size, flags); | 620 | rc = cap_inode_setxattr(dentry, name, value, size, flags); |
@@ -644,9 +648,6 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name, | |||
644 | if (strcmp(name, XATTR_NAME_SMACK)) | 648 | if (strcmp(name, XATTR_NAME_SMACK)) |
645 | return; | 649 | return; |
646 | 650 | ||
647 | if (size >= SMK_LABELLEN) | ||
648 | return; | ||
649 | |||
650 | isp = dentry->d_inode->i_security; | 651 | isp = dentry->d_inode->i_security; |
651 | 652 | ||
652 | /* | 653 | /* |
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index 92cea656ad21..ddfb9cccf468 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
@@ -1252,15 +1252,12 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head) | |||
1252 | struct tomoyo_domain_info *domain = head->write_var1; | 1252 | struct tomoyo_domain_info *domain = head->write_var1; |
1253 | bool is_delete = false; | 1253 | bool is_delete = false; |
1254 | bool is_select = false; | 1254 | bool is_select = false; |
1255 | bool is_undelete = false; | ||
1256 | unsigned int profile; | 1255 | unsigned int profile; |
1257 | 1256 | ||
1258 | if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE)) | 1257 | if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_DELETE)) |
1259 | is_delete = true; | 1258 | is_delete = true; |
1260 | else if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_SELECT)) | 1259 | else if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_SELECT)) |
1261 | is_select = true; | 1260 | is_select = true; |
1262 | else if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_UNDELETE)) | ||
1263 | is_undelete = true; | ||
1264 | if (is_select && tomoyo_is_select_one(head, data)) | 1261 | if (is_select && tomoyo_is_select_one(head, data)) |
1265 | return 0; | 1262 | return 0; |
1266 | /* Don't allow updating policies by non manager programs. */ | 1263 | /* Don't allow updating policies by non manager programs. */ |
@@ -1274,9 +1271,7 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head) | |||
1274 | down_read(&tomoyo_domain_list_lock); | 1271 | down_read(&tomoyo_domain_list_lock); |
1275 | domain = tomoyo_find_domain(data); | 1272 | domain = tomoyo_find_domain(data); |
1276 | up_read(&tomoyo_domain_list_lock); | 1273 | up_read(&tomoyo_domain_list_lock); |
1277 | } else if (is_undelete) | 1274 | } else |
1278 | domain = tomoyo_undelete_domain(data); | ||
1279 | else | ||
1280 | domain = tomoyo_find_or_assign_new_domain(data, 0); | 1275 | domain = tomoyo_find_or_assign_new_domain(data, 0); |
1281 | head->write_var1 = domain; | 1276 | head->write_var1 = domain; |
1282 | return 0; | 1277 | return 0; |
@@ -1725,14 +1720,14 @@ static bool tomoyo_policy_loader_exists(void) | |||
1725 | * policies are not loaded yet. | 1720 | * policies are not loaded yet. |
1726 | * Thus, let do_execve() call this function everytime. | 1721 | * Thus, let do_execve() call this function everytime. |
1727 | */ | 1722 | */ |
1728 | struct nameidata nd; | 1723 | struct path path; |
1729 | 1724 | ||
1730 | if (path_lookup(tomoyo_loader, LOOKUP_FOLLOW, &nd)) { | 1725 | if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) { |
1731 | printk(KERN_INFO "Not activating Mandatory Access Control now " | 1726 | printk(KERN_INFO "Not activating Mandatory Access Control now " |
1732 | "since %s doesn't exist.\n", tomoyo_loader); | 1727 | "since %s doesn't exist.\n", tomoyo_loader); |
1733 | return false; | 1728 | return false; |
1734 | } | 1729 | } |
1735 | path_put(&nd.path); | 1730 | path_put(&path); |
1736 | return true; | 1731 | return true; |
1737 | } | 1732 | } |
1738 | 1733 | ||
@@ -1778,7 +1773,7 @@ void tomoyo_load_policy(const char *filename) | |||
1778 | envp[2] = NULL; | 1773 | envp[2] = NULL; |
1779 | call_usermodehelper(argv[0], argv, envp, 1); | 1774 | call_usermodehelper(argv[0], argv, envp, 1); |
1780 | 1775 | ||
1781 | printk(KERN_INFO "TOMOYO: 2.2.0-pre 2009/02/01\n"); | 1776 | printk(KERN_INFO "TOMOYO: 2.2.0 2009/04/01\n"); |
1782 | printk(KERN_INFO "Mandatory Access Control activated.\n"); | 1777 | printk(KERN_INFO "Mandatory Access Control activated.\n"); |
1783 | tomoyo_policy_loaded = true; | 1778 | tomoyo_policy_loaded = true; |
1784 | { /* Check all profiles currently assigned to domains are defined. */ | 1779 | { /* Check all profiles currently assigned to domains are defined. */ |
@@ -1805,7 +1800,7 @@ void tomoyo_load_policy(const char *filename) | |||
1805 | static int tomoyo_read_version(struct tomoyo_io_buffer *head) | 1800 | static int tomoyo_read_version(struct tomoyo_io_buffer *head) |
1806 | { | 1801 | { |
1807 | if (!head->read_eof) { | 1802 | if (!head->read_eof) { |
1808 | tomoyo_io_printf(head, "2.2.0-pre"); | 1803 | tomoyo_io_printf(head, "2.2.0"); |
1809 | head->read_eof = true; | 1804 | head->read_eof = true; |
1810 | } | 1805 | } |
1811 | return 0; | 1806 | return 0; |
diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h index 26a76d67aa1c..678f4ff16aa4 100644 --- a/security/tomoyo/common.h +++ b/security/tomoyo/common.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
@@ -88,10 +88,7 @@ struct tomoyo_domain_info { | |||
88 | /* Name of this domain. Never NULL. */ | 88 | /* Name of this domain. Never NULL. */ |
89 | const struct tomoyo_path_info *domainname; | 89 | const struct tomoyo_path_info *domainname; |
90 | u8 profile; /* Profile number to use. */ | 90 | u8 profile; /* Profile number to use. */ |
91 | u8 is_deleted; /* Delete flag. | 91 | bool is_deleted; /* Delete flag. */ |
92 | 0 = active. | ||
93 | 1 = deleted but undeletable. | ||
94 | 255 = deleted and no longer undeletable. */ | ||
95 | bool quota_warned; /* Quota warnning flag. */ | 92 | bool quota_warned; /* Quota warnning flag. */ |
96 | /* DOMAIN_FLAGS_*. Use tomoyo_set_domain_flag() to modify. */ | 93 | /* DOMAIN_FLAGS_*. Use tomoyo_set_domain_flag() to modify. */ |
97 | u8 flags; | 94 | u8 flags; |
@@ -144,7 +141,6 @@ struct tomoyo_double_path_acl_record { | |||
144 | #define TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN "no_initialize_domain " | 141 | #define TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN "no_initialize_domain " |
145 | #define TOMOYO_KEYWORD_NO_KEEP_DOMAIN "no_keep_domain " | 142 | #define TOMOYO_KEYWORD_NO_KEEP_DOMAIN "no_keep_domain " |
146 | #define TOMOYO_KEYWORD_SELECT "select " | 143 | #define TOMOYO_KEYWORD_SELECT "select " |
147 | #define TOMOYO_KEYWORD_UNDELETE "undelete " | ||
148 | #define TOMOYO_KEYWORD_USE_PROFILE "use_profile " | 144 | #define TOMOYO_KEYWORD_USE_PROFILE "use_profile " |
149 | #define TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "ignore_global_allow_read" | 145 | #define TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "ignore_global_allow_read" |
150 | /* A domain definition starts with <kernel>. */ | 146 | /* A domain definition starts with <kernel>. */ |
@@ -267,8 +263,6 @@ struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname); | |||
267 | struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char * | 263 | struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char * |
268 | domainname, | 264 | domainname, |
269 | const u8 profile); | 265 | const u8 profile); |
270 | /* Undelete a domain. */ | ||
271 | struct tomoyo_domain_info *tomoyo_undelete_domain(const char *domainname); | ||
272 | /* Check mode for specified functionality. */ | 266 | /* Check mode for specified functionality. */ |
273 | unsigned int tomoyo_check_flags(const struct tomoyo_domain_info *domain, | 267 | unsigned int tomoyo_check_flags(const struct tomoyo_domain_info *domain, |
274 | const u8 index); | 268 | const u8 index); |
diff --git a/security/tomoyo/domain.c b/security/tomoyo/domain.c index 093a756030bd..2d6748741a26 100644 --- a/security/tomoyo/domain.c +++ b/security/tomoyo/domain.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
@@ -551,9 +551,7 @@ int tomoyo_write_alias_policy(char *data, const bool is_delete) | |||
551 | return tomoyo_update_alias_entry(data, cp, is_delete); | 551 | return tomoyo_update_alias_entry(data, cp, is_delete); |
552 | } | 552 | } |
553 | 553 | ||
554 | /* Domain create/delete/undelete handler. */ | 554 | /* Domain create/delete handler. */ |
555 | |||
556 | /* #define TOMOYO_DEBUG_DOMAIN_UNDELETE */ | ||
557 | 555 | ||
558 | /** | 556 | /** |
559 | * tomoyo_delete_domain - Delete a domain. | 557 | * tomoyo_delete_domain - Delete a domain. |
@@ -571,41 +569,15 @@ int tomoyo_delete_domain(char *domainname) | |||
571 | tomoyo_fill_path_info(&name); | 569 | tomoyo_fill_path_info(&name); |
572 | /***** EXCLUSIVE SECTION START *****/ | 570 | /***** EXCLUSIVE SECTION START *****/ |
573 | down_write(&tomoyo_domain_list_lock); | 571 | down_write(&tomoyo_domain_list_lock); |
574 | #ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE | ||
575 | printk(KERN_DEBUG "tomoyo_delete_domain %s\n", domainname); | ||
576 | list_for_each_entry(domain, &tomoyo_domain_list, list) { | ||
577 | if (tomoyo_pathcmp(domain->domainname, &name)) | ||
578 | continue; | ||
579 | printk(KERN_DEBUG "List: %p %u\n", domain, domain->is_deleted); | ||
580 | } | ||
581 | #endif | ||
582 | /* Is there an active domain? */ | 572 | /* Is there an active domain? */ |
583 | list_for_each_entry(domain, &tomoyo_domain_list, list) { | 573 | list_for_each_entry(domain, &tomoyo_domain_list, list) { |
584 | struct tomoyo_domain_info *domain2; | ||
585 | /* Never delete tomoyo_kernel_domain */ | 574 | /* Never delete tomoyo_kernel_domain */ |
586 | if (domain == &tomoyo_kernel_domain) | 575 | if (domain == &tomoyo_kernel_domain) |
587 | continue; | 576 | continue; |
588 | if (domain->is_deleted || | 577 | if (domain->is_deleted || |
589 | tomoyo_pathcmp(domain->domainname, &name)) | 578 | tomoyo_pathcmp(domain->domainname, &name)) |
590 | continue; | 579 | continue; |
591 | /* Mark already deleted domains as non undeletable. */ | 580 | domain->is_deleted = true; |
592 | list_for_each_entry(domain2, &tomoyo_domain_list, list) { | ||
593 | if (!domain2->is_deleted || | ||
594 | tomoyo_pathcmp(domain2->domainname, &name)) | ||
595 | continue; | ||
596 | #ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE | ||
597 | if (domain2->is_deleted != 255) | ||
598 | printk(KERN_DEBUG | ||
599 | "Marked %p as non undeletable\n", | ||
600 | domain2); | ||
601 | #endif | ||
602 | domain2->is_deleted = 255; | ||
603 | } | ||
604 | /* Delete and mark active domain as undeletable. */ | ||
605 | domain->is_deleted = 1; | ||
606 | #ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE | ||
607 | printk(KERN_DEBUG "Marked %p as undeletable\n", domain); | ||
608 | #endif | ||
609 | break; | 581 | break; |
610 | } | 582 | } |
611 | up_write(&tomoyo_domain_list_lock); | 583 | up_write(&tomoyo_domain_list_lock); |
@@ -614,58 +586,6 @@ int tomoyo_delete_domain(char *domainname) | |||
614 | } | 586 | } |
615 | 587 | ||
616 | /** | 588 | /** |
617 | * tomoyo_undelete_domain - Undelete a domain. | ||
618 | * | ||
619 | * @domainname: The name of domain. | ||
620 | * | ||
621 | * Returns pointer to "struct tomoyo_domain_info" on success, NULL otherwise. | ||
622 | */ | ||
623 | struct tomoyo_domain_info *tomoyo_undelete_domain(const char *domainname) | ||
624 | { | ||
625 | struct tomoyo_domain_info *domain; | ||
626 | struct tomoyo_domain_info *candidate_domain = NULL; | ||
627 | struct tomoyo_path_info name; | ||
628 | |||
629 | name.name = domainname; | ||
630 | tomoyo_fill_path_info(&name); | ||
631 | /***** EXCLUSIVE SECTION START *****/ | ||
632 | down_write(&tomoyo_domain_list_lock); | ||
633 | #ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE | ||
634 | printk(KERN_DEBUG "tomoyo_undelete_domain %s\n", domainname); | ||
635 | list_for_each_entry(domain, &tomoyo_domain_list, list) { | ||
636 | if (tomoyo_pathcmp(domain->domainname, &name)) | ||
637 | continue; | ||
638 | printk(KERN_DEBUG "List: %p %u\n", domain, domain->is_deleted); | ||
639 | } | ||
640 | #endif | ||
641 | list_for_each_entry(domain, &tomoyo_domain_list, list) { | ||
642 | if (tomoyo_pathcmp(&name, domain->domainname)) | ||
643 | continue; | ||
644 | if (!domain->is_deleted) { | ||
645 | /* This domain is active. I can't undelete. */ | ||
646 | candidate_domain = NULL; | ||
647 | #ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE | ||
648 | printk(KERN_DEBUG "%p is active. I can't undelete.\n", | ||
649 | domain); | ||
650 | #endif | ||
651 | break; | ||
652 | } | ||
653 | /* Is this domain undeletable? */ | ||
654 | if (domain->is_deleted == 1) | ||
655 | candidate_domain = domain; | ||
656 | } | ||
657 | if (candidate_domain) { | ||
658 | candidate_domain->is_deleted = 0; | ||
659 | #ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE | ||
660 | printk(KERN_DEBUG "%p was undeleted.\n", candidate_domain); | ||
661 | #endif | ||
662 | } | ||
663 | up_write(&tomoyo_domain_list_lock); | ||
664 | /***** EXCLUSIVE SECTION END *****/ | ||
665 | return candidate_domain; | ||
666 | } | ||
667 | |||
668 | /** | ||
669 | * tomoyo_find_or_assign_new_domain - Create a domain. | 589 | * tomoyo_find_or_assign_new_domain - Create a domain. |
670 | * | 590 | * |
671 | * @domainname: The name of domain. | 591 | * @domainname: The name of domain. |
@@ -711,10 +631,6 @@ struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char * | |||
711 | /***** CRITICAL SECTION END *****/ | 631 | /***** CRITICAL SECTION END *****/ |
712 | if (flag) | 632 | if (flag) |
713 | continue; | 633 | continue; |
714 | #ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE | ||
715 | printk(KERN_DEBUG "Reusing %p %s\n", domain, | ||
716 | domain->domainname->name); | ||
717 | #endif | ||
718 | list_for_each_entry(ptr, &domain->acl_info_list, list) { | 634 | list_for_each_entry(ptr, &domain->acl_info_list, list) { |
719 | ptr->type |= TOMOYO_ACL_DELETED; | 635 | ptr->type |= TOMOYO_ACL_DELETED; |
720 | } | 636 | } |
@@ -722,7 +638,7 @@ struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char * | |||
722 | domain->profile = profile; | 638 | domain->profile = profile; |
723 | domain->quota_warned = false; | 639 | domain->quota_warned = false; |
724 | mb(); /* Avoid out-of-order execution. */ | 640 | mb(); /* Avoid out-of-order execution. */ |
725 | domain->is_deleted = 0; | 641 | domain->is_deleted = false; |
726 | goto out; | 642 | goto out; |
727 | } | 643 | } |
728 | /* No memory reusable. Create using new memory. */ | 644 | /* No memory reusable. Create using new memory. */ |
diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c index 65f50c1c5ee9..2316da8ec5bc 100644 --- a/security/tomoyo/file.c +++ b/security/tomoyo/file.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index d47f16b844b2..40927a84cb6e 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c | |||
@@ -5,13 +5,14 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | #include <linux/mount.h> | 13 | #include <linux/mount.h> |
14 | #include <linux/mnt_namespace.h> | 14 | #include <linux/mnt_namespace.h> |
15 | #include <linux/fs_struct.h> | ||
15 | #include "common.h" | 16 | #include "common.h" |
16 | #include "realpath.h" | 17 | #include "realpath.h" |
17 | 18 | ||
@@ -164,11 +165,11 @@ char *tomoyo_realpath_from_path(struct path *path) | |||
164 | */ | 165 | */ |
165 | char *tomoyo_realpath(const char *pathname) | 166 | char *tomoyo_realpath(const char *pathname) |
166 | { | 167 | { |
167 | struct nameidata nd; | 168 | struct path path; |
168 | 169 | ||
169 | if (pathname && path_lookup(pathname, LOOKUP_FOLLOW, &nd) == 0) { | 170 | if (pathname && kern_path(pathname, LOOKUP_FOLLOW, &path) == 0) { |
170 | char *buf = tomoyo_realpath_from_path(&nd.path); | 171 | char *buf = tomoyo_realpath_from_path(&path); |
171 | path_put(&nd.path); | 172 | path_put(&path); |
172 | return buf; | 173 | return buf; |
173 | } | 174 | } |
174 | return NULL; | 175 | return NULL; |
@@ -183,11 +184,11 @@ char *tomoyo_realpath(const char *pathname) | |||
183 | */ | 184 | */ |
184 | char *tomoyo_realpath_nofollow(const char *pathname) | 185 | char *tomoyo_realpath_nofollow(const char *pathname) |
185 | { | 186 | { |
186 | struct nameidata nd; | 187 | struct path path; |
187 | 188 | ||
188 | if (pathname && path_lookup(pathname, 0, &nd) == 0) { | 189 | if (pathname && kern_path(pathname, 0, &path) == 0) { |
189 | char *buf = tomoyo_realpath_from_path(&nd.path); | 190 | char *buf = tomoyo_realpath_from_path(&path); |
190 | path_put(&nd.path); | 191 | path_put(&path); |
191 | return buf; | 192 | return buf; |
192 | } | 193 | } |
193 | return NULL; | 194 | return NULL; |
diff --git a/security/tomoyo/realpath.h b/security/tomoyo/realpath.h index 7ec9fc9cbc07..78217a37960b 100644 --- a/security/tomoyo/realpath.h +++ b/security/tomoyo/realpath.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c index 3eeeae12c4dc..e42be5c4f055 100644 --- a/security/tomoyo/tomoyo.c +++ b/security/tomoyo/tomoyo.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
@@ -27,6 +27,12 @@ static int tomoyo_cred_prepare(struct cred *new, const struct cred *old, | |||
27 | 27 | ||
28 | static int tomoyo_bprm_set_creds(struct linux_binprm *bprm) | 28 | static int tomoyo_bprm_set_creds(struct linux_binprm *bprm) |
29 | { | 29 | { |
30 | int rc; | ||
31 | |||
32 | rc = cap_bprm_set_creds(bprm); | ||
33 | if (rc) | ||
34 | return rc; | ||
35 | |||
30 | /* | 36 | /* |
31 | * Do only if this function is called for the first time of an execve | 37 | * Do only if this function is called for the first time of an execve |
32 | * operation. | 38 | * operation. |
diff --git a/security/tomoyo/tomoyo.h b/security/tomoyo/tomoyo.h index a0c8f6e0bea4..41c6ebafb9c5 100644 --- a/security/tomoyo/tomoyo.h +++ b/security/tomoyo/tomoyo.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION | 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
7 | * | 7 | * |
8 | * Version: 2.2.0-pre 2009/02/01 | 8 | * Version: 2.2.0 2009/04/01 |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||