kernel/team: Handle setpigd() being invoked for exiting teams.

In the case the team has already been removed from its process group,
this means we are far enough into teardown that we cannot change it.
Simply check for NULL and then return an error if so.

Fixes #17448.
This commit is contained in:
Augustin Cavalier 2022-02-18 17:39:42 -05:00
parent 705ee4bf53
commit 589b419c5b

View File

@ -730,6 +730,9 @@ Team::LockTeamAndProcessGroup()
// Try to lock the group. This will succeed in most cases, simplifying
// things.
ProcessGroup* group = this->group;
if (group == NULL)
return;
if (group->TryLock())
return;
@ -4112,6 +4115,12 @@ _user_setpgid(pid_t processID, pid_t groupID)
team->LockProcessGroup();
ProcessGroup* oldGroup = team->group;
if (oldGroup == NULL) {
// This can only happen if the team is exiting.
ASSERT(team->state >= TEAM_STATE_SHUTDOWN);
return ESRCH;
}
if (oldGroup == group) {
// it's the same as the target group, so just bail out
oldGroup->Unlock();