From b528a54a708c4cd2149c8e6884af2063c2b272cd Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 17 Jun 2023 22:19:36 +0200 Subject: kernel: fix procfs overflow bug, add safeguard to prevent similar ones --- src/kernel/vfs/request.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/kernel/vfs/request.c') diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 410e41e..5723201 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -73,6 +73,10 @@ void vfsreq_finish(VfsReq *req, char __user *stored, long ret, } } + if (req->type == VFSOP_READ && ret >= 0) { + assert((size_t)ret <= req->output.len); + } + if (req->input.kern) kfree(req->input.buf_kern); -- cgit v1.2.3