summaryrefslogtreecommitdiffstats
path: root/sys/kern/sysv_shm.c
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2008-02-12 20:55:03 +0000
committercsjp <csjp@FreeBSD.org>2008-02-12 20:55:03 +0000
commitb24cb219b9c5b9c7e769dbd2d26caad935b998fd (patch)
tree8d1777983c8795e786f2ca9977a02a96b8361039 /sys/kern/sysv_shm.c
parent841dab65e0dfa62b15f486a07b165dc02840cf3a (diff)
downloadFreeBSD-src-b24cb219b9c5b9c7e769dbd2d26caad935b998fd.zip
FreeBSD-src-b24cb219b9c5b9c7e769dbd2d26caad935b998fd.tar.gz
Make sure we restrict Linux only IPC calls from being executed
through the FreeBSD ABI. IPC_INFO, SHM_INFO, SHM_STAT were added specifically for Linux binary support. They are not documented as being a part of the FreeBSD ABI, also, the structures necessary for them have been hidden away from the users for a long time. Also, the Linux ABI layer uses it's own structures to populate the responses back to the user to ensure that the ABI is consistent. I think there is a bit more separation work that needs to happen. Reviewed by: jhb Discussed with: jhb Discussed on: freebsd-arch@ (very briefly) MFC after: 1 month
Diffstat (limited to 'sys/kern/sysv_shm.c')
-rw-r--r--sys/kern/sysv_shm.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index 57b6c5e..4e9854d 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -545,6 +545,15 @@ kern_shmctl(td, shmid, cmd, buf, bufsz)
mtx_lock(&Giant);
switch (cmd) {
+ /*
+ * It is possible that kern_shmctl is being called from the Linux ABI
+ * layer, in which case, we will need to implement IPC_INFO. It should
+ * be noted that other shmctl calls will be funneled through here for
+ * Linix binaries as well.
+ *
+ * NB: The Linux ABI layer will convert this data to structure(s) more
+ * consistent with the Linux ABI.
+ */
case IPC_INFO:
memcpy(buf, &shminfo, sizeof(shminfo));
if (bufsz)
@@ -639,6 +648,15 @@ shmctl(td, uap)
struct shmid_ds buf;
size_t bufsz;
+ /*
+ * The only reason IPC_INFO, SHM_INFO, SHM_STAT exists is to support
+ * Linux binaries. If we see the call come through the FreeBSD ABI,
+ * return an error back to the user since we do not to support this.
+ */
+ if (uap->cmd == IPC_INFO || uap->cmd == SHM_INFO ||
+ uap->cmd == SHM_STAT)
+ return (EINVAL);
+
/* IPC_SET needs to copyin the buffer before calling kern_shmctl */
if (uap->cmd == IPC_SET) {
if ((error = copyin(uap->buf, &buf, sizeof(struct shmid_ds))))
@@ -651,9 +669,6 @@ shmctl(td, uap)
/* Cases in which we need to copyout */
switch (uap->cmd) {
- case IPC_INFO:
- case SHM_INFO:
- case SHM_STAT:
case IPC_STAT:
error = copyout(&buf, uap->buf, bufsz);
break;
OpenPOWER on IntegriCloud