Author: bonefish Date: 2011-05-19 00:55:55 +0200 (Thu, 19 May 2011) New Revision: 41573 Changeset: https://dev.haiku-os.org/changeset/41573 Modified: haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h haiku/branches/developer/bonefish/signals/src/system/kernel/usergroup.cpp Log: * Protect the Team::*_uid/*_gid fields by the scheduler lock as well. * Fixed several getter functions which didn't lock at all. Modified: haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h =================================================================== --- haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 2011-05-18 22:51:35 UTC (rev 41572) +++ haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 2011-05-18 22:55:55 UTC (rev 41573) @@ -265,7 +265,8 @@ bigtime_t dead_threads_kernel_time; bigtime_t dead_threads_user_time; - // user group information; protected by fLock + // user group information; protected by fLock, the *_uid/*_gid fields also + // by the scheduler lock uid_t saved_set_uid; uid_t real_uid; uid_t effective_uid; Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/usergroup.cpp =================================================================== --- haiku/branches/developer/bonefish/signals/src/system/kernel/usergroup.cpp 2011-05-18 22:51:35 UTC (rev 41572) +++ haiku/branches/developer/bonefish/signals/src/system/kernel/usergroup.cpp 2011-05-18 22:55:55 UTC (rev 41573) @@ -54,6 +54,7 @@ // setgid() semantics: If privileged set both, real, effective and // saved set-gid, otherwise set the effective gid. if (privileged) { + InterruptsSpinLocker schedulerLocker(gSchedulerLock); team->saved_set_gid = rgid; team->real_gid = rgid; team->effective_gid = rgid; @@ -90,6 +91,7 @@ } // Getting here means all checks were successful -- set the gids. + InterruptsSpinLocker schedulerLocker(gSchedulerLock); team->real_gid = rgid; team->effective_gid = egid; team->saved_set_gid = ssgid; @@ -117,6 +119,7 @@ // setuid() semantics: If privileged set both, real, effective and // saved set-uid, otherwise set the effective uid. if (privileged) { + InterruptsSpinLocker schedulerLocker(gSchedulerLock); team->saved_set_uid = ruid; team->real_uid = ruid; team->effective_uid = ruid; @@ -153,6 +156,7 @@ } // Getting here means all checks were successful -- set the uids. + InterruptsSpinLocker schedulerLocker(gSchedulerLock); team->real_uid = ruid; team->effective_uid = euid; team->saved_set_uid = ssuid; @@ -249,6 +253,8 @@ void inherit_parent_user_and_group(Team* team, Team* parent) { + InterruptsSpinLocker schedulerLocker(gSchedulerLock); + team->saved_set_uid = parent->saved_set_uid; team->real_uid = parent->real_uid; team->effective_uid = parent->effective_uid; @@ -256,6 +262,8 @@ team->real_gid = parent->real_gid; team->effective_gid = parent->effective_gid; + schedulerLocker.Unlock(); + malloc_referenced_acquire(parent->supplementary_groups); team->supplementary_groups = parent->supplementary_groups; team->supplementary_group_count = parent->supplementary_group_count; @@ -271,6 +279,7 @@ return status; TeamLocker teamLocker(team); + InterruptsSpinLocker schedulerLocker(gSchedulerLock); if ((st.st_mode & S_ISUID) != 0) { team->saved_set_uid = st.st_uid; @@ -291,6 +300,8 @@ { Team* team = thread_get_current_thread()->team; + InterruptsSpinLocker schedulerLocker(gSchedulerLock); + return effective ? team->effective_gid : team->real_gid; } @@ -300,6 +311,8 @@ { Team* team = thread_get_current_thread()->team; + InterruptsSpinLocker schedulerLocker(gSchedulerLock); + return effective ? team->effective_uid : team->real_uid; } @@ -340,6 +353,8 @@ { Team* team = thread_get_current_thread()->team; + TeamLocker teamLocker(team); + return effective ? team->effective_gid : team->real_gid; } @@ -349,6 +364,8 @@ { Team* team = thread_get_current_thread()->team; + TeamLocker teamLocker(team); + return effective ? team->effective_uid : team->real_uid; }