-
Notifications
You must be signed in to change notification settings - Fork 178
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 transaction support to the libseccomp API #415
Conversation
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.
Thanks for the patchset, @pcmoore. I think the user-facing API is good. I do have a few questions here and there but nothing earth shattering.
Valgrind output of the test I added:
|
Well unsurprisingly these are the lines that valgrind is angry about:
|
As expected, resizing the snap filter array appeases valgrind. I feel like it's a worthwhile change since this is likely an infrequent operation (and perhaps only in an error path). I think proper memory management may outweigh speed in this case. Also, I don't claim to like my implementation - it was just a proof of concept to verify the root cause :).
|
6adf397
to
a3a7056
Compare
283f792
to
0deb5a2
Compare
I have a rough schedule the next few days, but I should have time at the end of the week to check this (and the other libseccomp patches) out later in the week. |
Hi Tom, no immediate rush, but when you have the time it would be great to look over the other PRs; if you don't have time to merge them - assuming they look good to you - just leave your ACK and I'll take care of them. As far as this PR is concerned, don't spend your time reviewing it just yet, I want to finish up a few things and make sure everything looks good on my end first; I'll leave a note when it is ready for review. Thanks for the previous review and feedback, it's been very helpful. |
Sounds good. I'll focus on the other PRs this week. Let me know when this one is ready, and I'll start looking at it again. |
@pcmoore, I admit I haven't paid attention to this pull request lately. Do you want me to review, or are you still adding some more changes? Thanks! |
I still need to give it a once over, but thanks for checking :) |
It turns out we don't properly handle transaction aborts as we should, this likely broke when we implemented the shadow snapshots but as the transaction concept was not exported via the API, and callers most likely abandoned the filter on error this went unnoticed. This patch ensures that transaction aborts are handled properly by correctly managing the filter's transaction stack. Signed-off-by: Paul Moore <[email protected]>
Fix an off-by-one error that was causing us to leak a db_filter struct at transaction commit time when we removed an arch/ABI in a transaction. Reported-by: Tom Hromatka <[email protected]> Signed-off-by: Paul Moore <[email protected]>
While libseccomp has internally has transaction support for some time now, it hasn't been accessible to callers through the libseccomp API. This patch adds a transaction API as well as supporting documentation and a new unit regression test. int seccomp_transaction_start(const scmp_filter_ctx ctx) int seccomp_transaction_commit(const scmp_filter_ctx ctx) void seccomp_transaction_reject(const scmp_filter_ctx ctx) Signed-off-by: Paul Moore <[email protected]>
Add a test to verify the logic at the end of db_col_transaction_commit() properly copies and releases the snapshots from the filter when the filter length doesn't match the snapshot length. Signed-off-by: Tom Hromatka <[email protected]> [PM: subj tweak] Signed-off-by: Paul Moore <[email protected]>
0deb5a2
to
893e70d
Compare
Okay @drakenclimber, I think this is ready for a closer review when you have the time. |
The patchset looks great to me, @pcmoore. Thanks so much for this; I think it's a really good improvement. |
I think we probably should do a backport of the two fixes. While yes, you are correct that users can't make direct use of the transaction capability in v2.5.Z, transactions are used internally and there is chance for a buggy abort operation if there is an error. The backport should be pretty trivial, I see about doing that right now. |
This PR contains two patches, the first fixes an existing problem with transaction management and the second adds a new transaction API to libseccomp.
@drakenclimber when you have the chance please take a look and let me know what you think, especially regarding the API as that is difficult/impossible to change later. If everything looks okay, I'll submit another PR with the "src/db.c" fix for the release-2.5 branch,