Small fixes to trace points

Don't collect `cwd` when task root is not present anymore, e.g. zombie.
Limit the size allocated for address in `connect(2)`.

Updates #4805

PiperOrigin-RevId: 455208465
This commit is contained in:
Fabricio Voznika
2022-06-15 13:39:52 -07:00
committed by gVisor bot
parent 2df29e11dd
commit 6258291815
2 changed files with 9 additions and 10 deletions
+8 -6
View File
@@ -49,12 +49,14 @@ func LoadSeccheckDataLocked(t *Task, mask seccheck.FieldMask, info *pb.ContextDa
info.ContainerId = t.tg.leader.ContainerID()
}
if mask.Contains(seccheck.FieldCtxtCwd) {
root := t.FSContext().RootDirectoryVFS2()
defer root.DecRef(t)
wd := t.FSContext().WorkingDirectoryVFS2()
defer wd.DecRef(t)
vfsObj := root.Mount().Filesystem().VirtualFilesystem()
info.Cwd, _ = vfsObj.PathnameWithDeleted(t, root, wd)
if root := t.FSContext().RootDirectoryVFS2(); root.Ok() {
defer root.DecRef(t)
if wd := t.FSContext().WorkingDirectoryVFS2(); wd.Ok() {
defer wd.DecRef(t)
vfsObj := root.Mount().Filesystem().VirtualFilesystem()
info.Cwd, _ = vfsObj.PathnameWithDeleted(t, root, wd)
}
}
}
if mask.Contains(seccheck.FieldCtxtProcessName) {
info.ProcessName = t.Name()
+1 -4
View File
@@ -191,10 +191,7 @@ func PointConnect(t *kernel.Task, fields seccheck.FieldSet, cxtData *pb.ContextD
addr := info.Args[1].Pointer()
addrlen := info.Args[2].Uint()
if addr > 0 {
p.Address = make([]byte, addrlen)
_, _ = t.CopyInBytes(addr, p.Address)
}
p.Address, _ = CaptureAddress(t, addr, addrlen)
if fields.Local.Contains(seccheck.FieldSyscallPath) {
p.FdPath = getFilePath(t, int32(p.Fd))