unicorn.unicorn.UcError when using timeout

オープン
#1,475 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python

調査の方向性

Reproduce the sample with Qiling 1.4.6, then trace the timeout path through qiling/core.py, qiling/os/linux/linux.py, and Unicorn's emu_start call shown in the traceback. Compare runs with and without timeout and determine how the timeout result should be handled. Done means the timeout behavior is consistent with the documented expectation without an unexpected uncaught error.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug
I want to use Qiling to track the block nodes of the binary hited by the input file. I hope to use the timeout mechanism when calling qiling.run, so I set the timeout parameter to 10000 (10 seconds). As a result, I encountered the following error.

[x]     000000000000400000 - 000000000000403000   r--     re2                    /home/test/re2
[x]     000000000000403000 - 000000000000425000   r-x     re2                    /home/test/re2
[x]     000000000000425000 - 000000000000438000   r--     re2                    /home/test/re2
[x]     000000000000439000 - 00000000000043b000   rw-     re2                    /home/test/re2
[x]     00000000000043b000 - 00000000000043d000   rwx     [hook_mem]             
[x]     0000007ffff7dd5000 - 0000007ffff7dfc000   r-x     ld-linux-x86-64.so.2   /home/rootfs/x8664_linux/lib64/ld-linux-x86-64.so.2
[x]     0000007ffff7ffc000 - 0000007ffff7fff000   rw-     ld-linux-x86-64.so.2   /home/rootfs/x8664_linux/lib64/ld-linux-x86-64.so.2
[x]     0000007ffffffde000 - 00000080000000e000   rwx     [stack]                
[x]     00ffffffffff600000 - 00ffffffffff601000   rwx     [vsyscall]             
Traceback (most recent call last):
  File "/home/source/cfg.py", line 220, in analyze_corpus
    self.tracer.trace_corpus(file_path)
  File "/home/source/cfg.py", line 117, in trace_corpus
    ql.run(timeout=10000)
  File "/home/angr/lib/python3.8/site-packages/qiling/core.py", line 595, in run
    self.os.run()
  File "/home/angr/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 184, in run
    self.ql.emu_start(self.ql.loader.elf_entry, self.exit_point, self.ql.timeout, self.ql.count)
  File "/home/angr/lib/python3.8/site-packages/qiling/core.py", line 769, in emu_start
    self.uc.emu_start(begin, end, timeout, count)
  File "/home/angr/lib/python3.8/site-packages/unicorn/unicorn.py", line 547, in emu_start
    raise UcError(status)
unicorn.unicorn.UcError: Invalid memory fetch (UC_ERR_FETCH_UNMAPPED)

When I remove the timeout parameter, the program runs normally.

Sample Code

ql = Qiling([target, os.path.abspath(corpus)], rootfs=rootfs, verbose=QL_VERBOSE.OFF)
ql.add_fs_mapper(os.path.abspath(corpus), os.path.abspath(corpus))
ql.os.stdout = open(os.devnull, 'wb')
ql.hook_block(hook_for_trace)
ql.run(timeout=10000)

Expected behavior
I want Qiling to forcibly terminate after running for more than 10 seconds, but I haven't found a method to stop it, so I used the timeout parameter.
I was originally expecting it to end after 10 seconds, and then I would check whether Qiling ended abnormally, but now it's throwing an error directly.

Additional context
Version: 1.4.6

May I ask why the timeout triggered this error? If the timeout cannot be used, how should I handle the timeout situation?

主要言語
Python
スター
6.2k
フォーク
806
PR マージ指標
30日以内にマージされた PR はありません

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

qilingframework/qiling のほかの issue

qilingframework/qiling の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。