aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/common.h
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2011-09-10 02:22:48 -0400
committerJames Morris <jmorris@namei.org>2011-09-13 18:27:05 -0400
commitd58e0da854376841ac99defeb117a83f086715c6 (patch)
treeb6e37d1030180680a7801ecb295d8d3990930375 /security/tomoyo/common.h
parent5dbe3040c74eef18e66951347eda05b153e69328 (diff)
TOMOYO: Add environment variable name restriction support.
This patch adds support for checking environment variable's names. Although TOMOYO already provides ability to check argv[]/envp[] passed to execve() requests, file execute /bin/sh exec.envp["LD_LIBRARY_PATH"]="bar" will reject execution of /bin/sh if environment variable LD_LIBRARY_PATH is not defined. To grant execution of /bin/sh if LD_LIBRARY_PATH is not defined, administrators have to specify like file execute /bin/sh exec.envp["LD_LIBRARY_PATH"]="/system/lib" file execute /bin/sh exec.envp["LD_LIBRARY_PATH"]=NULL . Since there are many environment variables whereas conditional checks are applied as "&&", it is difficult to cover all combinations. Therefore, this patch supports conditional checks that are applied as "||", by specifying like file execute /bin/sh misc env LD_LIBRARY_PATH exec.envp["LD_LIBRARY_PATH"]="/system/lib" which means "grant execution of /bin/sh if environment variable is not defined or is defined and its value is /system/lib". Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/common.h')
-rw-r--r--security/tomoyo/common.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h
index f7fbaa66e443..63720a328edd 100644
--- a/security/tomoyo/common.h
+++ b/security/tomoyo/common.h
@@ -196,6 +196,7 @@ enum tomoyo_acl_entry_type_index {
196 TOMOYO_TYPE_PATH_NUMBER_ACL, 196 TOMOYO_TYPE_PATH_NUMBER_ACL,
197 TOMOYO_TYPE_MKDEV_ACL, 197 TOMOYO_TYPE_MKDEV_ACL,
198 TOMOYO_TYPE_MOUNT_ACL, 198 TOMOYO_TYPE_MOUNT_ACL,
199 TOMOYO_TYPE_ENV_ACL,
199}; 200};
200 201
201/* Index numbers for access controls with one pathname. */ 202/* Index numbers for access controls with one pathname. */
@@ -300,12 +301,14 @@ enum tomoyo_mac_index {
300 TOMOYO_MAC_FILE_MOUNT, 301 TOMOYO_MAC_FILE_MOUNT,
301 TOMOYO_MAC_FILE_UMOUNT, 302 TOMOYO_MAC_FILE_UMOUNT,
302 TOMOYO_MAC_FILE_PIVOT_ROOT, 303 TOMOYO_MAC_FILE_PIVOT_ROOT,
304 TOMOYO_MAC_ENVIRON,
303 TOMOYO_MAX_MAC_INDEX 305 TOMOYO_MAX_MAC_INDEX
304}; 306};
305 307
306/* Index numbers for category of functionality. */ 308/* Index numbers for category of functionality. */
307enum tomoyo_mac_category_index { 309enum tomoyo_mac_category_index {
308 TOMOYO_MAC_CATEGORY_FILE, 310 TOMOYO_MAC_CATEGORY_FILE,
311 TOMOYO_MAC_CATEGORY_MISC,
309 TOMOYO_MAX_MAC_CATEGORY_INDEX 312 TOMOYO_MAX_MAC_CATEGORY_INDEX
310}; 313};
311 314
@@ -397,6 +400,9 @@ struct tomoyo_request_info {
397 u8 operation; 400 u8 operation;
398 } path_number; 401 } path_number;
399 struct { 402 struct {
403 const struct tomoyo_path_info *name;
404 } environ;
405 struct {
400 const struct tomoyo_path_info *type; 406 const struct tomoyo_path_info *type;
401 const struct tomoyo_path_info *dir; 407 const struct tomoyo_path_info *dir;
402 const struct tomoyo_path_info *dev; 408 const struct tomoyo_path_info *dev;
@@ -638,6 +644,12 @@ struct tomoyo_mount_acl {
638 struct tomoyo_number_union flags; 644 struct tomoyo_number_union flags;
639}; 645};
640 646
647/* Structure for "misc env" directive in domain policy. */
648struct tomoyo_env_acl {
649 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_ENV_ACL */
650 const struct tomoyo_path_info *env; /* environment variable */
651};
652
641/* Structure for holding a line from /sys/kernel/security/tomoyo/ interface. */ 653/* Structure for holding a line from /sys/kernel/security/tomoyo/ interface. */
642struct tomoyo_acl_param { 654struct tomoyo_acl_param {
643 char *data; 655 char *data;
@@ -820,6 +832,7 @@ const struct tomoyo_path_info *tomoyo_path_matches_group
820int tomoyo_check_open_permission(struct tomoyo_domain_info *domain, 832int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
821 struct path *path, const int flag); 833 struct path *path, const int flag);
822int tomoyo_close_control(struct tomoyo_io_buffer *head); 834int tomoyo_close_control(struct tomoyo_io_buffer *head);
835int tomoyo_env_perm(struct tomoyo_request_info *r, const char *env);
823int tomoyo_find_next_domain(struct linux_binprm *bprm); 836int tomoyo_find_next_domain(struct linux_binprm *bprm);
824int tomoyo_get_mode(const struct tomoyo_policy_namespace *ns, const u8 profile, 837int tomoyo_get_mode(const struct tomoyo_policy_namespace *ns, const u8 profile,
825 const u8 index); 838 const u8 index);
@@ -860,6 +873,7 @@ int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size,
860int tomoyo_write_aggregator(struct tomoyo_acl_param *param); 873int tomoyo_write_aggregator(struct tomoyo_acl_param *param);
861int tomoyo_write_file(struct tomoyo_acl_param *param); 874int tomoyo_write_file(struct tomoyo_acl_param *param);
862int tomoyo_write_group(struct tomoyo_acl_param *param, const u8 type); 875int tomoyo_write_group(struct tomoyo_acl_param *param, const u8 type);
876int tomoyo_write_misc(struct tomoyo_acl_param *param);
863int tomoyo_write_transition_control(struct tomoyo_acl_param *param, 877int tomoyo_write_transition_control(struct tomoyo_acl_param *param,
864 const u8 type); 878 const u8 type);
865ssize_t tomoyo_read_control(struct tomoyo_io_buffer *head, char __user *buffer, 879ssize_t tomoyo_read_control(struct tomoyo_io_buffer *head, char __user *buffer,