Skip to content

Commit

Permalink
Update decoder to handle indirect jumps for jump tables and syscall/i…
Browse files Browse the repository at this point in the history
…nterrupt pseudo-call control flow
  • Loading branch information
novafacing committed Nov 20, 2023
1 parent a983273 commit 31a980d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
24 changes: 21 additions & 3 deletions modules/tsffs/src/tsffs/src/arch/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,8 @@ impl TracerDisassembler for Disassembler {
if let Some(last) = self.last {
return matches!(
last.opcode(),
Opcode::JA
Opcode::JMP
| Opcode::JA
| Opcode::JB
| Opcode::JG
| Opcode::JGE
Expand Down Expand Up @@ -1161,7 +1162,15 @@ impl TracerDisassembler for Disassembler {
/// Check if an instruction is a call instruction
fn last_was_call(&self) -> bool {
if let Some(last) = self.last {
return matches!(last.opcode(), Opcode::CALL | Opcode::CALLF);
return matches!(
last.opcode(),
Opcode::CALL
| Opcode::CALLF
| Opcode::INT
| Opcode::INTO
| Opcode::SYSCALL
| Opcode::SYSENTER
);
}

false
Expand All @@ -1170,7 +1179,16 @@ impl TracerDisassembler for Disassembler {
/// Check if an instruction is a ret instruction
fn last_was_ret(&self) -> bool {
if let Some(last) = self.last {
return matches!(last.opcode(), Opcode::RETF | Opcode::RETURN);
return matches!(
last.opcode(),
Opcode::RETF
| Opcode::RETURN
| Opcode::IRET
| Opcode::IRETD
| Opcode::IRETQ
| Opcode::SYSRET
| Opcode::SYSEXIT
);
}

false
Expand Down
28 changes: 23 additions & 5 deletions modules/tsffs/src/tsffs/src/arch/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ impl TracerDisassembler for Disassembler {
if let Some(last) = self.last {
if matches!(
last.opcode(),
Opcode::JA
Opcode::JMP
| Opcode::JA
| Opcode::JB
| Opcode::JRCXZ
| Opcode::JG
Expand All @@ -945,19 +946,36 @@ impl TracerDisassembler for Disassembler {
false
}

/// Check if an instruction is a call instruction
/// Check if an instruction is a call instruction (loosely defined, this includes interrupts)
fn last_was_call(&self) -> bool {
if let Some(last) = self.last {
return matches!(last.opcode(), Opcode::CALL | Opcode::CALLF);
return matches!(
last.opcode(),
Opcode::CALL
| Opcode::CALLF
| Opcode::INT
| Opcode::INTO
| Opcode::SYSCALL
| Opcode::SYSENTER
);
}

false
}

/// Check if an instruction is a ret instruction
/// Check if an instruction is a ret instruction (loosely defined, this includes interrupts)
fn last_was_ret(&self) -> bool {
if let Some(last) = self.last {
return matches!(last.opcode(), Opcode::RETF | Opcode::RETURN);
return matches!(
last.opcode(),
Opcode::RETF
| Opcode::RETURN
| Opcode::IRET
| Opcode::IRETD
| Opcode::IRETQ
| Opcode::SYSRET
| Opcode::SYSEXIT
);
}

false
Expand Down

0 comments on commit 31a980d

Please sign in to comment.