aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-09-14 21:30:11 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-09-14 21:30:11 +0300
commitcabbf335824db0df835e4c541c19d3803ce38454 (patch)
treee7397d2b6637545b8e18f26135e3ad2a0a2fbe1e /include
parent025778e89e7d0fe3cd1ad53537c9cc6f3cd819cc (diff)
downloadkmi-cabbf335824db0df835e4c541c19d3803ce38454.tar.gz
kmi-cabbf335824db0df835e4c541c19d3803ce38454.zip
add canary to kernel stack
Diffstat (limited to 'include')
-rw-r--r--include/apos/canary.h27
-rw-r--r--include/apos/mem.h20
-rw-r--r--include/apos/types.h2
3 files changed, 39 insertions, 10 deletions
diff --git a/include/apos/canary.h b/include/apos/canary.h
new file mode 100644
index 0000000..30a3dd2
--- /dev/null
+++ b/include/apos/canary.h
@@ -0,0 +1,27 @@
+#ifndef APOS_CANARY_H
+#define APOS_CANARY_H
+
+/**
+ * @file canary.h
+ * Kernel stack canary handling.
+ */
+
+#include <apos/tcb.h>
+#include <apos/types.h>
+
+/**
+ * Place canary at end of kernel stack.
+ *
+ * @param t \ref tcb whose kernel stack to place canary in.
+ */
+void set_canary(struct tcb *t);
+
+/**
+ * Check that canary hasn't been accidentally overwritten.
+ *
+ * @param t \ref tcb whose kernel stack canary to check.
+ * @return \ref true if overwritten, \ref false otherwise.
+ */
+bool check_canary(struct tcb *t);
+
+#endif /* APOS_CANARY_H */
diff --git a/include/apos/mem.h b/include/apos/mem.h
index 08aad1f..512f1e7 100644
--- a/include/apos/mem.h
+++ b/include/apos/mem.h
@@ -245,34 +245,34 @@ extern size_t __mm_max_order;
/** Give names to page orders. */
enum mm_order {
/** Base order. */
- MM_O0,
+ MM_O0 = 0,
/** Order 1. */
- MM_O1,
+ MM_O1 = 1,
/** Order 2. */
- MM_O2,
+ MM_O2 = 2,
/** Order 3. */
- MM_O3,
+ MM_O3 = 3,
/** Order 4. */
- MM_O4,
+ MM_O4 = 4,
/** Order 5. */
- MM_O5,
+ MM_O5 = 5,
/** Order 6. */
- MM_O6,
+ MM_O6 = 6,
/** Order 7. */
- MM_O7,
+ MM_O7 = 7,
/** Order 8. */
- MM_O8,
+ MM_O8 = 8,
/** Order 9. */
- MM_O9,
+ MM_O9 = 9,
};
/** Page number. */
diff --git a/include/apos/types.h b/include/apos/types.h
index 10ad80a..f249705 100644
--- a/include/apos/types.h
+++ b/include/apos/types.h
@@ -455,6 +455,8 @@ typedef uint_fast16_t vmflags_t;
*/
/* should this enum be somewhere else? */
enum status_codes {
+ /** Internal error, should probably halt */
+ ERR_INT = -9,
/** Something went wrong :/ */
ERR_MISC = -8,
/** Not initialized. */