Apply the logic from r363051 to semctl(2) and __sem_base field.

Reported by:	Jeffball <jeffball@grimm-co.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25600
This commit is contained in:
markj 2020-07-09 18:34:54 +00:00
parent 59f784f7ea
commit 64b063841d
2 changed files with 8 additions and 2 deletions

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 23, 2018
.Dd July 9, 2020
.Dt SEMCTL 2
.Os
.Sh NAME
@ -148,7 +148,6 @@ is defined as follows:
.Bd -literal
struct semid_ds {
struct ipc_perm sem_perm; /* operation permission struct */
struct sem *__sem_base; /* kernel data, don't use */
u_short sem_nsems; /* number of sems in set */
time_t sem_otime; /* last operation time */
time_t sem_ctime; /* last change time */

View File

@ -798,6 +798,13 @@ kern_semctl(struct thread *td, int semid, int semnum, int cmd,
bcopy(&semakptr->u, arg->buf, sizeof(struct semid_ds));
if (cred->cr_prison != semakptr->cred->cr_prison)
arg->buf->sem_perm.key = IPC_PRIVATE;
/*
* Try to hide the fact that the structure layout is shared by
* both the kernel and userland. This pointer is not useful to
* userspace.
*/
arg->buf->__sem_base = NULL;
break;
case GETNCNT: