Fix integer overflow in degenerate invoke_signed BPF syscalls (#15051)
This commit is contained in:
@ -348,7 +348,7 @@ fn translate_slice_inner<'a, T>(
|
|||||||
{
|
{
|
||||||
Err(SyscallError::UnalignedPointer.into())
|
Err(SyscallError::UnalignedPointer.into())
|
||||||
} else if len == 0 {
|
} else if len == 0 {
|
||||||
Ok(unsafe { from_raw_parts_mut(0x1 as *mut T, len as usize) })
|
Ok(&mut [])
|
||||||
} else {
|
} else {
|
||||||
match translate(
|
match translate(
|
||||||
memory_mapping,
|
memory_mapping,
|
||||||
@ -1471,7 +1471,9 @@ fn check_instruction_size(
|
|||||||
data_len: usize,
|
data_len: usize,
|
||||||
invoke_context: &Ref<&mut dyn InvokeContext>,
|
invoke_context: &Ref<&mut dyn InvokeContext>,
|
||||||
) -> Result<(), EbpfError<BPFError>> {
|
) -> Result<(), EbpfError<BPFError>> {
|
||||||
let size = num_accounts * size_of::<AccountMeta>() + data_len;
|
let size = num_accounts
|
||||||
|
.saturating_mul(size_of::<AccountMeta>())
|
||||||
|
.saturating_add(data_len);
|
||||||
let max_size = invoke_context
|
let max_size = invoke_context
|
||||||
.get_bpf_compute_budget()
|
.get_bpf_compute_budget()
|
||||||
.max_cpi_instruction_size;
|
.max_cpi_instruction_size;
|
||||||
|
Reference in New Issue
Block a user