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

podman run volume mount option "z" does not relabel mount point and contents #10273

Closed
vikas-goel opened this issue May 7, 2021 · 15 comments · Fixed by #10334
Closed

podman run volume mount option "z" does not relabel mount point and contents #10273

vikas-goel opened this issue May 7, 2021 · 15 comments · Fixed by #10334
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@vikas-goel
Copy link
Contributor

vikas-goel commented May 7, 2021

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

When a volume is mounted to a container with SELinux z option with podman run command, the volume remains unlabeled. The z option has no effect. The container processes cannot access the mount point and the contents.

Steps to reproduce the issue:

  1. Create a persistent named volume podman volume create --driver <driver-name> nbconf

  2. Start a container with the volume podman run -dt --volume nbconf:/mnt/nbconf:z --name tme-mas-02 <container-image>

  3. Access the mount point inside the container podman exec -it tme-mas-02 bash followed by ls -l /mnt/nbconf

Describe the results you received:

# podman exec -it tme-mas-02 bash
bash-4.2# ls -l /mnt/nbconf
ls: cannot open directory /mnt/nbconf: Permission denied
bash-4.2# ls -Zd /mnt/nbconf
drwxr-xr-x. root root system_u:object_r:unlabeled_t:s0 /mnt/nbconf
bash-4.2#

Describe the results you expected:
The expected result is that the mount point and contents are relabeled to container_file_t. Docker does it when z option is specified.

bash-4.2# ls -Zd /mnt/nbconf
drwxr-xr-x. root root system_u:object_r:container_file_t:s0 /mnt/nbconf
bash-4.2#

Additional information you deem important (e.g. issue happens only occasionally):
Consistent

Output of podman version:

Version:      3.0.2-dev
API Version:  3.0.0
Go Version:   go1.15.7
Built:        Tue Mar  2 07:10:06 2021
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.19.4
  cgroupManager: systemd
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.26-1.module+el8.4.0+10198+36d1d0e3.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.26, commit: 0a5175681bdd52b99f1f0f442cbba8f8c126a1c9'
  cpus: 8
  distribution:
    distribution: '"rhel"'
    version: "8.4"
  eventLogger: file
  hostname: flex-vm-02.dc2.ros2100.veritas.com
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 4.18.0-293.el8.x86_64
  linkmode: dynamic
  memFree: 8781361152
  memTotal: 33511845888
  ociRuntime:
    name: runc
    package: runc-1.0.0-70.rc92.module+el8.4.0+10198+36d1d0e3.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.2-dev'
  os: linux
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_NET_RAW,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    selinuxEnabled: true
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 16910032896
  swapTotal: 16924012544
  uptime: 66h 45m 19.64s (Approximately 2.75 days)
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 5
    paused: 0
    running: 2
    stopped: 3
  graphDriverName: overlay
  graphOptions:
    overlay2.size: 10G
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 3
  runRoot: /run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 3.0.0
  Built: 1614697806
  BuiltTime: Tue Mar  2 07:10:06 2021
  GitCommit: ""
  GoVersion: go1.15.7
  OsArch: linux/amd64
  Version: 3.0.2-dev

Package info (e.g. output of rpm -q podman or apt list podman):

podman-3.0.1-3.module+el8.4.0+10198+36d1d0e3.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)

No

Additional environment details (AWS, VirtualBox, physical, etc.):
Red Hat Enterprise Linux 8.4 Beta
VMware virtual machine

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 7, 2021
@rhatdan
Copy link
Member

rhatdan commented May 10, 2021

What kind of file system is mounted at /mnt/nbconf?

This works perfectly for me:

# podman run --volume nbconf:/mnt/nbconf:z --rm fedora ls -ldZ /mnt/nbconf
drwxr-xr-x. 2 root root system_u:object_r:container_file_t:s0 6 May 10 13:30 /mnt/nbconf
$ podman run --volume nbconf:/mnt/nbconf:z --rm fedora ls -ldZ /mnt/nbconf
drwxr-xr-x. 2 root root system_u:object_r:container_file_t:s0 4096 May 10 13:29 /mnt/nbconf
$ podman -v
podman version 3.2.0-rc1

@vikas-goel
Copy link
Contributor Author

Hi @rhatdan ,
It is a loop device. https://github.com/vikas-goel/filevol

@mheon
Copy link
Member

mheon commented May 10, 2021 via email

@vikas-goel
Copy link
Contributor Author

vikas-goel commented May 10, 2021

Yes, Docker relabels all kinds of volumes to container_file_t when z is specified. Docker supports uppercase Z too that would set MCS of the container on the volume and contents.

@mheon
Copy link
Member

mheon commented May 10, 2021 via email

@vikas-goel
Copy link
Contributor Author

Thanks @mheon . What's the plan to introduce uppercase Z support?

@mheon
Copy link
Member

mheon commented May 10, 2021 via email

@vikas-goel
Copy link
Contributor Author

Fantastic. The podman manual/doc does not talk about uppercase Z support.

@vikas-goel
Copy link
Contributor Author

The uppercase Z is not effective on local volumes. No MCS category ids get set.

@mheon
Copy link
Member

mheon commented May 10, 2021 via email

mheon added a commit to mheon/libpod that referenced this issue May 17, 2021
Docker allows relabeling of any volume passed in via -v, even
including named volumes. This normally isn't an issue at all,
given named volumes get the right label for container access
automatically, but this becomes an issue when volume plugins are
involved - these aren't managed by Podman, and may well be
unaware of SELinux labelling. We could automatically relabel
these volumes on creation, but I'm still reluctant to do that
(feels like it could break things). Instead, let's allow :z and
:Z to be used with named volumes, so users can explicitly request
relabel of a volume plugin-backed volume.

We also get :U at the same time. I don't see any real need for it
but it also doesn't seem to hurt, so I didn't bother disabling
it.

Fixes containers#10273

Signed-off-by: Matthew Heon <mheon@redhat.com>
@vikas-goel
Copy link
Contributor Author

Thank you @mheon. I can verify the fix on my setup if I get a package for RHEL8.4 Beta.

@vikas-goel
Copy link
Contributor Author

Hi guys (@mheon , @rhatdan),
Is podman 3.2.2 package going to be available for Centos 8?

@mheon
Copy link
Member

mheon commented Jul 9, 2021

8, or Stream 8? It ought to be in Stream 8 already. I don't know whether non-Stream 8 will update to 8.4.x before it EOLs, but if it does it will include this.

@vikas-goel
Copy link
Contributor Author

Yes, Stream-8. The latest version there is 3.1.0.

http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/

Am I looking at wrong location?

@rhatdan
Copy link
Member

rhatdan commented Jul 10, 2021

@jnovy @lsm5 PTAL?

I think once we build a podman 3.2 for RHEL it will show up in Centos Stream. Perhaps we have not done this yet. Centos 8 will get it after RHEL8.5 is released. (Likely Podman 3.3)

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants