Skip to content

Commit

Permalink
Fix accessing to layer without lock
Browse files Browse the repository at this point in the history
There was a possibility to panic due to such behavior:
attempted to update last-writer in lockfile without the write lock

Fixes: #1324

Signed-off-by: Mikhail Khachayants <tyler92@inbox.ru>
  • Loading branch information
tyler92 committed Sep 21, 2022
1 parent 8a581aa commit e35b061
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ func (s *store) newLayerStore(rundir string, layerdir string, driver drivers.Dri
uidMap: copyIDMap(s.uidMap),
gidMap: copyIDMap(s.gidMap),
}
rlstore.Lock()
defer rlstore.Unlock()
if err := rlstore.Load(); err != nil {
return nil, err
}
Expand All @@ -584,6 +586,8 @@ func newROLayerStore(rundir string, layerdir string, driver drivers.Driver) (ROL
bymount: make(map[string]*Layer),
byname: make(map[string]*Layer),
}
rlstore.RLock()
defer rlstore.Unlock()
if err := rlstore.Load(); err != nil {
return nil, err
}
Expand Down

0 comments on commit e35b061

Please sign in to comment.