From 52e7fe3c679469032e77a5ca4adf19618ba1201b Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 24 Jan 2023 18:49:58 +0100 Subject: kernel/procfs: prevent reading kernel memory knew it --- src/kernel/vfs/procfs.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/kernel/vfs/procfs.c') diff --git a/src/kernel/vfs/procfs.c b/src/kernel/vfs/procfs.c index a417606..be907fd 100644 --- a/src/kernel/vfs/procfs.c +++ b/src/kernel/vfs/procfs.c @@ -123,6 +123,10 @@ procfs_accept(struct vfs_request *req) virt_cpy_to(req->caller->pages, req->output.buf, buf, pos); vfsreq_finish_short(req, pos); } else if (req->type == VFSOP_READ && h->type == PhMem) { + if (p->pages == NULL || req->caller->pages == NULL) { + vfsreq_finish_short(req, 0); + return; + } size_t res = virt_cpy( req->caller->pages, req->output.buf, p->pages, (__user void*)req->offset, -- cgit v1.2.3