From 88e27cddd2f75ea7ed2ce2c0a82a130bc2d05eb7 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 1 May 2024 22:05:19 +0100 Subject: [PATCH] src/ebpf.rs: Increase instruction limit to 1 million The linux kernel allows programs of 1 million instructions, see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c04c0d2b968ac45d6ef020316808ef6c82325a82 I'm hitting the 4096 limit in some corner cases with https://github.com/seanyoung/cir, if the infrared protocol is very complex (e.g. XMP). rbpf is used for testing the generated IR decoders in the test framework. Signed-off-by: Sean Young --- src/ebpf.rs | 2 +- tests/ubpf_verifier.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ebpf.rs b/src/ebpf.rs index e34236271..34f50977a 100644 --- a/src/ebpf.rs +++ b/src/ebpf.rs @@ -18,7 +18,7 @@ use byteorder::{ByteOrder, LittleEndian}; use crate::stdlib::vec::Vec; /// Maximum number of instructions in an eBPF program. -pub const PROG_MAX_INSNS: usize = 4096; +pub const PROG_MAX_INSNS: usize = 1000000; /// Size of an eBPF instructions, in bytes. pub const INSN_SIZE: usize = 8; /// Maximum size of an eBPF program, in bytes. diff --git a/tests/ubpf_verifier.rs b/tests/ubpf_verifier.rs index e6a14105e..09227aa12 100644 --- a/tests/ubpf_verifier.rs +++ b/tests/ubpf_verifier.rs @@ -115,11 +115,11 @@ fn test_verifier_err_no_exit_backward_jump() { } #[test] -#[should_panic(expected = "[Verifier] Error: eBPF program length limited to 4096, here 4097")] +#[should_panic(expected = "[Verifier] Error: eBPF program length limited to 1000000, here 1000001")] fn test_verifier_err_too_many_instructions() { // uBPF uses 65637 instructions, because it sets its limit at 65636. // We use the classic 4096 limit from kernel, so no need to produce as many instructions. - let mut prog = (0..(4096 * ebpf::INSN_SIZE)).map( |x| match x % 8 { + let mut prog = (0..(1_000_000 * ebpf::INSN_SIZE)).map( |x| match x % 8 { 0 => 0xb7, 1 => 0x01, _ => 0