-
Notifications
You must be signed in to change notification settings - Fork 972
Container: Don't bother with sys/proc protections when nesting enabled (from Incus) #16927
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
Conversation
…n nesting enabled When nesting is enabled, it's possible for the container to get a clean copy of /proc or /sys mounted anywhere without AppArmor being able to mediate. So there's little point in trying to apply safety checks on top of the main /proc and /sys. On top of that, we've recently discovered that AppArmor doesn't properly handle file access relative to a file descriptor, causing a bunch of those checks to deny access when they shouldn't. Related to lxc/incus#2623 Fixes canonical#16902 Signed-off-by: Stéphane Graber <stgraber@stgraber.org> (cherry picked from commit 1fbe4bffb9748cc3b07aaf5db310d463c1e827d0) Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com> License: Apache-2.0
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.
Pull Request Overview
This PR cherry-picks a security enhancement from Incus that conditionally disables AppArmor protections for /proc and /sys when container nesting is enabled. When nesting is active, containers can mount clean copies of these filesystems anywhere without AppArmor mediation, rendering the main protections ineffective. Additionally, AppArmor has issues with file descriptor-relative access that cause spurious denials.
Key changes:
- Wrapped
/proc/sysand/syssafety checks in{{- if not .nesting }}conditionals - Applied the same conditional logic to AppArmor stacking-related
/sys/kernelprotections
mihalicyn
left a comment
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
Related to canonical/lxd#16927 Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
Related to canonical/lxd#16927 Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
When nesting is enabled, it's possible for the container to get a clean copy of /proc or /sys mounted anywhere without AppArmor being able to mediate. So there's little point in trying to apply safety checks on top of the main /proc and /sys.
On top of that, we've recently discovered that AppArmor doesn't properly handle file access relative to a file descriptor, causing a bunch of those checks to deny access when they shouldn't.
Related to lxc/incus#2623
Fixes #16902
(cherry picked from commit 1fbe4bffb9748cc3b07aaf5db310d463c1e827d0)
License: Apache-2.0