From 589b419c5b6554436d812457324a6cd7cc56b49b Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 18 Feb 2022 17:39:42 -0500 Subject: [PATCH] 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. --- src/system/kernel/team.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 340a56dbc9..356563a2c8 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -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();