Skip to content

ql_syscall_setsockopt crash #1177

@FernandoDoming

Description

@FernandoDoming

A crash occurs when emulating sample with SHA256 0ae15ae0dd8888628e5b1e9f3f3a3d5bf9bbde44c2283568dbbcf69ea908c6b0. The stacktrace suggest the crash is due to a bug in the setsockopt implementation.

Stacktrace

File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/core.py", line 730, in run
    self.os.run()
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/os/linux/linux.py", line 149, in run
    self.ql.emu_start(self.ql.loader.elf_entry, self.exit_point, self.ql.timeout, self.ql.count)
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/core.py", line 883, in emu_start
    raise self._internal_exception
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/utils.py", line 159, in wrapper
    return func(*args, **kw)
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/core_hooks.py", line 53, in _hook_intr_cb
    ret = hook.call(ql, intno)
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/core_hooks_types.py", line 25, in call
    return self.callback(ql, *args)
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/os/linux/linux.py", line 104, in hook_syscall
    return self.load_syscall()
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/os/posix/posix.py", line 240, in load_syscall
    raise e
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/os/posix/posix.py", line 222, in load_syscall
    retval = syscall_hook(self.ql, *params)
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/colibri/syscalls/network.py", line 192, in syscall_setsockopt
    ql.os.fd[sockfd].setsockopt(level, optname, None, optlen)
  File "/Users/fdd/Library/Python/3.8/lib/python/site-packages/qiling/os/posix/filestruct.py", line 97, in setsockopt
    return self.__socket.setsockopt(level, optname, None, optval)
TypeError: setsockopt() takes exactly 3 arguments (4 given)

According to python's doc setsockopt(level, optname, None, optlen: int) is a valid call introduced in python 3.6 but it still complains about the number of arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions