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

default gid map not allowed error when uid != gid #1072

Closed
dtrudg opened this issue Nov 18, 2022 · 3 comments · Fixed by #1073
Closed

default gid map not allowed error when uid != gid #1072

dtrudg opened this issue Nov 18, 2022 · 3 comments · Fixed by #1073

Comments

@dtrudg
Copy link

dtrudg commented Nov 18, 2022

crun version 1.6
commit: 18cf2efbb8feb2b2f20e316520e0fd0b6c41ef4d
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL

At the following line...

gid_map_len = format_default_id_mapping (&gid_map, container->container_gid, container->host_uid, 0);

... the code creating a default gid mapping, when a mapping is not provided in the config.json, appears to be using container_gid to host_uid instead of container_gid to host_gid.

Edit - though I see this... a16fb8c so I'm probably not finding the whole picture here.

This often succeeds as in simple setups a user commonly has a primary group with a gid that is the same numerically as their uid. However when this is not the case:

$ id
uid=1001(circleci) gid=1002(circleci)

...and the config.json requests this gid...

	"process": {
		"terminal": true,
		"user": {
			"uid": 1001,
			"gid": 1002
		},
		...

... then execution will fail, because the mapping is incorrect...

$ crun --debug --root /run/user/1001/singularity-oci run -b /tmp/oci-bundle904459226 24a57941-dd9e-405d-85d3-0e56c17adf72
2022-11-18T15:56:09.000296196Z: non root user need to have an 'user' namespace
newgidmap: gid range [1002-1003) -> [1001-1002) not allowed
2022-11-18T15:56:09.000297587Z: unable to invoke newgidmap, will try creating a user namespace with single mapping as an alternative
2022-11-18T15:56:09.000299080Z: setresgid to 0: Invalid argument
@dtrudg dtrudg changed the title format_default_id_mapping for gid map is using host uid instead of gid default gid map not allowed error when uid != gid Nov 18, 2022
@giuseppe
Copy link
Member

I'll try to reproduce here. This code path is not very well tested because usually crun runs already in a user namespace.
Could you please share the content of /etc/subuid and /etc/subgid?

@dtrudg
Copy link
Author

dtrudg commented Nov 18, 2022

I'll try to reproduce here. This code path is not very well tested because usually crun runs already in a user namespace. Could you please share the content of /etc/subuid and /etc/subgid?

Understood. It's not something that really affects us a great deal. Calling from outside a userns, and without providing uid/gid mappings is just a bit of a stepping stone in something I've been working up... not something that we'll really be doing long term, but I thought I'd report the issue.

The situation arises on a CircleCI instance with id mapping files as below:

circleci@ip-172-28-22-174:~$ cat /etc/subuid
ubuntu:100000:65536
circleci:165536:65536

circleci@ip-172-28-22-174:~$ cat /etc/subgid
ubuntu:100000:65536
circleci:165536:65536

circleci@ip-172-28-22-174:~$ id
uid=1001(circleci) gid=1002(circleci) groups=1002(circleci),4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),118(netdev),119(lxd),997(docker),1000(ubuntu),1001(aws-sudoers)

Thanks!

giuseppe added a commit to giuseppe/crun that referenced this issue Nov 18, 2022
fix creating the default user namespace when the GID on the host is
different than the UID and there is not not already a mapping
specified in the OCI configuration.

Closes: containers#1072

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe
Copy link
Member

thanks for the extra information, opened a PR here: #1073

dtrudg added a commit to dtrudg/singularity that referenced this issue Nov 21, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 5, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 5, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 5, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 6, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 6, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 6, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 6, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Dec 6, 2022
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Feb 9, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Feb 23, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Mar 31, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue May 24, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue May 24, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Jun 14, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Jun 14, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Jun 16, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Jul 4, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Jul 11, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Jul 21, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
edytuk pushed a commit to vzokay/apptainer that referenced this issue Jul 24, 2023
Ensure e2e tests for oci actions use user profile.

Set uid/gid mappings explicitly. We need to do this anyone, going
forward, but here it works around:

containers/crun#1072
Signed-off-by: Edita Kizinevic <edita.kizinevic@cern.ch>
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 a pull request may close this issue.

2 participants