|
|
5cdd16 |
From a6fec757c8a17f3a5b92fb766b0f2eeb3b1a208a Mon Sep 17 00:00:00 2001
|
|
|
5cdd16 |
From: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
|
5cdd16 |
Date: Thu, 19 Dec 2019 19:06:00 +0100
|
|
|
5cdd16 |
Subject: [PATCH] store: keep graph lock during Mount
|
|
|
5cdd16 |
|
|
|
5cdd16 |
This solves a race condition where a mountpoint is created without the
|
|
|
5cdd16 |
home mount being present.
|
|
|
5cdd16 |
|
|
|
5cdd16 |
The cause is that another process could be calling the graph driver
|
|
|
5cdd16 |
cleanup as part of store.Shutdown() causing the unmount of the
|
|
|
5cdd16 |
driver home directory.
|
|
|
5cdd16 |
|
|
|
5cdd16 |
The unmount could happen between the time the rlstore is retrieved and
|
|
|
5cdd16 |
the actual mount, causing the driver mount to be done without a home
|
|
|
5cdd16 |
mount below it.
|
|
|
5cdd16 |
|
|
|
5cdd16 |
A third process then would re-create again the home mount, shadowing
|
|
|
5cdd16 |
the previous mount.
|
|
|
5cdd16 |
|
|
|
5cdd16 |
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1757845
|
|
|
5cdd16 |
|
|
|
5cdd16 |
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
|
5cdd16 |
---
|
|
|
5cdd16 |
store.go | 16 ++++++++++++++++
|
|
|
5cdd16 |
1 file changed, 16 insertions(+)
|
|
|
5cdd16 |
|
|
|
5cdd16 |
diff --git a/store.go b/store.go
|
|
|
5cdd16 |
index 65808b8a0..272153e51 100644
|
|
|
5cdd16 |
--- a/vendor/github.com/containers/storage/store.go
|
|
|
5cdd16 |
+++ b/vendor/github.com/containers/storage/store.go
|
|
|
5cdd16 |
@@ -2479,6 +2479,10 @@ func (s *store) Mount(id, mountLabel string) (string, error) {
|
|
|
5cdd16 |
if err != nil {
|
|
|
5cdd16 |
return "", err
|
|
|
5cdd16 |
}
|
|
|
5cdd16 |
+
|
|
|
5cdd16 |
+ s.graphLock.Lock()
|
|
|
5cdd16 |
+ defer s.graphLock.Unlock()
|
|
|
5cdd16 |
+
|
|
|
5cdd16 |
rlstore.Lock()
|
|
|
5cdd16 |
defer rlstore.Unlock()
|
|
|
5cdd16 |
if modified, err := rlstore.Modified(); modified || err != nil {
|
|
|
5cdd16 |
@@ -2486,6 +2490,18 @@ func (s *store) Mount(id, mountLabel string) (string, error) {
|
|
|
5cdd16 |
return "", err
|
|
|
5cdd16 |
}
|
|
|
5cdd16 |
}
|
|
|
5cdd16 |
+
|
|
|
5cdd16 |
+ /* We need to make sure the home mount is present when the Mount is done. */
|
|
|
5cdd16 |
+ if s.graphLock.TouchedSince(s.lastLoaded) {
|
|
|
5cdd16 |
+ s.graphDriver = nil
|
|
|
5cdd16 |
+ s.layerStore = nil
|
|
|
5cdd16 |
+ s.graphDriver, err = s.getGraphDriver()
|
|
|
5cdd16 |
+ if err != nil {
|
|
|
5cdd16 |
+ return "", err
|
|
|
5cdd16 |
+ }
|
|
|
5cdd16 |
+ s.lastLoaded = time.Now()
|
|
|
5cdd16 |
+ }
|
|
|
5cdd16 |
+
|
|
|
5cdd16 |
if rlstore.Exists(id) {
|
|
|
5cdd16 |
options := drivers.MountOpts{
|
|
|
5cdd16 |
MountLabel: mountLabel,
|