Skip to content

Commit 7f04b7f

Browse files
committed
storage: don't use stagedLayerExtract when mountLabel is set
Just be safe based on the review feedback from the PR. #378 Signed-off-by: Paul Holzinger <[email protected]>
1 parent e2dc28b commit 7f04b7f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

storage/layers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,8 +2526,7 @@ func (r *layerStore) stageWithUnlockedStore(sl *maybeStagedLayerExtraction, pare
25262526
cleanup, stageLayer, size, err := sl.staging.StartStagingDiffToApply(parent, drivers.ApplyDiffOpts{
25272527
Diff: payload,
25282528
Mappings: idtools.NewIDMappingsFromMaps(layerOptions.UIDMap, layerOptions.GIDMap),
2529-
// FIXME: What to do here? We have no lock and assigned label yet.
2530-
// Overlayfs should not need it anyway so this seems fine for now.
2529+
// MountLabel is not supported for the unlocked extraction, see the comment in (*store).PutLayer()
25312530
MountLabel: "",
25322531
})
25332532
sl.cleanupFuncs = append(sl.cleanupFuncs, cleanup)

storage/store.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,12 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w
15771577
}
15781578
}()
15791579
// driver can do unlocked staging so do that without holding the layer lock
1580-
if m.staging != nil {
1580+
// Special case we only support it when no mount label is used. c/image doesn't set it for layers
1581+
// and the overlay driver doesn't use it for extract today so it would be safe even when set but
1582+
// that is not exactly obvious and if someone would implement the ApplyDiffStaging interface for
1583+
// another driver that may be no longer true. So for now simply fall back to the locked extract path
1584+
// to ensure we don't cause any weird issues here.
1585+
if m.staging != nil && mountLabel == "" {
15811586
// func so we have a scope for defer, we don't want to hold the lock for stageWithUnlockedStore()
15821587
layer, err := func() (*Layer, error) {
15831588
if err := rlstore.startReading(); err != nil {

0 commit comments

Comments
 (0)