ipc: make use of compat ipc_perm helpers

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 28327fae c0ebccb6

+8 -50
+4 -24
ipc/msg.c
··· 591 591 memset(out, 0, sizeof(*out)); 592 592 if (version == IPC_64) { 593 593 struct compat_msqid64_ds *p = buf; 594 - struct compat_ipc64_perm v; 595 - if (copy_from_user(&v, &p->msg_perm, sizeof(v))) 594 + if (get_compat_ipc64_perm(&out->msg_perm, &p->msg_perm)) 596 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 596 if (get_user(out->msg_qbytes, &p->msg_qbytes)) 601 597 return -EFAULT; 602 598 } else { 603 599 struct compat_msqid_ds *p = buf; 604 - struct compat_ipc_perm v; 605 - if (copy_from_user(&v, &p->msg_perm, sizeof(v))) 600 + if (get_compat_ipc_perm(&out->msg_perm, &p->msg_perm)) 606 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 602 if (get_user(out->msg_qbytes, &p->msg_qbytes)) 611 603 return -EFAULT; 612 604 } ··· 611 619 if (version == IPC_64) { 612 620 struct compat_msqid64_ds v; 613 621 memset(&v, 0, sizeof(v)); 614 - v.msg_perm.key = in->msg_perm.key; 615 - v.msg_perm.uid = in->msg_perm.uid; 616 - v.msg_perm.gid = in->msg_perm.gid; 617 - v.msg_perm.cuid = in->msg_perm.cuid; 618 - v.msg_perm.cgid = in->msg_perm.cgid; 619 - v.msg_perm.mode = in->msg_perm.mode; 620 - v.msg_perm.seq = in->msg_perm.seq; 622 + to_compat_ipc64_perm(&v.msg_perm, &in->msg_perm); 621 623 v.msg_stime = in->msg_stime; 622 624 v.msg_rtime = in->msg_rtime; 623 625 v.msg_ctime = in->msg_ctime; ··· 624 638 } else { 625 639 struct compat_msqid_ds v; 626 640 memset(&v, 0, sizeof(v)); 627 - v.msg_perm.key = in->msg_perm.key; 628 - SET_UID(v.msg_perm.uid, in->msg_perm.uid); 629 - SET_GID(v.msg_perm.gid, in->msg_perm.gid); 630 - SET_UID(v.msg_perm.cuid, in->msg_perm.cuid); 631 - SET_GID(v.msg_perm.cgid, in->msg_perm.cgid); 632 - v.msg_perm.mode = in->msg_perm.mode; 633 - v.msg_perm.seq = in->msg_perm.seq; 641 + to_compat_ipc_perm(&v.msg_perm, &in->msg_perm); 634 642 v.msg_stime = in->msg_stime; 635 643 v.msg_rtime = in->msg_rtime; 636 644 v.msg_ctime = in->msg_ctime;
+4 -26
ipc/shm.c
··· 1161 1161 if (version == IPC_64) { 1162 1162 struct compat_shmid64_ds v; 1163 1163 memset(&v, 0, sizeof(v)); 1164 - v.shm_perm.key = in->shm_perm.key; 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; 1164 + to_compat_ipc64_perm(&v.shm_perm, &in->shm_perm); 1171 1165 v.shm_atime = in->shm_atime; 1172 1166 v.shm_dtime = in->shm_dtime; 1173 1167 v.shm_ctime = in->shm_ctime; ··· 1173 1179 } else { 1174 1180 struct compat_shmid_ds v; 1175 1181 memset(&v, 0, sizeof(v)); 1182 + to_compat_ipc_perm(&v.shm_perm, &in->shm_perm); 1176 1183 v.shm_perm.key = in->shm_perm.key; 1177 - SET_UID(v.shm_perm.uid, in->shm_perm.uid); 1178 - SET_GID(v.shm_perm.gid, in->shm_perm.gid); 1179 - SET_UID(v.shm_perm.cuid, in->shm_perm.cuid); 1180 - SET_GID(v.shm_perm.cgid, in->shm_perm.cgid); 1181 - v.shm_perm.mode = in->shm_perm.mode; 1182 - v.shm_perm.seq = in->shm_perm.seq; 1183 1184 v.shm_atime = in->shm_atime; 1184 1185 v.shm_dtime = in->shm_dtime; 1185 1186 v.shm_ctime = in->shm_ctime; ··· 1192 1203 memset(out, 0, sizeof(*out)); 1193 1204 if (version == IPC_64) { 1194 1205 struct compat_shmid64_ds *p = buf; 1195 - struct compat_ipc64_perm v; 1196 - if (copy_from_user(&v, &p->shm_perm, sizeof(v))) 1197 - return -EFAULT; 1198 - out->shm_perm.uid = v.uid; 1199 - out->shm_perm.gid = v.gid; 1200 - out->shm_perm.mode = v.mode; 1206 + return get_compat_ipc64_perm(&out->shm_perm, &p->shm_perm); 1201 1207 } else { 1202 1208 struct compat_shmid_ds *p = buf; 1203 - struct compat_ipc_perm v; 1204 - if (copy_from_user(&v, &p->shm_perm, sizeof(v))) 1205 - return -EFAULT; 1206 - out->shm_perm.uid = v.uid; 1207 - out->shm_perm.gid = v.gid; 1208 - out->shm_perm.mode = v.mode; 1209 + return get_compat_ipc_perm(&out->shm_perm, &p->shm_perm); 1209 1210 } 1210 - return 0; 1211 1211 } 1212 1212 1213 1213 COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr)