Skip to content

Commit f92950e

Browse files
authored
Support mounting NFS shares into workspaces (#19880)
* Handle Nfs call * Extend IWS Api * Add nfs-common * Add args * Mount nfs * Check args * Review comments
1 parent b94aec1 commit f92950e

17 files changed

+1483
-113
lines changed

components/workspacekit/pkg/seccomp/notify.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,20 @@ func (h *InWorkspaceHandler) Mount(req *libseccomp.ScmpNotifReq) (val uint64, er
254254
return Errno(unix.EFAULT)
255255
}
256256

257+
var args string
258+
if len(req.Data.Args) >= 5 && filesystem == "nfs4" {
259+
args, err = readarg.ReadString(memFile, int64(req.Data.Args[4]))
260+
log.WithField("arg", 4).WithError(err).Error("cannot read argument")
261+
}
262+
257263
log.WithFields(map[string]interface{}{
258264
"source": source,
259265
"dest": dest,
260266
"fstype": filesystem,
261-
}).Debug("handling mount syscall")
267+
"args": args,
268+
}).Info("handling mount syscall")
262269

263-
if filesystem == "proc" || filesystem == "sysfs" {
270+
if filesystem == "proc" || filesystem == "sysfs" || filesystem == "nfs4" {
264271
// When a process wants to mount proc relative to `/proc/self` that path has no meaning outside of the processes' context.
265272
// runc started doing this in https://github.com/opencontainers/runc/commit/0ca91f44f1664da834bc61115a849b56d22f595f
266273
// TODO(cw): there must be a better way to handle this. Find one.
@@ -308,10 +315,21 @@ func (h *InWorkspaceHandler) Mount(req *libseccomp.ScmpNotifReq) (val uint64, er
308315
if filesystem == "sysfs" {
309316
call = iws.MountSysfs
310317
}
311-
_, err = call(ctx, &daemonapi.MountProcRequest{
312-
Target: dest,
313-
Pid: int64(req.Pid),
314-
})
318+
319+
if filesystem == "sysfs" || filesystem == "proc" {
320+
_, err = call(ctx, &daemonapi.MountProcRequest{
321+
Target: dest,
322+
Pid: int64(req.Pid),
323+
})
324+
} else if filesystem == "nfs4" {
325+
_, err = iws.MountNfs(ctx, &daemonapi.MountNfsRequest{
326+
Source: source,
327+
Target: dest,
328+
Args: args,
329+
Pid: int64(req.Pid),
330+
})
331+
}
332+
315333
if err != nil {
316334
log.WithField("target", dest).WithError(err).Errorf("cannot mount %s", filesystem)
317335
return err
@@ -324,7 +342,10 @@ func (h *InWorkspaceHandler) Mount(req *libseccomp.ScmpNotifReq) (val uint64, er
324342
if wait > iwsBackoffMaxWait {
325343
wait = iwsBackoffMaxWait
326344
}
345+
} else {
346+
break
327347
}
348+
328349
}
329350
if err != nil {
330351
// We've already logged the reason above

components/ws-daemon-api/go/daemon.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ws-daemon-api/go/daemon_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ws-daemon-api/go/mock/mock.go

Lines changed: 41 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)