Skip to content

Commit

Permalink
munmap: check vaddr and size alignment
Browse files Browse the repository at this point in the history
JIRA: RTOS-967
  • Loading branch information
badochov authored and Darchiv committed Nov 5, 2024
1 parent 464ea21 commit 91c9cad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ int syscalls_sys_munmap(void *ustack)
GETFROMSTACK(ustack, void *, vaddr, 0);
GETFROMSTACK(ustack, size_t, size, 1);

size = round_page(size);
err = vm_munmap(proc->mapp, vaddr, size);
if (err < 0) {
return err;
Expand Down
4 changes: 4 additions & 0 deletions vm/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ int _vm_munmap(vm_map_t *map, void *vaddr, size_t size)
ptr_t eAoffs;
int putEntry;

if (((size & (SIZE_PAGE - 1)) != 0) || (((ptr_t)vaddr & (SIZE_PAGE - 1)) != 0)) {
return -EINVAL;
}

t.vaddr = vaddr;
t.size = size;

Expand Down

0 comments on commit 91c9cad

Please sign in to comment.