Skip to content

Commit

Permalink
Makes the ExhaustedTextSegment check more conservative.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Sep 4, 2024
1 parent 7064f2f commit 322e9cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 322e9cd

Please sign in to comment.