summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
authordzwdz2022-05-05 17:03:39 +0200
committerdzwdz2022-05-05 17:03:39 +0200
commit60a5c52c407db5f88df82c0dfce425d0faab6831 (patch)
treed6a141cb2791c029731e77fffbf4056c39b4db11 /src/kernel/vfs
parent7f78a3a6aff84558dd181bda099e54e2afdd1dbc (diff)
kernel/vfs_root: fix nullptr dereference
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/root.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/kernel/vfs/root.c b/src/kernel/vfs/root.c
index 4a1148e..904f996 100644
--- a/src/kernel/vfs/root.c
+++ b/src/kernel/vfs/root.c
@@ -66,6 +66,7 @@ static bool wait_setup(struct vfs_request *req, bool *ready, bool (*ready_fn)())
}
static int handle(struct vfs_request *req, bool *ready) {
+ assert(req->caller);
switch (req->type) {
case VFSOP_OPEN:
if (exacteq(req, "/")) return HANDLE_ROOT;
@@ -174,10 +175,25 @@ static int handle(struct vfs_request *req, bool *ready) {
}
int vfs_root_handler(struct vfs_request *req) {
- bool ready = true;
- int ret = handle(req, &ready);
- if (ready)
- return vfs_request_finish(req, ret);
- else
- return -1;
+ if (req->caller) {
+ /* this introduces a difference between the root vfs and emulated ones:
+ *
+ * the root vfs has to immediately discard requests from dead processes.
+ * so, if 16 processes queue up for an IRQ, and the middle 14 quit, only
+ * 2 IRQs will be processed
+ *
+ * but if they do that in an emulated root vfs, all 16 IRQs will be processed
+ *
+ * to fix this, i need to make it so callerless requests can also wait
+ * for IRQs.
+ */
+ bool ready = true;
+ int ret = handle(req, &ready);
+ if (ready)
+ return vfs_request_finish(req, ret);
+ else
+ return -1;
+ } else {
+ return vfs_request_finish(req, -1);
+ }
}