mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 18:03:25 +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 {
|
||||
None
|
||||
} else {
|
||||
Some(self.futex_addr(self.list_op_pending))
|
||||
self.futex_addr(self.list_op_pending)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the futex address
|
||||
fn futex_addr(&self, entry_ptr: Vaddr) -> Vaddr {
|
||||
(entry_ptr as isize + self.futex_offset) as _
|
||||
fn futex_addr(&self, entry_ptr: Vaddr) -> Option<Vaddr> {
|
||||
self.futex_offset
|
||||
.checked_add(entry_ptr as isize)
|
||||
.map(|result| result as Vaddr)
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +101,7 @@ impl Iterator for FutexIter<'_> {
|
||||
return None;
|
||||
}
|
||||
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 {
|
||||
None
|
||||
};
|
||||
|
Reference in New Issue
Block a user