Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle JumpKind.Exit in VEXIRSBConverter #198

Open
xxr0ss opened this issue Mar 5, 2024 · 1 comment
Open

Handle JumpKind.Exit in VEXIRSBConverter #198

xxr0ss opened this issue Mar 5, 2024 · 1 comment

Comments

@xxr0ss
Copy link

xxr0ss commented Mar 5, 2024

Description

I'm trying to convert an irsb of custom arch (eBPF example in angr-platforms) to AILBlock

diff --git a/tests/test_ebpf.py b/tests/test_ebpf.py
index 0d23ec8..8aa10a5 100644
--- a/tests/test_ebpf.py
+++ b/tests/test_ebpf.py
@@ -2,6 +2,7 @@ import unittest
 from pathlib import Path

 import angr
+import ailment
 from angr_platforms.ebpf import ArchExtendedBPF, LifterEbpf


@@ -36,8 +37,12 @@ class TestEbpf(unittest.TestCase):
         state = proj.factory.entry_state()
         block = proj.factory.block(state.addr)
         lifter = LifterEbpf(proj.arch, block.addr)
-        lifter.lift(block.bytes)
+        irsb = lifter.lift(block.bytes)
         assert len(lifter.disassemble()) == 2
+        
+        manager = ailment.Manager(arch=proj.arch)
+        ailblock = ailment.IRSBConverter.convert(irsb, manager)
+        assert isinstance(ailblock.statements[0], ailment.statement.Assignment)


 if __name__ == "__main__":

but the converter raises NotImplementedError.

To my understanding, If a irsb ends with a Ijk_Exit, we can simply do nothing, right? Maybe we can modify converter_vex.py as following:

diff --git a/ailment/converter_vex.py b/ailment/converter_vex.py
index 6523695..dc9bf5e 100644
--- a/ailment/converter_vex.py
+++ b/ailment/converter_vex.py
@@ -753,6 +753,9 @@ class VEXIRSBConverter(Converter):
                     vex_stmt_idx=DEFAULT_STATEMENT,
                 )
             )
+        elif irsb.jumpkind == "Ijk_Exit":
+            # exit
+            pass
         else:
             raise NotImplementedError("Unsupported jumpkind")

Alternatives

No response

Additional context

No response

@xxr0ss
Copy link
Author

xxr0ss commented Mar 5, 2024

well, the eBPF's exit is not a proper example, according to the eBPF instruction set docs, the instruction exit refers to "return".
but I still think it'll be great if JumpKind.Exit is handled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant