kernel: Do not error out on zero-length reads/writes to bad addresses

This commit is contained in:
apio 2023-06-17 12:04:34 +02:00
parent 592558d7ad
commit b7a82fd895
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -16,6 +16,8 @@ Result<u64> sys_read(Registers*, SyscallArgs args)
u8* buf = (u8*)args[1];
usize size = (usize)args[2];
if (!size) return 0;
if (!MemoryManager::validate_user_write(buf, size)) return err(EFAULT);
Thread* current = Scheduler::current();
@ -44,6 +46,8 @@ Result<u64> sys_write(Registers*, SyscallArgs args)
const u8* buf = (const u8*)args[1];
usize size = (usize)args[2];
if (!size) return 0;
if (!MemoryManager::validate_user_read(buf, size)) return err(EFAULT);
Thread* current = Scheduler::current();