hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/security/tomoyo/common.h
....@@ -10,6 +10,8 @@
1010 #ifndef _SECURITY_TOMOYO_COMMON_H
1111 #define _SECURITY_TOMOYO_COMMON_H
1212
13
+#define pr_fmt(fmt) fmt
14
+
1315 #include <linux/ctype.h>
1416 #include <linux/string.h>
1517 #include <linux/mm.h>
....@@ -29,6 +31,7 @@
2931 #include <linux/in.h>
3032 #include <linux/in6.h>
3133 #include <linux/un.h>
34
+#include <linux/lsm_hooks.h>
3235 #include <net/sock.h>
3336 #include <net/af_unix.h>
3437 #include <net/ip.h>
....@@ -422,7 +425,7 @@
422425 struct tomoyo_obj_info *obj;
423426 /*
424427 * For holding parameters specific to execve() request.
425
- * NULL if not dealing do_execve().
428
+ * NULL if not dealing execve().
426429 */
427430 struct tomoyo_execve *ee;
428431 struct tomoyo_domain_info *domain;
....@@ -681,11 +684,12 @@
681684 const struct tomoyo_path_info *domainname;
682685 /* Namespace for this domain. Never NULL. */
683686 struct tomoyo_policy_namespace *ns;
687
+ /* Group numbers to use. */
688
+ unsigned long group[TOMOYO_MAX_ACL_GROUPS / BITS_PER_LONG];
684689 u8 profile; /* Profile number to use. */
685
- u8 group; /* Group number to use. */
686690 bool is_deleted; /* Delete flag. */
687691 bool flags[TOMOYO_MAX_DOMAIN_INFO_FLAGS];
688
- atomic_t users; /* Number of referring credentials. */
692
+ atomic_t users; /* Number of referring tasks. */
689693 };
690694
691695 /*
....@@ -787,9 +791,9 @@
787791 * interfaces.
788792 */
789793 struct tomoyo_io_buffer {
790
- void (*read) (struct tomoyo_io_buffer *);
791
- int (*write) (struct tomoyo_io_buffer *);
792
- __poll_t (*poll) (struct file *file, poll_table *wait);
794
+ void (*read)(struct tomoyo_io_buffer *head);
795
+ int (*write)(struct tomoyo_io_buffer *head);
796
+ __poll_t (*poll)(struct file *file, poll_table *wait);
793797 /* Exclusive lock for this structure. */
794798 struct mutex io_sem;
795799 char __user *read_user_buf;
....@@ -906,10 +910,16 @@
906910 struct list_head acl_group[TOMOYO_MAX_ACL_GROUPS];
907911 /* List for connecting to tomoyo_namespace_list list. */
908912 struct list_head namespace_list;
909
- /* Profile version. Currently only 20110903 is defined. */
913
+ /* Profile version. Currently only 20150505 is defined. */
910914 unsigned int profile_version;
911915 /* Name of this namespace (e.g. "<kernel>", "</usr/sbin/httpd>" ). */
912916 const char *name;
917
+};
918
+
919
+/* Structure for "struct task_struct"->security. */
920
+struct tomoyo_task {
921
+ struct tomoyo_domain_info *domain_info;
922
+ struct tomoyo_domain_info *old_domain_info;
913923 };
914924
915925 /********** Function prototypes. **********/
....@@ -1020,6 +1030,7 @@
10201030 struct tomoyo_condition *tomoyo_get_condition(struct tomoyo_acl_param *param);
10211031 struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
10221032 const bool transit);
1033
+struct tomoyo_domain_info *tomoyo_domain(void);
10231034 struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname);
10241035 struct tomoyo_group *tomoyo_get_group(struct tomoyo_acl_param *param,
10251036 const u8 idx);
....@@ -1034,8 +1045,8 @@
10341045 void __init tomoyo_load_builtin_policy(void);
10351046 void __init tomoyo_mm_init(void);
10361047 void tomoyo_check_acl(struct tomoyo_request_info *r,
1037
- bool (*check_entry) (struct tomoyo_request_info *,
1038
- const struct tomoyo_acl_info *));
1048
+ bool (*check_entry)(struct tomoyo_request_info *,
1049
+ const struct tomoyo_acl_info *));
10391050 void tomoyo_check_profile(void);
10401051 void tomoyo_convert_time(time64_t time, struct tomoyo_time *stamp);
10411052 void tomoyo_del_condition(struct list_head *element);
....@@ -1062,6 +1073,7 @@
10621073 /********** External variable definitions. **********/
10631074
10641075 extern bool tomoyo_policy_loaded;
1076
+extern int tomoyo_enabled;
10651077 extern const char * const tomoyo_condition_keyword
10661078 [TOMOYO_MAX_CONDITION_KEYWORD];
10671079 extern const char * const tomoyo_dif[TOMOYO_MAX_DOMAIN_INFO_FLAGS];
....@@ -1085,6 +1097,7 @@
10851097 extern struct tomoyo_policy_namespace tomoyo_kernel_namespace;
10861098 extern unsigned int tomoyo_memory_quota[TOMOYO_MAX_MEMORY_STAT];
10871099 extern unsigned int tomoyo_memory_used[TOMOYO_MAX_MEMORY_STAT];
1100
+extern struct lsm_blob_sizes tomoyo_blob_sizes;
10881101
10891102 /********** Inlined functions. **********/
10901103
....@@ -1121,6 +1134,7 @@
11211134 static inline pid_t tomoyo_sys_getppid(void)
11221135 {
11231136 pid_t pid;
1137
+
11241138 rcu_read_lock();
11251139 pid = task_tgid_vnr(rcu_dereference(current->real_parent));
11261140 rcu_read_unlock();
....@@ -1197,26 +1211,15 @@
11971211 }
11981212
11991213 /**
1200
- * tomoyo_domain - Get "struct tomoyo_domain_info" for current thread.
1214
+ * tomoyo_task - Get "struct tomoyo_task" for specified thread.
12011215 *
1202
- * Returns pointer to "struct tomoyo_domain_info" for current thread.
1216
+ * @task - Pointer to "struct task_struct".
1217
+ *
1218
+ * Returns pointer to "struct tomoyo_task" for specified thread.
12031219 */
1204
-static inline struct tomoyo_domain_info *tomoyo_domain(void)
1220
+static inline struct tomoyo_task *tomoyo_task(struct task_struct *task)
12051221 {
1206
- return current_cred()->security;
1207
-}
1208
-
1209
-/**
1210
- * tomoyo_real_domain - Get "struct tomoyo_domain_info" for specified thread.
1211
- *
1212
- * @task: Pointer to "struct task_struct".
1213
- *
1214
- * Returns pointer to "struct tomoyo_security" for specified thread.
1215
- */
1216
-static inline struct tomoyo_domain_info *tomoyo_real_domain(struct task_struct
1217
- *task)
1218
-{
1219
- return task_cred_xxx(task, security);
1222
+ return task->security + tomoyo_blob_sizes.lbs_task;
12201223 }
12211224
12221225 /**