• R/O
  • SSH
  • HTTPS

caitsith: Commit


Commit MetaInfo

Revision294 (tree)
Zeit2020-01-02 12:43:02
Autorkumaneko

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- trunk/caitsith-patch/caitsith/policy_io.c (revision 293)
+++ trunk/caitsith-patch/caitsith/policy_io.c (revision 294)
@@ -859,7 +859,11 @@
859859 struct dentry *parent, const u8 key);
860860 static void __init cs_load_builtin_policy(void);
861861 static void __init cs_securityfs_init(void);
862+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
862863 static void cs_convert_time(time_t time, struct cs_time *stamp);
864+#else
865+static void cs_convert_time(time64_t time, struct cs_time *stamp);
866+#endif
863867 static void cs_io_printf(struct cs_io_buffer *head, const char *fmt, ...)
864868 __printf(2, 3);
865869 static void cs_normalize_line(unsigned char *buffer);
@@ -893,6 +897,7 @@
893897
894898 /***** SECTION4: Standalone functions section *****/
895899
900+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
896901 /**
897902 * cs_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.
898903 *
@@ -935,7 +940,29 @@
935940 stamp->month = ++m;
936941 stamp->day = ++time;
937942 }
943+#else
944+/**
945+ * cs_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.
946+ *
947+ * @time: Seconds since 1970/01/01 00:00:00.
948+ * @stamp: Pointer to "struct cs_time".
949+ *
950+ * Returns nothing.
951+ */
952+static void cs_convert_time(time64_t time, struct cs_time *stamp)
953+{
954+ struct tm tm;
938955
956+ time64_to_tm(time, 0, &tm);
957+ stamp->sec = tm.tm_sec;
958+ stamp->min = tm.tm_min;
959+ stamp->hour = tm.tm_hour;
960+ stamp->day = tm.tm_mday;
961+ stamp->month = tm.tm_mon + 1;
962+ stamp->year = tm.tm_year + 1900;
963+}
964+#endif
965+
939966 #ifdef CONFIG_CAITSITH_NETWORK
940967
941968 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
@@ -1167,11 +1194,15 @@
11671194 /* The list for "struct cs_name". */
11681195 struct list_head cs_name_list[CS_MAX_HASH];
11691196
1170-/* Timestamp counter for last updated. */
1197+/* Counter for number of updates. */
11711198 static unsigned int cs_stat_updated[CS_MAX_POLICY_STAT];
11721199
1173-/* Counter for number of updates. */
1200+/* Timestamp counter for last updated. */
1201+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
11741202 static unsigned int cs_stat_modified[CS_MAX_POLICY_STAT];
1203+#else
1204+static time64_t cs_stat_modified[CS_MAX_POLICY_STAT];
1205+#endif
11751206
11761207 /* Operations for /sys/kernel/security/caitsith/self_domain interface. */
11771208 static const struct file_operations cs_self_operations = {
@@ -3151,7 +3182,11 @@
31513182 * I don't use atomic operations because race condition is not fatal.
31523183 */
31533184 cs_stat_updated[index]++;
3185+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
31543186 cs_stat_modified[index] = get_seconds();
3187+#else
3188+ cs_stat_modified[index] = ktime_get_real_seconds();
3189+#endif
31553190 }
31563191
31573192 /**
@@ -3714,7 +3749,11 @@
37143749
37153750 if (!r->exename.name && !cs_get_exename(&r->exename))
37163751 return NULL;
3752+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
37173753 cs_convert_time(get_seconds(), &stamp);
3754+#else
3755+ cs_convert_time(ktime_get_real_seconds(), &stamp);
3756+#endif
37183757 trailer = cs_print_trailer(r);
37193758 if (r->bprm)
37203759 bprm_info = cs_print_bprm(r->bprm, &r->dump);
--- trunk/caitsith-patch/security/caitsith/policy_io.c (revision 293)
+++ trunk/caitsith-patch/security/caitsith/policy_io.c (revision 294)
@@ -902,7 +902,11 @@
902902 static void __init cs_policy_io_init(void);
903903 static void __init cs_securityfs_init(void);
904904 static void cs_check_profile(void);
905+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
905906 static void cs_convert_time(time_t time, struct cs_time *stamp);
907+#else
908+static void cs_convert_time(time64_t time, struct cs_time *stamp);
909+#endif
906910 static void cs_io_printf(struct cs_io_buffer *head, const char *fmt, ...)
907911 __printf(2, 3);
908912 static void cs_normalize_line(unsigned char *buffer);
@@ -936,6 +940,7 @@
936940
937941 /***** SECTION4: Standalone functions section *****/
938942
943+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
939944 /**
940945 * cs_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.
941946 *
@@ -978,7 +983,29 @@
978983 stamp->month = ++m;
979984 stamp->day = ++time;
980985 }
986+#else
987+/**
988+ * cs_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.
989+ *
990+ * @time: Seconds since 1970/01/01 00:00:00.
991+ * @stamp: Pointer to "struct cs_time".
992+ *
993+ * Returns nothing.
994+ */
995+static void cs_convert_time(time64_t time, struct cs_time *stamp)
996+{
997+ struct tm tm;
981998
999+ time64_to_tm(time, 0, &tm);
1000+ stamp->sec = tm.tm_sec;
1001+ stamp->min = tm.tm_min;
1002+ stamp->hour = tm.tm_hour;
1003+ stamp->day = tm.tm_mday;
1004+ stamp->month = tm.tm_mon + 1;
1005+ stamp->year = tm.tm_year + 1900;
1006+}
1007+#endif
1008+
9821009 #ifdef CONFIG_CAITSITH_NETWORK
9831010
9841011 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
@@ -1210,11 +1237,15 @@
12101237 /* The list for "struct cs_name". */
12111238 struct list_head cs_name_list[CS_MAX_HASH];
12121239
1213-/* Timestamp counter for last updated. */
1240+/* Counter for number of updates. */
12141241 static unsigned int cs_stat_updated[CS_MAX_POLICY_STAT];
12151242
1216-/* Counter for number of updates. */
1243+/* Timestamp counter for last updated. */
1244+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
12171245 static unsigned int cs_stat_modified[CS_MAX_POLICY_STAT];
1246+#else
1247+static time64_t cs_stat_modified[CS_MAX_POLICY_STAT];
1248+#endif
12181249
12191250 /* Operations for /sys/kernel/security/caitsith/self_domain interface. */
12201251 static const struct file_operations cs_self_operations = {
@@ -3188,7 +3219,11 @@
31883219 * I don't use atomic operations because race condition is not fatal.
31893220 */
31903221 cs_stat_updated[index]++;
3222+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
31913223 cs_stat_modified[index] = get_seconds();
3224+#else
3225+ cs_stat_modified[index] = ktime_get_real_seconds();
3226+#endif
31923227 }
31933228
31943229 /**
@@ -3771,7 +3806,11 @@
37713806
37723807 if (!r->exename.name && !cs_get_exename(&r->exename))
37733808 return NULL;
3809+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
37743810 cs_convert_time(get_seconds(), &stamp);
3811+#else
3812+ cs_convert_time(ktime_get_real_seconds(), &stamp);
3813+#endif
37753814 trailer = cs_print_trailer(r);
37763815 if (r->bprm)
37773816 bprm_info = cs_print_bprm(r->bprm, &r->dump);
Show on old repository browser