Merge lp://qastaging/~jdstrand/snap-confine/preprocessor into lp://qastaging/~snappy-dev/snap-confine/trunk

Proposed by Jamie Strandboge
Status: Merged
Merged at revision: 113
Proposed branch: lp://qastaging/~jdstrand/snap-confine/preprocessor
Merge into: lp://qastaging/~snappy-dev/snap-confine/trunk
Diff against target: 169 lines (+76/-28)
3 files modified
debian/changelog (+1/-0)
src/seccomp.c (+73/-28)
tests/test_restrictions_working (+2/-0)
To merge this branch: bzr merge lp://qastaging/~jdstrand/snap-confine/preprocessor
Reviewer Review Type Date Requested Status
Tyler Hicks (community) Needs Fixing
Snappy Developers Pending
Review via email: mp+290652@code.qastaging.launchpad.net

Description of the change

preprocess the seccomp file for '@' directives. Right now this is only a small refactor and preprocessing for @unrestricted, but this sets up future directives like @deny rules and @complain.

To post a comment you must log in.
134. By Jamie Strandboge

preprocess_filter() should return void and die() on error

135. By Jamie Strandboge

add SC_MAX_LINE_LENGTH
remove some unnecessary variables

136. By Jamie Strandboge

clarify comment

137. By Jamie Strandboge

merge from trunk

Revision history for this message
Tyler Hicks (tyhicks) wrote :

There's one serious bug that needs fixing (mentioned inline).

I'm having a little trouble understanding the bigger picture of why we need to preprocess. The card corresponding to this MP suggests that it us for @deny and I don't know exactly what @deny will do so could you briefly explain why preprocessing is needed for @deny?

review: Needs Fixing
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Nice catch on the sizeof; that is annoying. I'm going to cleanup those sizeof()s so this won't happen again and also add a test that is close to the max line length to catch this in the future.

The reason for the preprocessing is threefold:
 * Seth mentioned he didn't like that we started to setup the seccomp filter then just bailed. Preprocessing addresses that
 * We are going to need to support complain mode and I was going to introduce @complain for this. With preprocessing I can detect @complain easily and then set seccomp_init() appropriately rather than having to undo stuff
 * I wanted to support deny rules and have deny rules behave like apparmor for policy writers. Ie, if you have a deny rule, any allow rules are ignored. I was going to implement this using '@deny foo' (I chose '@deny' in case 'deny' was ever added as a syscall and to continue with the '@' directives). I was going to preprocess and find all the deny rules, then in postprocess I would check to see if I already saw a deny rule, if I did, then I would skip adding the rule

All combined, preprocessing seemed to be the simplest and easiest to understand method to implement.

Revision history for this message
Tyler Hicks (tyhicks) wrote :

Thanks for the explanation. That makes sense.

Note that the sizeof() in preprocess_filter() is fine since the buf array is declared in scope.

Feel free to merge after you've adjusted read_line() to have a 'size_t buf_len' argument.

138. By Jamie Strandboge

incorporate feedback from tyhicks

139. By Jamie Strandboge

also use buf_len in fprintf

140. By Jamie Strandboge

rename validate_line to validate_and_trim_line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches