summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/aarch64/conf/GENERIC7
-rw-r--r--sys/arch/amd64/conf/GENERIC8
-rw-r--r--sys/conf/GENERIC9
-rw-r--r--sys/fs/tmpfs.c8
-rw-r--r--sys/kern/kern_subr.c21
5 files changed, 35 insertions, 18 deletions
diff --git a/sys/arch/aarch64/conf/GENERIC b/sys/arch/aarch64/conf/GENERIC
index eeb9d9d..702a248 100644
--- a/sys/arch/aarch64/conf/GENERIC
+++ b/sys/arch/aarch64/conf/GENERIC
@@ -1,10 +1,3 @@
// Kernel options
option SERIAL_DEBUG yes // Enable kmsg serial logging
option USER_KMSG yes // Show kmsg in user consoles
-
-// Kernel constants
-setval SCHED_NQUEUE 4 // Number of scheduler queues (for MLFQ)
-
-// Console attributes
-setval CONSOLE_BG 0x000000
-setval CONSOLE_FG 0xB57614
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index e407fa9..6f573f3 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -9,12 +9,4 @@ option SPECTRE_IBRS no // Enable the IBRS CPU feature
option SERIAL_DEBUG yes // Enable kmsg serial logging
option USER_KMSG no // Show kmsg in user consoles
option CPU_SMEP yes // Supervisor Memory Exec Protection
-option PANIC_SCR no // Clear screen on panic
option I8042_POLL yes // Use polling for the i8042
-
-// Kernel constants
-setval SCHED_NQUEUE 4 // Number of scheduler queues (for MLFQ)
-
-// Console attributes
-setval CONSOLE_BG 0x000000
-setval CONSOLE_FG 0xB57614
diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC
new file mode 100644
index 0000000..5734c43
--- /dev/null
+++ b/sys/conf/GENERIC
@@ -0,0 +1,9 @@
+// Kernel options
+option PANIC_SCR no // Clear screen on panic
+
+// Kernel constants
+setval SCHED_NQUEUE 4 // Number of scheduler queues (for MLFQ)
+
+// Console attributes
+setval CONSOLE_BG 0x000000
+setval CONSOLE_FG 0xB57614
diff --git a/sys/fs/tmpfs.c b/sys/fs/tmpfs.c
index c3f2fae..4fd9e85 100644
--- a/sys/fs/tmpfs.c
+++ b/sys/fs/tmpfs.c
@@ -238,6 +238,7 @@ static int
tmpfs_write(struct vnode *vp, struct sio_txn *sio)
{
struct tmpfs_node *np;
+ off_t res_off;
uint8_t *buf;
if (sio->buf == NULL || sio->len == 0) {
@@ -274,8 +275,9 @@ tmpfs_write(struct vnode *vp, struct sio_txn *sio)
* Bring up the real size if we are writing
* more bytes.
*/
- if (sio->offset >= np->real_size) {
- np->real_size = sio->offset;
+ res_off = sio->offset + sio->len;
+ if (res_off > np->real_size) {
+ np->real_size = res_off;
}
/*
@@ -285,7 +287,7 @@ tmpfs_write(struct vnode *vp, struct sio_txn *sio)
* into a suitable size that does not overflow what we
* have left.
*/
- if ((sio->offset + sio->len) > np->len) {
+ if (res_off > np->len) {
np->data = dynrealloc(np->data, (sio->offset + sio->len));
if (np->data == NULL) {
sio->len = np->len;
diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c
index f437ec7..8a08f33 100644
--- a/sys/kern/kern_subr.c
+++ b/sys/kern/kern_subr.c
@@ -29,9 +29,12 @@
#include <sys/proc.h>
#include <sys/types.h>
+#include <sys/param.h>
#include <sys/errno.h>
+#include <sys/mman.h>
#include <sys/exec.h>
#include <sys/systm.h>
+#include <vm/vm.h>
#include <string.h>
/*
@@ -45,6 +48,8 @@ static bool
check_uaddr(const void *uaddr)
{
vaddr_t stack_start, stack_end;
+ struct mmap_lgdr *lp;
+ struct mmap_entry find, *res;
struct exec_prog exec;
struct proc *td;
uintptr_t addr;
@@ -61,6 +66,22 @@ check_uaddr(const void *uaddr)
if (addr >= stack_start && addr <= stack_end)
return true;
+ /* Try to grab the mmap ledger */
+ if ((lp = td->mlgdr) == NULL) {
+ return false;
+ }
+
+ /*
+ * Now give an attempt at looking through the
+ * mmap ledger. Perhaps this memory was allocated
+ * in the user heap?
+ */
+ find.va_start = ALIGN_DOWN(addr, DEFAULT_PAGESIZE);
+ res = RBT_FIND(lgdr_entries, &lp->hd, &find);
+ if (res != NULL) {
+ return true;
+ }
+
return false;
}