Skip to content
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

support changing of lsm mount context on restore #3068

Merged

Conversation

adrianreber
Copy link
Contributor

@adrianreber adrianreber commented Jul 7, 2021

Wire through CRIU's support to change the mount context on restore.

This is especially useful if restoring a container in a different pod.

Single container restore uses the same SELinux process label and same mount context as during checkpointing. If a container is being restored into an existing pod the process label and the mount context needs to be changed to the context of the pod.

Changing process label on restore is already supported by runc. This patch adds the possibility to change the mount context.

This requires yet unreleased version of CRIU 3.16.

Proposed changelog entry:

New features:
* checkpoint/restore: add an option (`--lsm-mount-context`) to set
  a different LSM mount context on restore. (#3068)

@adrianreber adrianreber force-pushed the 2021-07-07-lsm-mount-context branch from bc90e5f to 02139ea Compare July 7, 2021 13:01
man/runc-restore.8.md Outdated Show resolved Hide resolved
man/runc-restore.8.md Outdated Show resolved Hide resolved
man/runc-restore.8.md Outdated Show resolved Hide resolved
@adrianreber
Copy link
Contributor Author

Made all requested changes and force pushed.

man/runc-restore.8.md Outdated Show resolved Hide resolved
man/runc-restore.8.md Outdated Show resolved Hide resolved
@kolyshkin kolyshkin added this to the 1.1.0 milestone Jul 12, 2021
@adrianreber
Copy link
Contributor Author

Both man page changes applied.

@kolyshkin
Copy link
Contributor

@adrianreber could you please rebase (needed to run latest CI)?

kolyshkin
kolyshkin previously approved these changes Jul 21, 2021
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolyshkin
Copy link
Contributor

@adrianreber needs a rebase 🙏🏻

@adrianreber
Copy link
Contributor Author

@adrianreber needs a rebase 🙏🏻

rebased

kolyshkin
kolyshkin previously approved these changes Jul 28, 2021
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kolyshkin
Copy link
Contributor

@thaJeztah PTAL

@thaJeztah
Copy link
Member

Overall looks good; I'm not a very SELinux person, but I noticed that we also have

--process-label label : Set the asm process label for the process commonly used with selinux(7).

Which uses label as term. Is it clear that both apply a label?

Just asking; I'm fine with this if this term is clearer to more SELinux-savvy users 😅

@kolyshkin
Copy link
Contributor

  1. mount(8) man page clearly talks about contexts (although it has no less than 4 options for that), so I guess "context" is the right term here.

  2. Option --process-label sets SELinux values via /proc using go-selinux pkg. The package uses term "label", the proc(5) (when describing /proc/[pid]/attr files such as attr/exec) uses the terms "attribute", "label", and "[security] context", with "attribute" being the most generic term.

  3. From selinux(7) it seems that "security context" and "label" terms are interchangeable.

Overall, it seems OK as it is (process -- label, mount -- context). We also have --lsm-profile which argument is called label.

@kolyshkin
Copy link
Contributor

@rhatdan can you please review this from the POV of terminology used?

@@ -74,6 +74,14 @@ daemon. See [criu --lazy-pages option](https://criu.org/CLI/opt/--lazy-pages).
: Specify an LSM profile to be used during restore. Here _type_ can either be
**apparamor** or **selinux**, and _label_ is a valid LSM label. For example,
**--lsm-profile "selinux:system_u:system_r:container_t:s0:c82,c137"**.
By default, the checkpointed LSM profile is used upon restore.

**--lsm-mount-context** _context_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate typing extra letters, why not just --mount-context? Or --mount-label, since context is not a common user facing term.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a matter of fact, I think all through runc, it is referred to as the MountLabel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrianreber WDYT about --mount-context or --mount-label?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason not to rename it is to keep the options consistent between criu and runc.

Another reason not to rename it is that Podman already uses this option if it finds support for it in runc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I'll leave this decision to @rhatdan 🦆

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate typing extra letters, why not just --mount-context? Or --mount-label, since context is not a common user facing term.

@rhatdan I think this option is not likely to be used very often directly by users from command-line and using an explicit name clarifies the meaning of "context".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm with @kolyshkin. I think it would be nice to use something a bit less cryptic -- the fact that podman already expects this (presumably because crun already supports this?) is a bit of a shame.

I thought a bit more about the Podman problem and it is not really a problem. Podman currently checks for the existence of --lsm-mount-context and tells the user early if runc does not support it. So we can still call it whatever we want in runc and adapt Podman.

Should I change it to --mount-label? Would that be a good name for everyone?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kolyshkin Are you sure? The example given in the docs is --lsm-mount-context "system_u:object_r:container_file_t:s0:c82,c137". --lsm-profile takes type:profile.

However, since we already have --lsm-profile maybe --lsm-mount-context is more consistent. Since it looks like we've copied the CRIU argument names in the past we should probably just stick with it...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyphar right, I mixed it with --lsm-profile which does have apparmor or selinux prefix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it looks like we've copied the CRIU argument names in the past we should probably just stick with it...

Fair point. Adding --lsm-mount-label to the list of possible names (naming is hard!)

@adrianreber
Copy link
Contributor Author

Rebased.

@adrianreber
Copy link
Contributor Author

So, did we agree on not changing the name of the option? Is this ready to be merged?

cyphar
cyphar previously approved these changes Sep 19, 2021
Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Yeah, let's keep it in line with the other --lsm-* options.

Signed-off-by: Adrian Reber <areber@redhat.com>
Wire through CRIU's support to change the mount context on restore.

This is especially useful if restoring a container in a different pod.

Single container restore uses the same SELinux process label and
same mount context as during checkpointing. If a container is being
restored into an existing pod the process label and the mount context
needs to be changed to the context of the pod.

Changing process label on restore is already supported by runc. This
patch adds the possibility to change the mount context.

Signed-off-by: Adrian Reber <areber@redhat.com>
@adrianreber
Copy link
Contributor Author

I had to rebase again for go.mod conflicts.

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 206c16a into opencontainers:master Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants