mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 17:33:23 +00:00
Fix integer overflow in futex wake
This commit is contained in:
committed by
Jianfeng Jiang
parent
95faea0fb0
commit
bb3f21b41e
@ -195,7 +195,13 @@ impl FutexWakeOpEncode {
|
||||
|
||||
fn calculate_new_val(&self, old_val: u32) -> u32 {
|
||||
let oparg = if self.is_oparg_shift {
|
||||
1 << self.oparg
|
||||
if self.oparg > 31 {
|
||||
// Linux might return EINVAL in the future
|
||||
// Reference: https://elixir.bootlin.com/linux/v6.15.2/source/kernel/futex/waitwake.c#L211-L222
|
||||
warn!("futex_wake_op: program tries to shift op by {}", self.oparg);
|
||||
}
|
||||
|
||||
1 << (self.oparg & 31)
|
||||
} else {
|
||||
self.oparg
|
||||
};
|
||||
|
Reference in New Issue
Block a user