summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/sysv_shm.c21
-rw-r--r--sys/sys/ipc.h3
-rw-r--r--sys/sys/shm.h2
3 files changed, 22 insertions, 4 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;
diff --git a/sys/sys/ipc.h b/sys/sys/ipc.h
index 57b3186..139b103 100644
--- a/sys/sys/ipc.h
+++ b/sys/sys/ipc.h
@@ -100,6 +100,9 @@ struct ipc_perm {
#define IPC_SET 1 /* set options */
#define IPC_STAT 2 /* get options */
#if __BSD_VISIBLE
+/*
+ * For Linux compatability.
+ */
#define IPC_INFO 3 /* get info */
#endif
diff --git a/sys/sys/shm.h b/sys/sys/shm.h
index 88eaf06..33ed7b0 100644
--- a/sys/sys/shm.h
+++ b/sys/sys/shm.h
@@ -56,7 +56,7 @@
#define SHM_LOCK 11
#define SHM_UNLOCK 12
-/* ipcs shmctl commands */
+/* ipcs shmctl commands for Linux compatability */
#define SHM_STAT 13
#define SHM_INFO 14
OpenPOWER on IntegriCloud