podman/pkg
Giuseppe Scrivano ecedda63a6
rootless: automatically split userns ranges
writing to the id map fails when an extent overlaps multiple mappings
in the parent user namespace:

$ cat /proc/self/uid_map
         0       1000          1
         1     100000      65536
$ unshare -U sleep 100 &
[1] 1029703
$ printf "0 0 100\n" | tee /proc/$!/uid_map
0 0 100
tee: /proc/1029703/uid_map: Operation not permitted

This limitation is particularly annoying when working with rootless
containers as each container runs in the rootless user namespace, so a
command like:

$ podman run --uidmap 0:0:2 --rm fedora echo hi
Error: writing file `/proc/664087/gid_map`: Operation not permitted: OCI permission denied

would fail since the specified mapping overlaps the first
mapping (where the user id is mapped to root) and the second extent
with the additional IDs available.

Detect such cases and automatically split the specified mapping with
the equivalent of:

$ podman run --uidmap 0:0:1 --uidmap 1:1:1 --rm fedora echo hi
hi

A fix has already been proposed for the kernel[1], but even if it
accepted it will take time until it is available in a released kernel,
so fix it also in pkg/rootless.

[1] https://lkml.kernel.org/lkml/20201203150252.1229077-1-gscrivan@redhat.com/

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-01-07 09:42:27 +01:00
..
annotations Spelling 2020-12-22 13:34:31 -05:00
api Merge pull request #8831 from bblenard/issue-8658-system-prune-reclaimed-space 2021-01-05 11:35:18 -05:00
auth Add X-Registry-Config support 2020-09-29 08:46:44 -07:00
autoupdate Spelling 2020-12-22 13:34:31 -05:00
bindings Rework pruning to report reclaimed space 2020-12-30 19:57:35 -06:00
cgroups Spelling 2020-12-22 13:34:31 -05:00
channel fix closed the remote connection on pull causes service panic 2020-10-03 11:38:38 +08:00
checkpoint Lowercase some errors 2020-10-05 15:56:44 -07:00
copy Spelling 2020-12-22 13:34:31 -05:00
criu Add helper function to read out CRIU version 2018-10-23 12:52:03 +02:00
ctime Re-add int64 casts for ctime 2019-07-23 15:43:40 -04:00
domain Rework pruning to report reclaimed space 2020-12-30 19:57:35 -06:00
env Ensure DefaultEnvVariables is used in Specgen 2020-08-18 15:17:46 -04:00
errorhandling remote copy 2020-12-18 12:08:49 +01:00
hooks Spelling 2020-12-22 13:34:31 -05:00
inspect Switch all references to github.com/containers/libpod -> podman 2020-07-28 08:23:45 -04:00
kubeutils Remove dependency on kubernetes 2018-03-27 21:55:33 +00:00
lookup Turn on More linters 2020-06-15 07:05:56 -04:00
namespaces [CI:DOCS] BZ1860126 - Fix userns defaults in run man page 2020-08-07 15:42:13 -04:00
netns Spelling 2020-12-22 13:34:31 -05:00
parallel Move pod jobs to parallel execution 2020-10-07 10:00:11 -04:00
ps Consolidate filter logic to pkg subdirectory 2020-12-24 20:27:41 +00:00
registrar Switch all references to github.com/containers/libpod -> podman 2020-07-28 08:23:45 -04:00
registries pkg/registries: add a retiring note 2020-09-30 16:30:41 +02:00
resolvconf Switch all references to github.com/containers/libpod -> podman 2020-07-28 08:23:45 -04:00
rootless rootless: automatically split userns ranges 2021-01-07 09:42:27 +01:00
rootlessport rootlessport: use two different channels 2020-04-29 12:35:23 +02:00
seccomp Spelling 2020-12-22 13:34:31 -05:00
selinux Fix SELinux functions names to not be repetitive 2020-04-23 15:57:34 -04:00
signal Fix build for mips architecture 2020-12-21 15:55:18 +01:00
specgen Merge pull request #8892 from mheon/fix_8886 2021-01-06 15:26:55 -05:00
systemd generate systemd: do not set `KillMode` 2021-01-05 16:37:24 +01:00
terminal Refine public key usage when remote 2020-12-10 15:32:37 -07:00
timetype make lint: enable gocritic 2020-01-13 14:27:02 +01:00
tracing make lint: include pkg/tracing 2020-01-14 09:54:48 +01:00
trust image sign using per user registries.d 2020-12-07 09:58:38 -05:00
util Spelling 2020-12-22 13:34:31 -05:00