From 322e9cdff61522c8f1ecfb78ab14567d4ecbc566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Wed, 4 Sep 2024 08:47:18 +0200 Subject: [PATCH] Makes the ExhaustedTextSegment check more conservative. --- src/jit.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jit.rs b/src/jit.rs index 73c2a44e..ee6e9094 100644 --- a/src/jit.rs +++ b/src/jit.rs @@ -399,7 +399,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> { self.emit_subroutines(); while self.pc * ebpf::INSN_SIZE < self.program.len() { - if self.offset_in_text_section + MAX_MACHINE_CODE_LENGTH_PER_INSTRUCTION > self.result.text_section.len() { + if self.offset_in_text_section + MAX_MACHINE_CODE_LENGTH_PER_INSTRUCTION * 2 >= self.result.text_section.len() { return Err(EbpfError::ExhaustedTextSegment(self.pc)); } let mut insn = ebpf::get_insn_unchecked(self.program, self.pc); @@ -729,7 +729,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> { } // Bumper in case there was no final exit - if self.offset_in_text_section + MAX_MACHINE_CODE_LENGTH_PER_INSTRUCTION > self.result.text_section.len() { + if self.offset_in_text_section + MAX_MACHINE_CODE_LENGTH_PER_INSTRUCTION * 2 >= self.result.text_section.len() { return Err(EbpfError::ExhaustedTextSegment(self.pc)); } self.emit_validate_and_profile_instruction_count(true, Some(self.pc + 2));