Fix integer overflow in futex wake

This commit is contained in:
Marsman1996
2025-06-20 15:45:05 +08:00
committed by Jianfeng Jiang
parent 95faea0fb0
commit bb3f21b41e

View File

@ -195,7 +195,13 @@ impl FutexWakeOpEncode {
fn calculate_new_val(&self, old_val: u32) -> u32 { fn calculate_new_val(&self, old_val: u32) -> u32 {
let oparg = if self.is_oparg_shift { 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 { } else {
self.oparg self.oparg
}; };