diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2026-09-25 21:38:06 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2026-09-25 21:38:06 +0000 |
| commit | 546d15061962a8c45c779210969015e30124fe8d (patch) | |
| tree | 9d7f3c6d5d2204813399b308bada9e3139708d7a | |
| parent | 287d60af18126ee0750fa2332896ede2b84a12dc (diff) | |
sysvshm: Fix locking in shm_prison_set()
We were not acquiring the global sysvshm lock when handling cleanup of
sysvshm segments. Acquire the lock in shm_prison_cleanup() instead, to
be consistent with the sysv semaphore code.
Reviewed by: jamie
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D60030
| -rw-r--r-- | sys/kern/sysv_shm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index 8d1a469127c6..6942cb90873b 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -1304,13 +1304,11 @@ shm_prison_remove(void *obj, void *data __unused) struct prison *pr = obj; struct prison *rpr; - SYSVSHM_LOCK(); prison_lock(pr); rpr = osd_jail_get(pr, shm_prison_slot); prison_unlock(pr); if (rpr == pr) shm_prison_cleanup(pr); - SYSVSHM_UNLOCK(); return (0); } @@ -1320,6 +1318,7 @@ shm_prison_cleanup(struct prison *pr) struct shmid_kernel *shmseg; int i; + SYSVSHM_LOCK(); /* Remove any segments that belong to this jail. */ for (i = 0; i < shmalloced; i++) { shmseg = &shmsegs[i]; @@ -1328,6 +1327,7 @@ shm_prison_cleanup(struct prison *pr) shm_remove(shmseg, i); } } + SYSVSHM_UNLOCK(); } SYSCTL_JAIL_PARAM_SYS_NODE(sysvshm, CTLFLAG_RW, "SYSV shared memory"); |
