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

added warning and error to sys_arch_prctl #1319

Merged
merged 3 commits into from Jan 6, 2019

Conversation

Projects
None yet
2 participants
@sharon-lin
Copy link
Contributor

sharon-lin commented Jan 2, 2019

Fixed sys_arch_prctl syscall when wrong code value was passed and raise a NotImplementedError instead of asserting for not supported code values.

This change is Reviewable

logger.debug("code not in expected options ARCH_GET/SET_FS/GS")
return -errno.EINVAL
if code != ARCH_SET_FS:
raise NotImplementedError("code is not set to 0x1002")

This comment has been minimized.

@disconnect3d

disconnect3d Jan 2, 2019

Contributor
Suggested change Beta
raise NotImplementedError("code is not set to 0x1002")
raise NotImplementedError("Manticore supports only arch_prctl with code=ARCH_SET_FS (0x1002) for now")
assert code == ARCH_SET_FS
if code not in (ARCH_SET_GS, ARCH_SET_FS, ARCH_GET_FS, ARCH_GET_GS):
logger.debug("code not in expected options ARCH_GET/SET_FS/GS")
return -errno.EINVAL

This comment has been minimized.

@disconnect3d

disconnect3d Jan 2, 2019

Contributor
Suggested change Beta
return -errno.EINVAL
return -errno.EINVAL

(remove trailing whitespace)

@@ -1412,7 +1412,11 @@ def sys_arch_prctl(self, code, addr):
ARCH_SET_FS = 0x1002
ARCH_GET_FS = 0x1003
ARCH_GET_GS = 0x1004
assert code == ARCH_SET_FS
if code not in (ARCH_SET_GS, ARCH_SET_FS, ARCH_GET_FS, ARCH_GET_GS):

This comment has been minimized.

@disconnect3d

disconnect3d Jan 3, 2019

Contributor
Suggested change Beta
if code not in (ARCH_SET_GS, ARCH_SET_FS, ARCH_GET_FS, ARCH_GET_GS):
if code not in {ARCH_SET_GS, ARCH_SET_FS, ARCH_GET_FS, ARCH_GET_GS}:

It doesn't matter here but usually it is better to use set literals instead of a tuple/list. Sets have average of O(1) while lists have O(n) for item in collection (source).

It can also be tested in ipython interactive shell:
image

@disconnect3d disconnect3d merged commit b7f9a46 into master Jan 6, 2019

5 checks passed

codeclimate All good!
Details
codeclimate/total-coverage 70% (0.0% change)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@disconnect3d disconnect3d deleted the sharon-arch_prctl branch Jan 6, 2019

disconnect3d added a commit that referenced this pull request Jan 8, 2019

Merge branch 'master' into refactor-events
* master:
  Make gas calculation faithfulness configurable (#1279)
  Fix terminated states resurrection (#1326)
  Make is_human a property (#1323)
  added warning and error to sys_arch_prctl (#1319)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment