Add overflow check for given sigaltstack addr and size

This commit is contained in:
Marsman1996 2024-12-25 14:37:40 +08:00 committed by Tate, Hongliang Tian
parent 7c249cf0ca
commit 1a5bf7b0ad

View File

@ -106,6 +106,9 @@ impl TryFrom<stack_t> for SigStack {
if stack.size < MINSTKSZ {
return_errno_with_message!(Errno::ENOMEM, "stack size is less than MINSTKSZ");
}
if stack.sp.checked_add(stack.size).is_none() {
return_errno_with_message!(Errno::EINVAL, "overflow for given stack addr and size");
}
if flags.is_empty() {
flags.insert(SigStackFlags::SS_ONSTACK);