CreateProcessGroup has to check whether a target process stil exists or not

A caller of CreateProcessGroup looks up a thread group without locks, so
the target process can exit before CreateProcessGroup will be called.

Reported-by: syzbot+6abb7c34663dacbd55a8@syzkaller.appspotmail.com
PiperOrigin-RevId: 381351069
This commit is contained in:
Andrei Vagin
2021-06-24 15:36:01 -07:00
committed by gVisor bot
parent fdf7c49030
commit 2e6195ffe0
+5
View File
@@ -369,6 +369,11 @@ func (tg *ThreadGroup) CreateProcessGroup() error {
// Get the ID for this thread in the current namespace.
id := tg.pidns.tgids[tg]
// Check whether a process still exists or not.
if id == 0 {
return syserror.ESRCH
}
// Per above, check for a Session leader or existing group.
for s := tg.pidns.owner.sessions.Front(); s != nil; s = s.Next() {
if s.leader.pidns != tg.pidns {