-
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
init: switch away from stateDirFd entirely #1570
init: switch away from stateDirFd entirely #1570
Conversation
@crosbymichael This is the patchset I've been promising for a while that would remove the entire possibility of a CVE-2016-9962-style bug happening again. |
libcontainer/container_linux.go
Outdated
// fd, with _LIBCONTAINER_FIFOFD set to its fd number. | ||
func (c *linuxContainer) includeExecFifo(cmd *exec.Cmd) error { | ||
fifoName := filepath.Join(c.root, execFifoFilename) | ||
fifoFd, err := unix.Open(fifoName, unix.O_PATH|unix.O_RDWR|unix.O_CLOEXEC, 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.
"When O_PATH is specified in flags, flag bits other than O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW are ignored"
Should we remove O_RDWR
since it'll be ignored anyway?
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.
Yeah, you're right. I'll remove it.
While we have significant protections in place against CVE-2016-9962, we still were holding onto a file descriptor that referenced the host filesystem. This meant that in certain scenarios it was still possible for a semi-privileged container to gain access to the host filesystem (if they had CAP_SYS_PTRACE). Instead, open the FIFO itself using a O_PATH. This allows us to reference the FIFO directly without providing the ability for directory-level access. When opening the FIFO inside the init process, open it through procfs to re-open the actual FIFO (this is currently the only supported way to open such a file descriptor). Signed-off-by: Aleksa Sarai <[email protected]>
Alright fixed up @hqhq's comment. |
LGTM, really awesome comments throughout @cyphar. 🥇 |
While we have significant protections in place against CVE-2016-9962, we
still were holding onto a file descriptor that referenced the host
filesystem. This meant that in certain scenarios it was still possible
for a semi-privileged container to gain access to the host filesystem
(if they had CAP_SYS_PTRACE).
Instead, open the FIFO itself using a O_PATH. This allows us to
reference the FIFO directly without providing the ability for
directory-level access. When opening the FIFO inside the init process,
open it through procfs to re-open the actual FIFO (this is currently the
only supported way to open such a file descriptor).
Signed-off-by: Aleksa Sarai [email protected]