mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
configs: make id mappings int64 to better handle 32-bit
Using ints for all of our mapping structures means that a 32-bit binary
errors out when trying to parse /proc/self/*id_map:
failed to cache mappings for userns: failed to parse uid_map of userns /proc/1/ns/user:
parsing id map failed: invalid format in line " 0 0 4294967295": integer overflow on token 4294967295
This issue was unearthed by commit 1912d5988b ("*: actually support
joining a userns with a new container") but the underlying issue has
been present since the docker/libcontainer days.
In theory, switching to uint32 (to match the spec) instead of int64
would also work, but keeping everything signed seems much less
error-prone. It's also important to note that a mapping might be too
large for an int on 32-bit, so we detect this during the mapping.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -1351,7 +1351,7 @@ func ignoreTerminateErrors(err error) error {
|
||||
|
||||
func requiresRootOrMappingTool(c *configs.Config) bool {
|
||||
gidMap := []configs.IDMap{
|
||||
{ContainerID: 0, HostID: os.Getegid(), Size: 1},
|
||||
{ContainerID: 0, HostID: int64(os.Getegid()), Size: 1},
|
||||
}
|
||||
return !reflect.DeepEqual(c.GIDMappings, gidMap)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user