summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2016-02-07 22:12:39 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2016-02-07 22:12:39 +0000
commitf00fb5457ebf5907055e420d803ac67fb098109e (patch)
treed1ff67b50654cbedfcbd100e9ccea7def00ef75f
parent9ef7a36255e617fc030eb2bbd7fea1b67014ed45 (diff)
downloadsrc-test2-f00fb5457ebf5907055e420d803ac67fb098109e.tar.gz
src-test2-f00fb5457ebf5907055e420d803ac67fb098109e.zip
Notes
-rw-r--r--sys/kern/sysv_sem.c10
-rw-r--r--tools/regression/sysvsem/semtest.c9
2 files changed, 14 insertions, 5 deletions
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index d9324f46d0df..22616b988d88 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -867,6 +867,11 @@ sys_semget(struct thread *td, struct semget_args *uap)
}
if (semid < seminfo.semmni) {
DPRINTF(("found public key\n"));
+ if ((semflg & IPC_CREAT) && (semflg & IPC_EXCL)) {
+ DPRINTF(("not exclusive\n"));
+ error = EEXIST;
+ goto done2;
+ }
if ((error = ipcperm(td, &sema[semid].u.sem_perm,
semflg & 0700))) {
goto done2;
@@ -876,11 +881,6 @@ sys_semget(struct thread *td, struct semget_args *uap)
error = EINVAL;
goto done2;
}
- if ((semflg & IPC_CREAT) && (semflg & IPC_EXCL)) {
- DPRINTF(("not exclusive\n"));
- error = EEXIST;
- goto done2;
- }
#ifdef MAC
error = mac_sysvsem_check_semget(cred, &sema[semid]);
if (error != 0)
diff --git a/tools/regression/sysvsem/semtest.c b/tools/regression/sysvsem/semtest.c
index 8a997d0bf6a4..39c416403c63 100644
--- a/tools/regression/sysvsem/semtest.c
+++ b/tools/regression/sysvsem/semtest.c
@@ -152,6 +152,15 @@ main(int argc, char *argv[])
print_semid_ds(&s_ds, 0600);
+ errno = 0;
+ if (semget(semkey, 1, IPC_CREAT | IPC_EXCL | 0600) != -1 ||
+ errno != EEXIST)
+ err(1, "semget IPC_EXCL 1 did not fail with [EEXIST]");
+ errno = 0;
+ if (semget(semkey, 2, IPC_CREAT | IPC_EXCL | 0600) != -1 ||
+ errno != EEXIST)
+ err(1, "semget IPC_EXCL 2 did not fail with [EEXIST]");
+
for (child_count = 0; child_count < 5; child_count++) {
switch ((child_pid = fork())) {
case -1: