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

add configuration option for disabling new keyring #8384

Closed
gzm55 opened this issue Nov 18, 2020 · 18 comments · Fixed by #8806
Closed

add configuration option for disabling new keyring #8384

gzm55 opened this issue Nov 18, 2020 · 18 comments · Fixed by #8806
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@gzm55
Copy link

gzm55 commented Nov 18, 2020

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

/kind feature

Description

In a rootless container with lean capabilities, to create a container by podman run, we have problems of no permissions to call pivot_root and create new keyring. In containers.conf, we could disable pivot_root, but we miss an option to disable keyring.

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 18, 2020
@rhatdan
Copy link
Member

rhatdan commented Nov 18, 2020

These look like they are blocked by seccomp rules. Could you give the actual podman command you are trying to execute?

@gzm55
Copy link
Author

gzm55 commented Nov 18, 2020

  1. create docker container:
docker run --rm -it --user test-user \
                   --device /dev/fuse \
                   --cap-add SYS_ADMIN \
                   an-oci-toolset-image sh
  1. in the rootless ADMIN container, create a nested container:
podman run --rm -it --net=host --pid=host busybox echo ok

As @rhatdan said, the problem is that the keyctl() syscall is blocked by seccomp, and according to the docker document, this syscall is blocked to prevent containers from using the kernel keyring, which is not namespaced. I can confirm that, using an special seccomp profile with keyctl enabled, the nested container works.

This syscall is blocked for security concern, so I think we should either namspacize the keyring, or provide an option to reuse the current keyring just like each runtime does. The latter one should be reasonable for nested rootless container.

PS:

podman: 2.1.1
ociRuntime: runc 1.0.0-rc10
cgroupManager: cgroupfs
cgroupVersion: v1
kernel: 3.10.0-1127.19.1.el7.x86_64

@rhatdan
Copy link
Member

rhatdan commented Nov 18, 2020

Docker is wrong, keyctl is namespaced. This seccomp statement is dated.
Podman allow these sysctls by default.
Since this is more about how docker sets up the containers that run podman, it is not a podman issue. So I am going to close this issue.
BTW Why not run podman natively or podman inside of podman?

@rhatdan rhatdan closed this as completed Nov 18, 2020
@gzm55
Copy link
Author

gzm55 commented Nov 18, 2020

Docker is wrong, keyctl is namespaced. This seccomp statement is dated.
Podman allow these sysctls by default.
Since this is more about how docker sets up the containers that run podman, it is not a podman issue. So I am going to close this issue.
BTW Why not run podman natively or podman inside of podman?

OK, thanks to figure out the solution.

Some old ci systems are still used to build images inside a docker container, so we need nested containers. And this system communicate to daemon via unix sock. Later we would like to try the new podman rest api, this way should introduce the native rootless nested containers to our systems.

@gzm55
Copy link
Author

gzm55 commented Nov 18, 2020

@rhatdan is this the default seccomp profile used by podman? this does not enable the keyctl syscall.

@gzm55
Copy link
Author

gzm55 commented Nov 18, 2020

@rhatdan
according to containers/common#294
it seems that the keyctl is still under discussion, how is it going?

@rhatdan
Copy link
Member

rhatdan commented Nov 18, 2020

Well we do a small patch for Fedora to allow it. I attempted to get this in the upstream,but was blocked since some older kernels still did not do a decent job of namespacing keyctl. RHEL7 age kernels.

@gzm55
Copy link
Author

gzm55 commented Nov 19, 2020

@rhatdan since keyctl is not merged in the upstream, and RHEL7 is still widely deployed, so native nested podman container still needs the option describe in this issue. can we re-open this issue and consider again?

@rhatdan rhatdan reopened this Nov 19, 2020
@rhatdan
Copy link
Member

rhatdan commented Nov 19, 2020

containers/common#354

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Dec 21, 2020

This should be in the main branch now.

@rhatdan rhatdan closed this as completed Dec 21, 2020
@gzm55
Copy link
Author

gzm55 commented Dec 22, 2020

@rhatdan do you mean that the master branch of podman already has a new podman run ... option for disabling creating a new keyring? I tested the latest tag 2.2.1 and searched the commits in the last 3 weeks, and did not see such an option. How can I disable the keyring feature using the latest or development version of podman.

@rhatdan
Copy link
Member

rhatdan commented Dec 22, 2020

There is support in containers.conf for setting all container engines to create or not create the keyring.

keyring tells the container engine whether to create

a kernel keyring for use within the container.

keyring = true

I believe creating $HOME/.config/containers/containers.conf or /etc/containers/containers.conf should do this, if it is fully wired up.

[containers]
keyring=false

@gzm55
Copy link
Author

gzm55 commented Dec 22, 2020

for podman version 2.2.1, podman recognize keyring option. But after setting keyring=false in /etc/containers/containers.conf, we still got the same error about 'create session key'.

@rhatdan rhatdan reopened this Dec 22, 2020
@rhatdan
Copy link
Member

rhatdan commented Dec 22, 2020

This was not wired down the stack.

rhatdan added a commit to rhatdan/podman that referenced this issue Dec 22, 2020
We have a new field in containers.conf that tells whether
or not we want to generate a new keyring in a container.

This field was being ignored.  It now will be followed and
passed down to conmon.

Fixes: containers#8384

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@rhatdan rhatdan self-assigned this Dec 22, 2020
@rhatdan rhatdan reopened this Dec 24, 2020
@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jan 25, 2021

Looks like this is done in the main branch and podman 3.0.

@hickersonj
Copy link

I'm not able to execute a private registry within a container via podman without having the same keyring error. I have added keyring=false, but still the same error:

Error: unable to start container "0dd65ac9fcf3af154e3caefd8ad638430b6929dfce912bbf7886529833088a94": container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: join session keyring: create session key: operation not permitted: OCI permission denied
# strace shows podman is reading the config
read(3, "[engine]\ncgroup_manager=\"cgroupfs\"\nevents_logger=\"file\"\ntmp_dir=\"/tmp/libpod\"\nno_pivot_root=true\nkeyring=false\nconmon_path=[\"/usr/bin/conmon\",]\nruntime=\"/dat"..., 681) = 680
podman version
Version:      3.2.3
API Version:  3.2.3
Go Version:   go1.16.5
Git Commit:   1e6fd46e91b21342f9454cf8105a92b90e398c52
Built:        Thu Aug 12 19:02:50 2021
OS/Arch:      linux/amd64

runc --version
runc version 1.0.1
commit: v1.0.1-0-g4144b63817eb
spec: 1.0.2-dev
go: go1.16.5
libseccomp: 2.5.1

conmon --version
conmon version 2.0.27
commit: 65fad4bfcb250df0435ea668017e643e7f462155
cat ~/.config/containers/container.conf
[engine]
cgroup_manager="cgroupfs"
events_logger="file"
tmp_dir="/tmp/libpod"
no_pivot_root=true
keyring=false
conmon_path=["/usr/bin/conmon",]
runtime="/usr/bin/runc"

Any feedback on this or how to output what podman is sending to the runc run command would be greatly appreciated.

@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/feature Categorizes issue or PR as related to a new feature. 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