Skip to content

Commit 99bb944

Browse files
utam0kroboquat
authored andcommitted
workspackit: put the workspace id into seccomp handler's log to trace.
1 parent f5b1475 commit 99bb944

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

components/workspacekit/cmd/rings.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ var ring0Cmd = &cobra.Command{
120120
cmd.Env = append(os.Environ(),
121121
"WORKSPACEKIT_FSSHIFT="+prep.FsShift.String(),
122122
fmt.Sprintf("WORKSPACEKIT_NO_WORKSPACE_MOUNT=%v", prep.FullWorkspaceBackup || prep.PersistentVolumeClaim),
123-
"GITPOD_WORKSPACE_ID="+wsid,
124123
)
125124

126125
if err := cmd.Start(); err != nil {
@@ -373,7 +372,6 @@ var ring1Cmd = &cobra.Command{
373372
}
374373

375374
env = append(env, "WORKSPACEKIT_WRAP_NETNS=true")
376-
env = append(env, "GITPOD_WORKSPACE_ID="+wsid)
377375

378376
socketFN := filepath.Join(os.TempDir(), fmt.Sprintf("workspacekit-ring1-%d.unix", time.Now().UnixNano()))
379377
skt, err := net.Listen("unix", socketFN)
@@ -521,6 +519,7 @@ var ring1Cmd = &cobra.Command{
521519
Ring2PID: cmd.Process.Pid,
522520
Ring2Rootfs: ring2Root,
523521
BindEvents: make(chan seccomp.BindEvent),
522+
WorkspaceId: wsid,
524523
}
525524

526525
stp, errchan := seccomp.Handle(scmpfd, handler)

components/workspacekit/pkg/seccomp/notify.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ type InWorkspaceHandler struct {
186186
Ring2PID int
187187
Ring2Rootfs string
188188
BindEvents chan<- BindEvent
189+
WorkspaceId string
189190
}
190191

191192
// BindEvent describes a process binding to a socket
@@ -196,9 +197,10 @@ type BindEvent struct {
196197
// Mount handles mount syscalls
197198
func (h *InWorkspaceHandler) Mount(req *libseccomp.ScmpNotifReq) (val uint64, errno int32, flags uint32) {
198199
log := log.WithFields(map[string]interface{}{
199-
"syscall": "mount",
200-
"pid": req.Pid,
201-
"id": req.ID,
200+
"syscall": "mount",
201+
"worksapceId": h.WorkspaceId,
202+
"pid": req.Pid,
203+
"id": req.ID,
202204
})
203205

204206
memFile, err := readarg.OpenMem(req.Pid)
@@ -301,9 +303,10 @@ func (h *InWorkspaceHandler) Mount(req *libseccomp.ScmpNotifReq) (val uint64, er
301303
func (h *InWorkspaceHandler) Umount(req *libseccomp.ScmpNotifReq) (val uint64, errno int32, flags uint32) {
302304
nme, _ := req.Data.Syscall.GetName()
303305
log := log.WithFields(map[string]interface{}{
304-
"syscall": nme,
305-
"pid": req.Pid,
306-
"id": req.ID,
306+
"syscall": nme,
307+
"workspaceId": h.WorkspaceId,
308+
"pid": req.Pid,
309+
"id": req.ID,
307310
})
308311

309312
memFile, err := readarg.OpenMem(req.Pid)
@@ -380,9 +383,10 @@ func (h *InWorkspaceHandler) Umount(req *libseccomp.ScmpNotifReq) (val uint64, e
380383

381384
func (h *InWorkspaceHandler) Bind(req *libseccomp.ScmpNotifReq) (val uint64, errno int32, flags uint32) {
382385
log := log.WithFields(map[string]interface{}{
383-
"syscall": "bind",
384-
"pid": req.Pid,
385-
"id": req.ID,
386+
"syscall": "bind",
387+
"workspaceId": h.WorkspaceId,
388+
"pid": req.Pid,
389+
"id": req.ID,
386390
})
387391
// We want the syscall to succeed, no matter what we do in this handler.
388392
// The Kernel will execute the syscall for us.
@@ -425,9 +429,10 @@ func (h *InWorkspaceHandler) Bind(req *libseccomp.ScmpNotifReq) (val uint64, err
425429

426430
func (h *InWorkspaceHandler) Chown(req *libseccomp.ScmpNotifReq) (val uint64, errno int32, flags uint32) {
427431
log := log.WithFields(map[string]interface{}{
428-
"syscall": "chown",
429-
"pid": req.Pid,
430-
"id": req.ID,
432+
"syscall": "chown",
433+
"workspaceId": h.WorkspaceId,
434+
"pid": req.Pid,
435+
"id": req.ID,
431436
})
432437

433438
memFile, err := readarg.OpenMem(req.Pid)

0 commit comments

Comments
 (0)