Skip to content

Commit

Permalink
Lock overlay.Driver.locker before creating a layer
Browse files Browse the repository at this point in the history
It's _completely_ unclear to me why we need this
driver-specific locking when the whole layerStore
is locked before calling the driver; but if it makes
any sense at all, and Driver.Remove is taking the
lock, it seems that driver.create should take
the lock as well.

Note that additionalLayer.CreateAs is not
holding Driver.locker over its modifications;
this does not change that.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Feb 22, 2022
1 parent d79d62e commit e2631cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/overlay/overlay.go
Expand Up @@ -913,6 +913,11 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, disable
rootUID = int(st.UID())
rootGID = int(st.GID())
}

// --- Only access "dir" below.
d.locker.Lock(id)
defer d.locker.Unlock(id)

if err := idtools.MkdirAllAndChownNew(dir, 0700, idPair); err != nil {
return err
}
Expand Down

0 comments on commit e2631cd

Please sign in to comment.