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 Apr 20, 2022
1 parent 1be409a commit 9d6e4c7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/overlay/overlay.go
Expand Up @@ -942,6 +942,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 9d6e4c7

Please sign in to comment.