mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 02:13:24 +00:00
Add overflow check for futex_addr
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
5aa73d3bcf
commit
9753d796c5
@ -43,13 +43,15 @@ impl RobustListHead {
|
|||||||
if self.list_op_pending == 0 {
|
if self.list_op_pending == 0 {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(self.futex_addr(self.list_op_pending))
|
self.futex_addr(self.list_op_pending)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the futex address
|
/// Get the futex address
|
||||||
fn futex_addr(&self, entry_ptr: Vaddr) -> Vaddr {
|
fn futex_addr(&self, entry_ptr: Vaddr) -> Option<Vaddr> {
|
||||||
(entry_ptr as isize + self.futex_offset) as _
|
self.futex_offset
|
||||||
|
.checked_add(entry_ptr as isize)
|
||||||
|
.map(|result| result as Vaddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ impl Iterator for FutexIter<'_> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let futex_addr = if self.entry_ptr != self.robust_list.list_op_pending {
|
let futex_addr = if self.entry_ptr != self.robust_list.list_op_pending {
|
||||||
Some(self.robust_list.futex_addr(self.entry_ptr))
|
self.robust_list.futex_addr(self.entry_ptr)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user