Skip to content

Comments

virtio/fs: Check capabilities & act accordingly#244

Merged
slp merged 2 commits intocontainers:mainfrom
hoshinolina:asahi/fs-check-caps
Dec 19, 2024
Merged

virtio/fs: Check capabilities & act accordingly#244
slp merged 2 commits intocontainers:mainfrom
hoshinolina:asahi/fs-check-caps

Conversation

@hoshinolina
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 <lina@asahilina.net>
This makes overlayfs mounts with virtiofs lower dirs work.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Copy link
Collaborator

@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!

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