From e0101ecf0d2f29d8860e865e3f333803af918f2e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 21 May 2022 18:30:52 +0200 Subject: syscall/memflag: zero out allocated pages to prevent leaks --- src/kernel/syscalls.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 560cd37..af70e4e 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -266,8 +266,11 @@ int _syscall_memflag(void __user *addr, size_t len, int flags) { continue; } - if (!pagedir_virt2phys(pages, addr, false, false)) - pagedir_map(pages, addr, page_alloc(1), true, true); + if (!pagedir_virt2phys(pages, addr, false, false)) { + void *phys = page_alloc(1); + memset(phys, 0, PAGE_SIZE); // TODO somehow test this + pagedir_map(pages, addr, phys, true, true); + } } SYSCALL_RETURN(-1); -- cgit v1.2.3