mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 03:56:42 +00:00
Set overflow boundary to isize::MAX
for memory related syscalls
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
9589b332aa
commit
745ac6d982
@ -20,7 +20,7 @@ pub fn sys_madvise(
|
||||
if start % PAGE_SIZE != 0 {
|
||||
return_errno_with_message!(Errno::EINVAL, "the start address should be page aligned");
|
||||
}
|
||||
if len > usize::MAX - PAGE_SIZE + 1 {
|
||||
if len > isize::MAX as usize {
|
||||
return_errno_with_message!(Errno::EINVAL, "len align overflow");
|
||||
}
|
||||
if len == 0 {
|
||||
|
@ -22,7 +22,7 @@ pub fn sys_mprotect(addr: Vaddr, len: usize, perms: u64, ctx: &Context) -> Resul
|
||||
if len == 0 {
|
||||
return Ok(SyscallReturn::Return(0));
|
||||
}
|
||||
if len > usize::MAX - PAGE_SIZE + 1 {
|
||||
if len > isize::MAX as usize {
|
||||
return_errno_with_message!(Errno::ENOMEM, "len align overflow");
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ pub fn sys_munmap(addr: Vaddr, len: usize, ctx: &Context) -> Result<SyscallRetur
|
||||
if len == 0 {
|
||||
return_errno_with_message!(Errno::EINVAL, "munmap len cannot be zero");
|
||||
}
|
||||
if len > usize::MAX - PAGE_SIZE + 1 {
|
||||
if len > isize::MAX as usize {
|
||||
return_errno_with_message!(Errno::ENOMEM, "munmap len align overflow");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user