Skip to content

Commit b2a5598

Browse files
nixprimegvisor-bot
authored andcommitted
vfs: generate fake procfs information for unresolved mount promises
Also handle PathnameReachable() failure in GenerateProcMounts() consistently with GenerateProcMountInfo() (the latter changed in cl/485155018). PiperOrigin-RevId: 800198513
1 parent 49a6cc3 commit b2a5598

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

pkg/sentry/vfs/mount.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,15 +1371,19 @@ func (vfs *VirtualFilesystem) GenerateProcMounts(ctx context.Context, taskRootDi
13711371
}
13721372
path, err := vfs.PathnameReachable(ctx, taskRootDir, mntRootVD)
13731373
if err != nil {
1374-
// For some reason we didn't get a path. Log a warning
1375-
// and run with empty path.
1374+
// For some reason we didn't get a path.
13761375
ctx.Warningf("VFS.GenerateProcMounts: error getting pathname for mount root: %v", err)
1377-
path = ""
1376+
continue
13781377
}
13791378
if path == "" {
1380-
// Either an error occurred, or path is not reachable
1381-
// from root.
1382-
break
1379+
// The path is not reachable from root.
1380+
continue
1381+
}
1382+
if mp := vfs.getMountPromise(mntRootVD); mp != nil && !mp.resolved.Load() {
1383+
// Generate fake information for unresolved mount promises for
1384+
// consistency with GenerateProcMountInfo.
1385+
fmt.Fprintf(buf, "none %s promise promise 0 0\n", path)
1386+
continue
13831387
}
13841388

13851389
mntOpts := mnt.Options()
@@ -1466,6 +1470,14 @@ func (vfs *VirtualFilesystem) GenerateProcMountInfo(ctx context.Context, taskRoo
14661470
// The path is not reachable from root.
14671471
continue
14681472
}
1473+
if mp := vfs.getMountPromise(mntRootVD); mp != nil && !mp.resolved.Load() {
1474+
// If the caller is reponsible for resolving the mount promise,
1475+
// blocking below in StatAt will result in deadlock. Some
1476+
// applications expect mount promises to appear in /proc/mountinfo
1477+
// (b/388102869), so generate fake information to avoid this.
1478+
fmt.Fprintf(buf, "0 0 0:0 %s %s promise - promise none promise\n", manglePath(pathFromFS), manglePath(pathFromRoot))
1479+
continue
1480+
}
14691481
// Stat the mount root to get the major/minor device numbers.
14701482
pop := &PathOperation{
14711483
Root: mntRootVD,

0 commit comments

Comments
 (0)