summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-10-29 11:19:47 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-10-29 11:19:47 +0000
commit3f427a584015fcd59dd9aa342779bbb2ccf00a55 (patch)
tree0966c92b3ce32a6a6ade8760acfe7e97a6f3f360
parent1468f36d44e739dff9cc6044fab527cbc0b806c6 (diff)
downloadsrc-test2-3f427a584015fcd59dd9aa342779bbb2ccf00a55.tar.gz
src-test2-3f427a584015fcd59dd9aa342779bbb2ccf00a55.zip
MFC r366932:
sysv_sem: semusz depends on semume. PR: 250361
Notes
Notes: svn path=/stable/11/; revision=367129
-rw-r--r--sys/kern/sysv_sem.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index a97db6cb87b4..c238ebb1972f 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -179,13 +179,13 @@ struct sem_undo {
#define SEM_ALIGN(bytes) roundup2(bytes, sizeof(long))
/* actual size of an undo structure */
-#define SEMUSZ SEM_ALIGN(offsetof(struct sem_undo, un_ent[SEMUME]))
+#define SEMUSZ(x) SEM_ALIGN(offsetof(struct sem_undo, un_ent[(x)]))
/*
* Macro to find a particular sem_undo vector
*/
#define SEMU(ix) \
- ((struct sem_undo *)(((intptr_t)semu)+ix * seminfo.semusz))
+ ((struct sem_undo *)(((intptr_t)semu) + (ix) * seminfo.semusz))
/*
* semaphore info struct
@@ -197,7 +197,7 @@ struct seminfo seminfo = {
.semmsl = SEMMSL, /* max # of semaphores per id */
.semopm = SEMOPM, /* max # of operations per semop call */
.semume = SEMUME, /* max # of undo entries per process */
- .semusz = SEMUSZ, /* size in bytes of undo structure */
+ .semusz = SEMUSZ(SEMUME), /* size in bytes of undo structure */
.semvmx = SEMVMX, /* semaphore maximum value */
.semaem = SEMAEM, /* adjust on exit max value */
};
@@ -214,7 +214,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semopm, CTLFLAG_RDTUN, &seminfo.semopm, 0,
"Max operations per semop call");
SYSCTL_INT(_kern_ipc, OID_AUTO, semume, CTLFLAG_RDTUN, &seminfo.semume, 0,
"Max undo entries per process");
-SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RDTUN, &seminfo.semusz, 0,
+SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RD, &seminfo.semusz, 0,
"Size in bytes of undo structure");
SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RWTUN, &seminfo.semvmx, 0,
"Semaphore maximum value");
@@ -276,6 +276,7 @@ seminit(void)
M_WAITOK | M_ZERO);
sema_mtx = malloc(sizeof(struct mtx) * seminfo.semmni, M_SEM,
M_WAITOK | M_ZERO);
+ seminfo.semusz = SEMUSZ(seminfo.semume);
semu = malloc(seminfo.semmnu * seminfo.semusz, M_SEM, M_WAITOK);
for (i = 0; i < seminfo.semmni; i++) {