aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/common.h
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2011-06-26 10:18:58 -0400
committerJames Morris <jmorris@namei.org>2011-06-28 19:31:20 -0400
commiteadd99cc85347b4f9eb10122ac90032eb4971b02 (patch)
treefa6075ad4917422288222ee52bfcb66b7ed30a0e /security/tomoyo/common.h
parentd5ca1725ac9ba876c2dd614bb9826d0c4e13d818 (diff)
TOMOYO: Add auditing interface.
Add /sys/kernel/security/tomoyo/audit interface. This interface generates audit logs in the form of domain policy so that /usr/sbin/tomoyo-auditd can reuse audit logs for appending to /sys/kernel/security/tomoyo/domain_policy interface. 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.h83
1 files changed, 78 insertions, 5 deletions
diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h
index 2b39e63234c8..f40ec1fcbc5d 100644
--- a/security/tomoyo/common.h
+++ b/security/tomoyo/common.h
@@ -44,7 +44,10 @@ enum tomoyo_mode_index {
44 TOMOYO_CONFIG_LEARNING, 44 TOMOYO_CONFIG_LEARNING,
45 TOMOYO_CONFIG_PERMISSIVE, 45 TOMOYO_CONFIG_PERMISSIVE,
46 TOMOYO_CONFIG_ENFORCING, 46 TOMOYO_CONFIG_ENFORCING,
47 TOMOYO_CONFIG_USE_DEFAULT = 255 47 TOMOYO_CONFIG_MAX_MODE,
48 TOMOYO_CONFIG_WANT_REJECT_LOG = 64,
49 TOMOYO_CONFIG_WANT_GRANT_LOG = 128,
50 TOMOYO_CONFIG_USE_DEFAULT = 255,
48}; 51};
49 52
50/* Index numbers for entry type. */ 53/* Index numbers for entry type. */
@@ -115,6 +118,13 @@ enum tomoyo_path_acl_index {
115 TOMOYO_MAX_PATH_OPERATION 118 TOMOYO_MAX_PATH_OPERATION
116}; 119};
117 120
121enum tomoyo_memory_stat_type {
122 TOMOYO_MEMORY_POLICY,
123 TOMOYO_MEMORY_AUDIT,
124 TOMOYO_MEMORY_QUERY,
125 TOMOYO_MAX_MEMORY_STAT
126};
127
118enum tomoyo_mkdev_acl_index { 128enum tomoyo_mkdev_acl_index {
119 TOMOYO_TYPE_MKBLOCK, 129 TOMOYO_TYPE_MKBLOCK,
120 TOMOYO_TYPE_MKCHAR, 130 TOMOYO_TYPE_MKCHAR,
@@ -150,6 +160,7 @@ enum tomoyo_securityfs_interface_index {
150 TOMOYO_PROCESS_STATUS, 160 TOMOYO_PROCESS_STATUS,
151 TOMOYO_MEMINFO, 161 TOMOYO_MEMINFO,
152 TOMOYO_SELFDOMAIN, 162 TOMOYO_SELFDOMAIN,
163 TOMOYO_AUDIT,
153 TOMOYO_VERSION, 164 TOMOYO_VERSION,
154 TOMOYO_PROFILE, 165 TOMOYO_PROFILE,
155 TOMOYO_QUERY, 166 TOMOYO_QUERY,
@@ -213,6 +224,7 @@ enum tomoyo_mac_category_index {
213 224
214/* Index numbers for profile's PREFERENCE values. */ 225/* Index numbers for profile's PREFERENCE values. */
215enum tomoyo_pref_index { 226enum tomoyo_pref_index {
227 TOMOYO_PREF_MAX_AUDIT_LOG,
216 TOMOYO_PREF_MAX_LEARNING_ENTRY, 228 TOMOYO_PREF_MAX_LEARNING_ENTRY,
217 TOMOYO_MAX_PREF 229 TOMOYO_MAX_PREF
218}; 230};
@@ -506,13 +518,21 @@ struct tomoyo_profile {
506 unsigned int pref[TOMOYO_MAX_PREF]; 518 unsigned int pref[TOMOYO_MAX_PREF];
507}; 519};
508 520
521/* Structure for representing YYYY/MM/DD hh/mm/ss. */
522struct tomoyo_time {
523 u16 year;
524 u8 month;
525 u8 day;
526 u8 hour;
527 u8 min;
528 u8 sec;
529};
530
509/********** Function prototypes. **********/ 531/********** Function prototypes. **********/
510 532
511bool tomoyo_str_starts(char **src, const char *find); 533bool tomoyo_str_starts(char **src, const char *find);
512const char *tomoyo_get_exe(void); 534const char *tomoyo_get_exe(void);
513void tomoyo_normalize_line(unsigned char *buffer); 535void tomoyo_normalize_line(unsigned char *buffer);
514void tomoyo_warn_log(struct tomoyo_request_info *r, const char *fmt, ...)
515 __attribute__ ((format(printf, 2, 3)));
516void tomoyo_check_profile(void); 536void tomoyo_check_profile(void);
517int tomoyo_open_control(const u8 type, struct file *file); 537int tomoyo_open_control(const u8 type, struct file *file);
518int tomoyo_close_control(struct tomoyo_io_buffer *head); 538int tomoyo_close_control(struct tomoyo_io_buffer *head);
@@ -620,6 +640,14 @@ void tomoyo_check_acl(struct tomoyo_request_info *r,
620char *tomoyo_read_token(struct tomoyo_acl_param *param); 640char *tomoyo_read_token(struct tomoyo_acl_param *param);
621bool tomoyo_permstr(const char *string, const char *keyword); 641bool tomoyo_permstr(const char *string, const char *keyword);
622 642
643const char *tomoyo_yesno(const unsigned int value);
644void tomoyo_write_log2(struct tomoyo_request_info *r, int len, const char *fmt,
645 va_list args);
646void tomoyo_read_log(struct tomoyo_io_buffer *head);
647int tomoyo_poll_log(struct file *file, poll_table *wait);
648char *tomoyo_init_log(struct tomoyo_request_info *r, int len, const char *fmt,
649 va_list args);
650
623/********** External variable definitions. **********/ 651/********** External variable definitions. **********/
624 652
625/* Lock for GC. */ 653/* Lock for GC. */
@@ -650,8 +678,9 @@ extern const u8 tomoyo_pnnn2mac[TOMOYO_MAX_MKDEV_OPERATION];
650extern const u8 tomoyo_pp2mac[TOMOYO_MAX_PATH2_OPERATION]; 678extern const u8 tomoyo_pp2mac[TOMOYO_MAX_PATH2_OPERATION];
651extern const u8 tomoyo_pn2mac[TOMOYO_MAX_PATH_NUMBER_OPERATION]; 679extern const u8 tomoyo_pn2mac[TOMOYO_MAX_PATH_NUMBER_OPERATION];
652 680
653extern unsigned int tomoyo_quota_for_query; 681extern const char * const tomoyo_mode[TOMOYO_CONFIG_MAX_MODE];
654extern unsigned int tomoyo_query_memory_size; 682extern unsigned int tomoyo_memory_quota[TOMOYO_MAX_MEMORY_STAT];
683extern unsigned int tomoyo_memory_used[TOMOYO_MAX_MEMORY_STAT];
655 684
656/********** Inlined functions. **********/ 685/********** Inlined functions. **********/
657 686
@@ -773,6 +802,50 @@ static inline bool tomoyo_same_number_union
773 a->value_type[1] == b->value_type[1]; 802 a->value_type[1] == b->value_type[1];
774} 803}
775 804
805#if defined(CONFIG_SLOB)
806
807/**
808 * tomoyo_round2 - Round up to power of 2 for calculating memory usage.
809 *
810 * @size: Size to be rounded up.
811 *
812 * Returns @size.
813 *
814 * Since SLOB does not round up, this function simply returns @size.
815 */
816static inline int tomoyo_round2(size_t size)
817{
818 return size;
819}
820
821#else
822
823/**
824 * tomoyo_round2 - Round up to power of 2 for calculating memory usage.
825 *
826 * @size: Size to be rounded up.
827 *
828 * Returns rounded size.
829 *
830 * Strictly speaking, SLAB may be able to allocate (e.g.) 96 bytes instead of
831 * (e.g.) 128 bytes.
832 */
833static inline int tomoyo_round2(size_t size)
834{
835#if PAGE_SIZE == 4096
836 size_t bsize = 32;
837#else
838 size_t bsize = 64;
839#endif
840 if (!size)
841 return 0;
842 while (size > bsize)
843 bsize <<= 1;
844 return bsize;
845}
846
847#endif
848
776/** 849/**
777 * list_for_each_cookie - iterate over a list with cookie. 850 * list_for_each_cookie - iterate over a list with cookie.
778 * @pos: the &struct list_head to use as a loop cursor. 851 * @pos: the &struct list_head to use as a loop cursor.