BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / 73145c0e2b43a1cca5c2cd10a53a703d3ad013bf / memory / user.c

// Related

Nucleus

Barry Page functions + User memory functions 73145c0 (3 years, 3 months ago)
diff --git a/memory/user.c b/memory/user.c
new file mode 100644
index 0000000..cdf4bcd
--- /dev/null
+++ b/memory/user.c
@@ -0,0 +1,24 @@
+/*
+ * This file handles safely getting data from userspace for the kernel.  This is
+ * for security reasons to prevent the user from tricking a syscall into
+ * manipulating/leaking kernel data structures.  User memory is defined as any
+ * address range that completely sits in a Virtual Memory Region.
+ */
+
+#include <nucleus/memory.h>
+
+/* Check if user has access to a region of memory */
+int
+verify_access(const void *addr, size_t len, int prot)
+{
+	/*
+	 * This should iterate all memory regions to check if the address range
+	 * fits inside one, if not then access should be denied.  If a matching
+	 * region is found, the prot parameter should be checked against the
+	 * protection value for that region.  If this function is called from
+	 * the kernel directly, or the user did not pass an address or a length
+	 * (NULL and 0, respectively), then it should just grant access
+	 * immediately.  This can be implemented when userspace is implemented.
+	 */
+	return 1;
+}