-
Notifications
You must be signed in to change notification settings - Fork 173
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
RFE: add support for comparisons against 32-bit arguments #384
Open
jhenstridge
wants to merge
8
commits into
seccomp:main
Choose a base branch
from
jhenstridge:32-bit-comparisons
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad65b76
api: Add a SCMP_CMP_32BIT flag bit that can be combined with existing…
jhenstridge b6b2e21
db: extract per db_api_arg portion of _db_rule_gen_32 into its own fu…
jhenstridge 9090c42
db: extract 64-bit comparison generation into _db_rule_gen_arg_64
jhenstridge 0936a72
db: merge _db_rule_gen_64 and _db_rule_gen_32
jhenstridge b86348b
db: generate 32-bit comparisons on 64-bit architectures if SCMP_CMP_3…
jhenstridge 3a13808
tests: add a test covering forced 32-bit comparisons
jhenstridge d472727
db: return EINVAL if there are any unknown flags set in the compariso…
jhenstridge 518493f
tests: add Python version of 32-bit comparison test program
jhenstridge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python | ||
|
||
# | ||
# Seccomp Library test program | ||
# | ||
# Copyright (c) 2022 Canonical Ltd. | ||
# Author: James Henstridge <[email protected]> | ||
# | ||
|
||
# | ||
# This library is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2.1 of the GNU Lesser General Public License as | ||
# published by the Free Software Foundation. | ||
# | ||
# This library is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with this library; if not, see <http://www.gnu.org/licenses>. | ||
# | ||
|
||
import argparse | ||
import sys | ||
|
||
import util | ||
|
||
from seccomp import * | ||
|
||
def test(args): | ||
f = SyscallFilter(KILL) | ||
f.add_rule_exactly(ALLOW, 1001, Arg(0, NE | CMP_32BIT, 0x10)) | ||
f.add_rule_exactly(ALLOW, 1002, Arg(0, LT | CMP_32BIT, 0x10)) | ||
f.add_rule_exactly(ALLOW, 1003, Arg(0, LE | CMP_32BIT, 0x10)) | ||
f.add_rule_exactly(ALLOW, 1004, Arg(0, EQ | CMP_32BIT, 0x10)) | ||
f.add_rule_exactly(ALLOW, 1005, Arg(0, GE | CMP_32BIT, 0x10)) | ||
f.add_rule_exactly(ALLOW, 1006, Arg(0, GT | CMP_32BIT, 0x10)) | ||
f.add_rule_exactly(ALLOW, 1007, Arg(0, MASKED_EQ | CMP_32BIT, 0xff, 0x10)) | ||
return f | ||
|
||
args = util.get_opt() | ||
ctx = test(args) | ||
util.filter_output(args, ctx) | ||
|
||
# kate: syntax python; | ||
# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double bonus points for the Python tests :)