-
Notifications
You must be signed in to change notification settings - Fork 588
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
osutil: add mount/libmount package with option validator #14814
osutil: add mount/libmount package with option validator #14814
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #14814 +/- ##
==========================================
+ Coverage 78.20% 78.26% +0.05%
==========================================
Files 1151 1152 +1
Lines 151396 152065 +669
==========================================
+ Hits 118402 119015 +613
- Misses 25662 25693 +31
- Partials 7332 7357 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
a45e563
to
f5aaf1d
Compare
We need to recognize and validate libmount-style mount options, such as those that one can use with the mount(1) utility on command line for possible conflicts. This is so that the apparmor parser, which does similar validation, does not fail "late" in the interface setup process, when given incorrect data by the mount-control interface. Note that the Darwin implementation of the function is a stub. Jira: https://warthogs.atlassian.net/browse/SNAPDENG-32984 Signed-off-by: Zygmunt Krynicki <[email protected]>
Mount APIs use event propagation terminology with the words mater and slave that are hard to change. Add the two files to the exception list. Signed-off-by: Zygmunt Krynicki <[email protected]>
Signed-off-by: Zygmunt Krynicki <[email protected]>
The mount-control interface used to allow requesting contradicting mount options, such as nodev and dev and would silently pass this down to apparmor_parser. The parser would detect this and cause the failure of the security setup. With this code we now detect this much earlier, at interface validation stage. Fixes: https://warthogs.atlassian.net/browse/SNAPDENG-32984 Signed-off-by: Zygmunt Krynicki <[email protected]>
f5aaf1d
to
c789f68
Compare
I've made the code compatible with Go 1.18 |
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.
To me this looks super clean and nice. Thank you!
|
||
// ValidateMountOptions is a stub. | ||
func ValidateMountOptions(opts ...string) error { | ||
// This is not implemented for Darwin. We could implement it by baking all |
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.
Until the need arrives for this to be on darwin I think this is fine. I'd rather move things around when we need to than try to predict.
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.
LGTM
We need to recognize and validate libmount-style mount options, such as those that one can use with the mount(1) utility on command line for possible conflicts. This is so that the apparmor parser, which does similar validation, does not fail "late" in the interface setup process, when given incorrect data by the mount-control interface.
This patch adds the skeleton of the validator, along with read-only and read-write mount options.
Jira: https://warthogs.atlassian.net/browse/SNAPDENG-32984
NOTE: this is a draft, I need to hook it up to interfaces logic as well.
I have considered asking apparmor for this information but given that we cannot even discover the full set of known mount options and the interrogation is inefficient (compile and see if it gets ignored), I chose to just bake in the table. There are only 32 bits possible so we are not up an unbound problem anyway.
I've only added one pair of conflicting options as this is a draft solicitng review