From 3b2f4495e98bfa9d3457eac045fd5d78491c3e1c Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 2 Jun 2021 17:21:32 -0400 Subject: [PATCH] canUseShifting can segfault Fixes: https://github.com/containers/podman/issues/10535 Signed-off-by: Daniel J Walsh --- store.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/store.go b/store.go index d6d547c648..dc6eaafa2d 100644 --- a/store.go +++ b/store.go @@ -937,7 +937,7 @@ func (s *store) ContainerStore() (ContainerStore, error) { } func (s *store) canUseShifting(uidmap, gidmap []idtools.IDMap) bool { - if !s.graphDriver.SupportsShifting() { + if s.graphDriver == nil || !s.graphDriver.SupportsShifting() { return false } if uidmap != nil && !idtools.IsContiguous(uidmap) { @@ -2668,6 +2668,10 @@ func (s *store) mount(id string, options drivers.MountOpts) (string, error) { s.lastLoaded = time.Now() } + if options.UidMaps != nil || options.GidMaps != nil { + options.DisableShifting = !s.canUseShifting(options.UidMaps, options.GidMaps) + } + if rlstore.Exists(id) { return rlstore.Mount(id, options) } @@ -2708,7 +2712,6 @@ func (s *store) Mount(id, mountLabel string) (string, error) { options.Volatile = v.(bool) } } - options.DisableShifting = !s.canUseShifting(container.UIDMap, container.GIDMap) } return s.mount(id, options) }