summaryrefslogtreecommitdiff
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-07-09 10:10:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-07-15 20:46:45 -0400
commit28327fae62b011216026b66299882c53b95b4500 (patch)
treea5d0dc678591875f06f45c88cdbbb98c9a0cf8ba /ipc/shm.c
parentc0ebccb6fa1e2c9c3377fa8136e6d8bc006fca64 (diff)
ipc: make use of compat ipc_perm helpers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 87334ee3acb3..2e31545035a6 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1161,13 +1161,7 @@ static int copy_compat_shmid_to_user(void __user *buf, struct shmid64_ds *in,
if (version == IPC_64) {
struct compat_shmid64_ds v;
memset(&v, 0, sizeof(v));
- v.shm_perm.key = in->shm_perm.key;
- v.shm_perm.uid = in->shm_perm.uid;
- v.shm_perm.gid = in->shm_perm.gid;
- v.shm_perm.cuid = in->shm_perm.cuid;
- v.shm_perm.cgid = in->shm_perm.cgid;
- v.shm_perm.mode = in->shm_perm.mode;
- v.shm_perm.seq = in->shm_perm.seq;
+ to_compat_ipc64_perm(&v.shm_perm, &in->shm_perm);
v.shm_atime = in->shm_atime;
v.shm_dtime = in->shm_dtime;
v.shm_ctime = in->shm_ctime;
@@ -1179,13 +1173,8 @@ static int copy_compat_shmid_to_user(void __user *buf, struct shmid64_ds *in,
} else {
struct compat_shmid_ds v;
memset(&v, 0, sizeof(v));
+ to_compat_ipc_perm(&v.shm_perm, &in->shm_perm);
v.shm_perm.key = in->shm_perm.key;
- SET_UID(v.shm_perm.uid, in->shm_perm.uid);
- SET_GID(v.shm_perm.gid, in->shm_perm.gid);
- SET_UID(v.shm_perm.cuid, in->shm_perm.cuid);
- SET_GID(v.shm_perm.cgid, in->shm_perm.cgid);
- v.shm_perm.mode = in->shm_perm.mode;
- v.shm_perm.seq = in->shm_perm.seq;
v.shm_atime = in->shm_atime;
v.shm_dtime = in->shm_dtime;
v.shm_ctime = in->shm_ctime;
@@ -1203,22 +1192,11 @@ static int copy_compat_shmid_from_user(struct shmid64_ds *out, void __user *buf,
memset(out, 0, sizeof(*out));
if (version == IPC_64) {
struct compat_shmid64_ds *p = buf;
- struct compat_ipc64_perm v;
- if (copy_from_user(&v, &p->shm_perm, sizeof(v)))
- return -EFAULT;
- out->shm_perm.uid = v.uid;
- out->shm_perm.gid = v.gid;
- out->shm_perm.mode = v.mode;
+ return get_compat_ipc64_perm(&out->shm_perm, &p->shm_perm);
} else {
struct compat_shmid_ds *p = buf;
- struct compat_ipc_perm v;
- if (copy_from_user(&v, &p->shm_perm, sizeof(v)))
- return -EFAULT;
- out->shm_perm.uid = v.uid;
- out->shm_perm.gid = v.gid;
- out->shm_perm.mode = v.mode;
+ return get_compat_ipc_perm(&out->shm_perm, &p->shm_perm);
}
- return 0;
}
COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr)