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 /ipc/shm.c | |
parent | c0ebccb6fa1e2c9c3377fa8136e6d8bc006fca64 (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.c | 30 |
1 files changed, 4 insertions, 26 deletions
@@ -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) |