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

virtio/fs: Check capabilities & act accordingly #244

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

asahilina
Copy link
Contributor

Two changes that make the passthrough layer check whether it runs with the proper capabilities to do something (i.e. root) and, if not, make it not do it.

Needed for some experiments I'm trying with the FEX RootFS stuff, but also generally helpful (I don't expect anything else to be needed in libkrun, so I'm sending this early).

When run in muvm as an unprivileged user, write operations right now
kind of work by accident, since libkrun assumes it runs as root:

- If the access is in root context, it assumes it does not need to
  change user. The access is then made as the user.
- If the access is as the muvm user, it tries to change uid to that
  user, which succeeds as a no-op. The access is made as the user, and
  then it tries to change back to root after it, which spams an error
  message.
- If the access is as any other user, it tries to change to that uid,
  which fails and the access fails.

This behavior, except for the spammy error, is essentially what we want.
Re-do the credential change logic to explicitly implement the above,
without trying to change uid/gid at all if we do not have the
capability.

Signed-off-by: Asahi Lina <[email protected]>
This makes overlayfs mounts with virtiofs lower dirs work.

Signed-off-by: Asahi Lina <[email protected]>
Copy link
Contributor

@slp slp left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@slp slp merged commit b67a6a0 into containers:main Dec 19, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants