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

System Call Audit #1384

Merged
merged 49 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0d79a21
Move unimplemented syscall logging to decorator
Mar 1, 2019
55398a5
Move unimplemented calls further down
Mar 2, 2019
0e05dd3
Add stubs for unimplemented system calls
Mar 6, 2019
6acaa7e
Move most stubs back to stub file
Mar 6, 2019
3147bdd
Merge branch 'master' into dev-syscall-audit
Mar 6, 2019
3dc02f4
Codeclimate
Mar 6, 2019
b709a69
Fix discrepancies in syscall ABI
Mar 25, 2019
a338b88
Add gettimeofday and directory handling
Mar 29, 2019
92746ee
Hacky pipe implementation
Mar 29, 2019
7536573
Better support for MSR writing
Apr 4, 2019
8fd42f1
Default to success on directory operations
Apr 15, 2019
00569a8
Codeclimate
Apr 15, 2019
84afdf0
More verbose unimplemented syscall printing
Apr 16, 2019
e5daf9d
Fix line overrun before CC calls me out
Apr 16, 2019
1349a69
Add ftruncate support
Apr 16, 2019
0841479
Add link, unlink, and nanosleep
Apr 16, 2019
901cf91
Add getdents
Apr 19, 2019
b2133ca
Add tests for mkdir and time functions
Apr 19, 2019
cac07b7
Fix codeclimate and force rebuild
Apr 25, 2019
1ff1e1a
Add pre and post hooks for syscalls
Apr 26, 2019
f0ed9d9
Merge branch 'master' into dev-syscall-audit
Apr 26, 2019
8d4e0d3
Fix lingering single quotes
Apr 26, 2019
8f9f79e
Handle dumb invocations
Apr 27, 2019
7e3c7d2
Type-o
Apr 27, 2019
25f542d
Make emulator follow logging behavior
May 6, 2019
0271688
CC
May 6, 2019
5b7049c
Fix pipe tests
May 7, 2019
ac36b12
Fix shadowed name
May 7, 2019
e8f78d1
Add test for ftruncate
May 9, 2019
57c1983
Add link tests
May 9, 2019
41135a5
Add chmod test
May 9, 2019
7221428
Rewrite docstrings
May 9, 2019
b3f814e
Replace with simple returns
May 9, 2019
5d4d35f
Strip out unique implementations
May 9, 2019
42200c3
Check that unimplemented syscalls exhibit the proper behavior
May 9, 2019
6b570b4
Merge branch 'master' into dev-syscall-audit
May 9, 2019
3bcc284
Fix missing keyword 'solver'
May 9, 2019
b8c1b87
Pass initial states to will_run callback
May 10, 2019
75784a9
Restore debug printouts after run
May 10, 2019
b05973e
Fix existing `init` calls
May 10, 2019
05e5ac7
Restore old exception behavior
May 10, 2019
b02dd81
Move save_run_data to manticore native
May 13, 2019
8e38d9b
CC
May 13, 2019
aa79b62
Refactor finalization call
May 14, 2019
e386c76
Fix save_run_data
May 15, 2019
541801c
Adjust expected output line counts
May 15, 2019
fdb74d8
CC [ci skip]
May 15, 2019
c05688a
Rename terminate state on exception to kill state
May 16, 2019
9a42527
Move time started to manticore_native
May 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add stubs for unimplemented system calls
  • Loading branch information
Eric Hennenfent committed Mar 6, 2019
commit 0e05dd3ecbd8cbe9da2d9ae418226e37049dabaf
20 changes: 9 additions & 11 deletions manticore/platforms/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import struct
import time
import resource
import wrapt
from typing import Union, List, TypeVar, cast

import io
Expand All @@ -19,14 +18,15 @@
from elftools.elf.sections import SymbolTableSection

from . import linux_syscalls
from . linux_syscall_stubs import SyscallStubs
from ..core.executor import TerminateState
from ..core.smtlib import ConstraintSet, solver, Operators
from ..core.smtlib import Expression
from ..exceptions import SolverError
from ..native.cpu.abstractcpu import Syscall, ConcretizeArgument, Interruption
from ..native.cpu.cpufactory import CpuFactory
from ..native.memory import SMemory32, SMemory64, Memory32, Memory64, LazySMemory32, LazySMemory64
from ..platforms.platform import Platform, SyscallNotImplemented
from ..platforms.platform import Platform, SyscallNotImplemented, unimplemented
from ..utils.helpers import issymbolic

logger = logging.getLogger(__name__)
Expand All @@ -53,12 +53,6 @@ def __init__(self, message='', err=errno.EBADF):
super().__init__(message)


@wrapt.decorator
def unimplemented(wrapped, _instance, args, kwargs):
logger.warning("Unimplemented system call: %s", wrapped.__name__)
return wrapped(*args, **kwargs)


def perms_from_elf(elf_flags):
return [' ', ' x', ' w ', ' wx', 'r ', 'r x', 'rw ', 'rwx'][elf_flags & 7]

Expand Down Expand Up @@ -422,7 +416,7 @@ def __init__(self, program, argv=None, envp=None, disasm='capstone', **kwargs):
self.disasm = disasm
self.envp = envp
self.argv = argv
self.default_to_fail = True
self.stubs = SyscallStubs()

# dict of [int -> (int, int)] where tuple is (soft, hard) limits
self._rlimits = {
Expand Down Expand Up @@ -652,6 +646,7 @@ def __setstate__(self, state):
self._function_abi = state['functionabi']
self._syscall_abi = state['syscallabi']
self._uname_machine = state['uname_machine']
self.stubs = SyscallStubs()
if '_arm_tls_memory' in state:
self._arm_tls_memory = state['_arm_tls_memory']

Expand Down Expand Up @@ -2138,7 +2133,10 @@ def syscall(self):
try:
table = getattr(linux_syscalls, self.current.machine)
name = table.get(index, None)
implementation = getattr(self, name)
if hasattr(self, name):
implementation = getattr(self, name)
else:
implementation = getattr(self.stubs, name)
except (AttributeError, KeyError):
if name is not None:
raise SyscallNotImplemented(index, name)
Expand All @@ -2150,7 +2148,7 @@ def syscall(self):
def sys_clock_gettime(self, clock_id, timespec):
logger.warning("sys_clock_time not really implemented")
if clock_id == 1:
t = int(time.monotonic() * 1000000000)
t = int(time.monotonic() * 1000000000) # switch to monotonic_ns in py3.7
self.current.write_bytes(timespec, struct.pack('l', t // 1000000000) + struct.pack('l', t))
return 0

Expand Down
Loading