Skip to content

Commit

Permalink
Update SymbolicSocket constraints pointers on fork
Browse files Browse the repository at this point in the history
  • Loading branch information
ekilmer committed Aug 11, 2020
1 parent 8b25940 commit aeb4a31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions manticore/native/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ class CheckpointData(NamedTuple):


class State(StateBase):
def __enter__(self):
new_state = super().__enter__()

# Update constraint pointers in platform objects
from ..platforms.linux import SLinux

if isinstance(new_state.platform, SLinux):

This comment has been minimized.

Copy link
@feliam

feliam Aug 11, 2020

Contributor

I wonder if there is no room for a LinuxState?

This comment has been minimized.

Copy link
@ekilmer

ekilmer Aug 11, 2020

Author Contributor

Good question. I was thinking the same when I ran into an error during a test that used FakePlatform

This comment has been minimized.

Copy link
@ekilmer

ekilmer Aug 12, 2020

Author Contributor

Also, @ehennenfent any thoughts regarding a separate LinuxState?

This comment has been minimized.

Copy link
@ehennenfent

ehennenfent Aug 13, 2020

Contributor

I don't see any reason to oppose it. Am I right in thinking that it helps with encapsulation, but doesn't provide any other benefits?

This comment has been minimized.

Copy link
@ekilmer

ekilmer Aug 13, 2020

Author Contributor

helps with encapsulation, but doesn't provide any other benefits

Yeah, that was my thinking as well

from ..platforms.linux import SymbolicSocket

# Add constraints to symbolic sockets
for fd_entry in new_state.platform.fd_table.entries():
symb_socket_entry = fd_entry.fdlike
if isinstance(symb_socket_entry, SymbolicSocket):
symb_socket_entry._constraints = new_state.constraints

return new_state

@property
def cpu(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion manticore/platforms/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -3279,7 +3279,7 @@ def __setstate__(self, state):
for fd_entry in self.fd_table.entries():
symb_socket_entry = fd_entry.fdlike
if isinstance(symb_socket_entry, SymbolicSocket):
symb_socket_entry._constraints = self._constraints
symb_socket_entry._constraints = self.constraints

def _sys_open_get_file(self, filename: str, flags: int) -> FdLike:
if filename in self.symbolic_files:
Expand Down

0 comments on commit aeb4a31

Please sign in to comment.