-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
rootfs: handle nested procfs mounts for MS_MOVE #2647
Conversation
/cc @giuseppe Does this change make sense to you? |
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.
just a nit, otherwise the change makes sense to me. Thanks!
LGTM except for a single nit. |
In a case where the host /proc mount has already been overmounted, the MS_MOVE handling would get ENOENT when trying to hide (for instance) "/proc/bus" because it had already hidden away "/proc". This revealed two issues in the previous implementation of this hardening feaure: 1. No checks were done to make sure the mount was a "full" mount (it is a mount of the root of the filesystem), but the kernel doesn't permit a non-full mount to be converted to a full mount (for reference, see mnt_already_visible). This just removes extra busy-work during setup. 2. ENOENT was treated as a critical error, even though it actually indicates the mount doesn't exist and thus isn't a problem. A more theoretically pure solution would be to store the set of mountpoints to be hidden and only ignore the error if an ancestor directory of the current mountpoint was already hidden, but that would just add complexity with little justification. In addition, better document the reasoning behind this logic so that folks aren't confused when looking at it. Fixes: 28a697c ("rootfs: umount all procfs and sysfs with --no-pivot") Signed-off-by: Aleksa Sarai <[email protected]>
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
@AkihiroSuda PTAL |
This reverts commit b8bf572. Revert #2647 Reopen #2339 Signed-off-by: Akihiro Suda <[email protected]>
Previously, the filter would be run before all of the fields were parsed (this behaviour also was not documented) -- this resulted in users of the function accidentally assuming that fields like fsinfo.Root would actually be filled correctly. It seems that the performance overhead of parsing a few extra fields is not exorbitant, and optimising this just leads to incorrect user code. For a concrete example, this optimisation actually made this runc change[1] regress a security hardening feature because it relied on fsinfo.Root being filled correctly. [1]: opencontainers/runc#2647 Signed-off-by: Aleksa Sarai <[email protected]>
For preventing regression like #2647 Signed-off-by: Akihiro Suda <[email protected]>
Previously, the filter would be run before all of the fields were parsed (this behaviour also was not documented) -- this resulted in users of the function accidentally assuming that fields like fsinfo.Root would actually be filled correctly. It seems that the performance overhead of parsing a few extra fields is not exorbitant, and optimising this just leads to incorrect user code. For a concrete example, this optimisation actually made this runc change[1] regress a security hardening feature because it relied on fsinfo.Root being filled correctly. [1]: opencontainers/runc#2647 Signed-off-by: Aleksa Sarai <[email protected]>
For preventing regression like opencontainers#2647 Signed-off-by: Akihiro Suda <[email protected]> Signed-off-by: Aleksa Sarai <[email protected]>
For preventing regression like opencontainers#2647 Signed-off-by: Akihiro Suda <[email protected]> Signed-off-by: Aleksa Sarai <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
For preventing regression like opencontainers#2647 Signed-off-by: Akihiro Suda <[email protected]> Signed-off-by: Aleksa Sarai <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
For preventing regression like opencontainers#2647 Signed-off-by: Akihiro Suda <[email protected]> Signed-off-by: Aleksa Sarai <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
In a case where the host /proc mount has already been overmounted, the
MS_MOVE handling would get ENOENT when trying to hide (for instance)
"/proc/bus" because it had already hidden away "/proc". This revealed
two issues in the previous implementation of this hardening feaure:
No checks were done to make sure the mount was a "full" mount (it is
a mount of the root of the filesystem), but the kernel doesn't permit
a non-full mount to be converted to a full mount (for reference, see
mnt_already_visible). This just removes extra busy-work during setup.
ENOENT was treated as a critical error, even though it actually
indicates the mount doesn't exist and thus isn't a problem. A more
theoretically pure solution would be to store the set of mountpoints
to be hidden and only ignore the error if an ancestor directory of
the current mountpoint was already hidden, but that would just add
complexity with little justification.
In addition, better document the reasoning behind this logic so that
folks aren't confused when looking at it.
Fixes #2639
Fixes: 28a697c ("rootfs: umount all procfs and sysfs with --no-pivot")
Signed-off-by: Aleksa Sarai [email protected]