diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-07-09 10:10:32 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-07-15 20:46:45 -0400 |
commit | 28327fae62b011216026b66299882c53b95b4500 (patch) | |
tree | a5d0dc678591875f06f45c88cdbbb98c9a0cf8ba | |
parent | c0ebccb6fa1e2c9c3377fa8136e6d8bc006fca64 (diff) |
ipc: make use of compat ipc_perm helpers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | ipc/msg.c | 28 | ||||
-rw-r--r-- | ipc/shm.c | 30 |
2 files changed, 8 insertions, 50 deletions
@@ -591,22 +591,14 @@ static int copy_compat_msqid_from_user(struct msqid64_ds *out, void __user *buf, | |||
591 | memset(out, 0, sizeof(*out)); | 591 | memset(out, 0, sizeof(*out)); |
592 | if (version == IPC_64) { | 592 | if (version == IPC_64) { |
593 | struct compat_msqid64_ds *p = buf; | 593 | struct compat_msqid64_ds *p = buf; |
594 | struct compat_ipc64_perm v; | 594 | if (get_compat_ipc64_perm(&out->msg_perm, &p->msg_perm)) |
595 | if (copy_from_user(&v, &p->msg_perm, sizeof(v))) | ||
596 | return -EFAULT; | 595 | return -EFAULT; |
597 | out->msg_perm.uid = v.uid; | ||
598 | out->msg_perm.gid = v.gid; | ||
599 | out->msg_perm.mode = v.mode; | ||
600 | if (get_user(out->msg_qbytes, &p->msg_qbytes)) | 596 | if (get_user(out->msg_qbytes, &p->msg_qbytes)) |
601 | return -EFAULT; | 597 | return -EFAULT; |
602 | } else { | 598 | } else { |
603 | struct compat_msqid_ds *p = buf; | 599 | struct compat_msqid_ds *p = buf; |
604 | struct compat_ipc_perm v; | 600 | if (get_compat_ipc_perm(&out->msg_perm, &p->msg_perm)) |
605 | if (copy_from_user(&v, &p->msg_perm, sizeof(v))) | ||
606 | return -EFAULT; | 601 | return -EFAULT; |
607 | out->msg_perm.uid = v.uid; | ||
608 | out->msg_perm.gid = v.gid; | ||
609 | out->msg_perm.mode = v.mode; | ||
610 | if (get_user(out->msg_qbytes, &p->msg_qbytes)) | 602 | if (get_user(out->msg_qbytes, &p->msg_qbytes)) |
611 | return -EFAULT; | 603 | return -EFAULT; |
612 | } | 604 | } |
@@ -619,13 +611,7 @@ static int copy_compat_msqid_to_user(void __user *buf, struct msqid64_ds *in, | |||
619 | if (version == IPC_64) { | 611 | if (version == IPC_64) { |
620 | struct compat_msqid64_ds v; | 612 | struct compat_msqid64_ds v; |
621 | memset(&v, 0, sizeof(v)); | 613 | memset(&v, 0, sizeof(v)); |
622 | v.msg_perm.key = in->msg_perm.key; | 614 | to_compat_ipc64_perm(&v.msg_perm, &in->msg_perm); |
623 | v.msg_perm.uid = in->msg_perm.uid; | ||
624 | v.msg_perm.gid = in->msg_perm.gid; | ||
625 | v.msg_perm.cuid = in->msg_perm.cuid; | ||
626 | v.msg_perm.cgid = in->msg_perm.cgid; | ||
627 | v.msg_perm.mode = in->msg_perm.mode; | ||
628 | v.msg_perm.seq = in->msg_perm.seq; | ||
629 | v.msg_stime = in->msg_stime; | 615 | v.msg_stime = in->msg_stime; |
630 | v.msg_rtime = in->msg_rtime; | 616 | v.msg_rtime = in->msg_rtime; |
631 | v.msg_ctime = in->msg_ctime; | 617 | v.msg_ctime = in->msg_ctime; |
@@ -638,13 +624,7 @@ static int copy_compat_msqid_to_user(void __user *buf, struct msqid64_ds *in, | |||
638 | } else { | 624 | } else { |
639 | struct compat_msqid_ds v; | 625 | struct compat_msqid_ds v; |
640 | memset(&v, 0, sizeof(v)); | 626 | memset(&v, 0, sizeof(v)); |
641 | v.msg_perm.key = in->msg_perm.key; | 627 | to_compat_ipc_perm(&v.msg_perm, &in->msg_perm); |
642 | SET_UID(v.msg_perm.uid, in->msg_perm.uid); | ||
643 | SET_GID(v.msg_perm.gid, in->msg_perm.gid); | ||
644 | SET_UID(v.msg_perm.cuid, in->msg_perm.cuid); | ||
645 | SET_GID(v.msg_perm.cgid, in->msg_perm.cgid); | ||
646 | v.msg_perm.mode = in->msg_perm.mode; | ||
647 | v.msg_perm.seq = in->msg_perm.seq; | ||
648 | v.msg_stime = in->msg_stime; | 628 | v.msg_stime = in->msg_stime; |
649 | v.msg_rtime = in->msg_rtime; | 629 | v.msg_rtime = in->msg_rtime; |
650 | v.msg_ctime = in->msg_ctime; | 630 | v.msg_ctime = in->msg_ctime; |
@@ -1161,13 +1161,7 @@ static int copy_compat_shmid_to_user(void __user *buf, struct shmid64_ds *in, | |||
1161 | if (version == IPC_64) { | 1161 | if (version == IPC_64) { |
1162 | struct compat_shmid64_ds v; | 1162 | struct compat_shmid64_ds v; |
1163 | memset(&v, 0, sizeof(v)); | 1163 | memset(&v, 0, sizeof(v)); |
1164 | v.shm_perm.key = in->shm_perm.key; | 1164 | to_compat_ipc64_perm(&v.shm_perm, &in->shm_perm); |
1165 | v.shm_perm.uid = in->shm_perm.uid; | ||
1166 | v.shm_perm.gid = in->shm_perm.gid; | ||
1167 | v.shm_perm.cuid = in->shm_perm.cuid; | ||
1168 | v.shm_perm.cgid = in->shm_perm.cgid; | ||
1169 | v.shm_perm.mode = in->shm_perm.mode; | ||
1170 | v.shm_perm.seq = in->shm_perm.seq; | ||
1171 | v.shm_atime = in->shm_atime; | 1165 | v.shm_atime = in->shm_atime; |
1172 | v.shm_dtime = in->shm_dtime; | 1166 | v.shm_dtime = in->shm_dtime; |
1173 | v.shm_ctime = in->shm_ctime; | 1167 | v.shm_ctime = in->shm_ctime; |
@@ -1179,13 +1173,8 @@ static int copy_compat_shmid_to_user(void __user *buf, struct shmid64_ds *in, | |||
1179 | } else { | 1173 | } else { |
1180 | struct compat_shmid_ds v; | 1174 | struct compat_shmid_ds v; |
1181 | memset(&v, 0, sizeof(v)); | 1175 | memset(&v, 0, sizeof(v)); |
1176 | to_compat_ipc_perm(&v.shm_perm, &in->shm_perm); | ||
1182 | v.shm_perm.key = in->shm_perm.key; | 1177 | v.shm_perm.key = in->shm_perm.key; |
1183 | SET_UID(v.shm_perm.uid, in->shm_perm.uid); | ||
1184 | SET_GID(v.shm_perm.gid, in->shm_perm.gid); | ||
1185 | SET_UID(v.shm_perm.cuid, in->shm_perm.cuid); | ||
1186 | SET_GID(v.shm_perm.cgid, in->shm_perm.cgid); | ||
1187 | v.shm_perm.mode = in->shm_perm.mode; | ||
1188 | v.shm_perm.seq = in->shm_perm.seq; | ||
1189 | v.shm_atime = in->shm_atime; | 1178 | v.shm_atime = in->shm_atime; |
1190 | v.shm_dtime = in->shm_dtime; | 1179 | v.shm_dtime = in->shm_dtime; |
1191 | v.shm_ctime = in->shm_ctime; | 1180 | v.shm_ctime = in->shm_ctime; |
@@ -1203,22 +1192,11 @@ static int copy_compat_shmid_from_user(struct shmid64_ds *out, void __user *buf, | |||
1203 | memset(out, 0, sizeof(*out)); | 1192 | memset(out, 0, sizeof(*out)); |
1204 | if (version == IPC_64) { | 1193 | if (version == IPC_64) { |
1205 | struct compat_shmid64_ds *p = buf; | 1194 | struct compat_shmid64_ds *p = buf; |
1206 | struct compat_ipc64_perm v; | 1195 | return get_compat_ipc64_perm(&out->shm_perm, &p->shm_perm); |
1207 | if (copy_from_user(&v, &p->shm_perm, sizeof(v))) | ||
1208 | return -EFAULT; | ||
1209 | out->shm_perm.uid = v.uid; | ||
1210 | out->shm_perm.gid = v.gid; | ||
1211 | out->shm_perm.mode = v.mode; | ||
1212 | } else { | 1196 | } else { |
1213 | struct compat_shmid_ds *p = buf; | 1197 | struct compat_shmid_ds *p = buf; |
1214 | struct compat_ipc_perm v; | 1198 | return get_compat_ipc_perm(&out->shm_perm, &p->shm_perm); |
1215 | if (copy_from_user(&v, &p->shm_perm, sizeof(v))) | ||
1216 | return -EFAULT; | ||
1217 | out->shm_perm.uid = v.uid; | ||
1218 | out->shm_perm.gid = v.gid; | ||
1219 | out->shm_perm.mode = v.mode; | ||
1220 | } | 1199 | } |
1221 | return 0; | ||
1222 | } | 1200 | } |
1223 | 1201 | ||
1224 | COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr) | 1202 | COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr) |