Lock the semaphore identifier lock during semaphore initialization to
guarantee atomicity of the operation for other semaphore consumers. In particular, this should guard against access to the semaphore with not done or partially done MAC label assignment. Reviewed by: rwatson MFC after: 1 month
This commit is contained in:
parent
892f21a681
commit
137cf3b682
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=187298
@ -914,6 +914,9 @@ semget(struct thread *td, struct semget_args *uap)
|
||||
goto done2;
|
||||
}
|
||||
DPRINTF(("semid %d is available\n", semid));
|
||||
mtx_lock(&sema_mtx[semid]);
|
||||
KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0,
|
||||
("Lost semaphore %d", semid));
|
||||
sema[semid].u.sem_perm.key = key;
|
||||
sema[semid].u.sem_perm.cuid = cred->cr_uid;
|
||||
sema[semid].u.sem_perm.uid = cred->cr_uid;
|
||||
@ -932,6 +935,7 @@ semget(struct thread *td, struct semget_args *uap)
|
||||
#ifdef MAC
|
||||
mac_sysvsem_create(cred, &sema[semid]);
|
||||
#endif
|
||||
mtx_unlock(&sema_mtx[semid]);
|
||||
DPRINTF(("sembase = %p, next = %p\n",
|
||||
sema[semid].u.sem_base, &sem[semtot]));
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user