diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2018-03-22 21:52:43 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2018-03-22 22:07:51 -0400 |
commit | aefad9593ec5ad4aae5346253a8b646364cd7317 (patch) | |
tree | 98f72912460afef0280f96f14880a8219c615f65 /ipc | |
parent | dd206bec9a446884805370b1c16c1d7a97036777 (diff) |
sem/security: Pass kern_ipc_perm not sem_array into the sem security hooks
All of the implementations of security hooks that take sem_array only
access sem_perm the struct kern_ipc_perm member. This means the
dependencies of the sem security hooks can be simplified by passing
the kern_ipc_perm member of sem_array.
Making this change will allow struct sem and struct sem_array
to become private to ipc/sem.c.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/sem.c | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -265,7 +265,7 @@ static void sem_rcu_free(struct rcu_head *head) | |||
265 | struct kern_ipc_perm *p = container_of(head, struct kern_ipc_perm, rcu); | 265 | struct kern_ipc_perm *p = container_of(head, struct kern_ipc_perm, rcu); |
266 | struct sem_array *sma = container_of(p, struct sem_array, sem_perm); | 266 | struct sem_array *sma = container_of(p, struct sem_array, sem_perm); |
267 | 267 | ||
268 | security_sem_free(sma); | 268 | security_sem_free(&sma->sem_perm); |
269 | kvfree(sma); | 269 | kvfree(sma); |
270 | } | 270 | } |
271 | 271 | ||
@@ -495,7 +495,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params) | |||
495 | sma->sem_perm.key = key; | 495 | sma->sem_perm.key = key; |
496 | 496 | ||
497 | sma->sem_perm.security = NULL; | 497 | sma->sem_perm.security = NULL; |
498 | retval = security_sem_alloc(sma); | 498 | retval = security_sem_alloc(&sma->sem_perm); |
499 | if (retval) { | 499 | if (retval) { |
500 | kvfree(sma); | 500 | kvfree(sma); |
501 | return retval; | 501 | return retval; |
@@ -535,10 +535,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params) | |||
535 | */ | 535 | */ |
536 | static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg) | 536 | static inline int sem_security(struct kern_ipc_perm *ipcp, int semflg) |
537 | { | 537 | { |
538 | struct sem_array *sma; | 538 | return security_sem_associate(ipcp, semflg); |
539 | |||
540 | sma = container_of(ipcp, struct sem_array, sem_perm); | ||
541 | return security_sem_associate(sma, semflg); | ||
542 | } | 539 | } |
543 | 540 | ||
544 | /* | 541 | /* |
@@ -1209,7 +1206,7 @@ static int semctl_stat(struct ipc_namespace *ns, int semid, | |||
1209 | if (ipcperms(ns, &sma->sem_perm, S_IRUGO)) | 1206 | if (ipcperms(ns, &sma->sem_perm, S_IRUGO)) |
1210 | goto out_unlock; | 1207 | goto out_unlock; |
1211 | 1208 | ||
1212 | err = security_sem_semctl(sma, cmd); | 1209 | err = security_sem_semctl(&sma->sem_perm, cmd); |
1213 | if (err) | 1210 | if (err) |
1214 | goto out_unlock; | 1211 | goto out_unlock; |
1215 | 1212 | ||
@@ -1300,7 +1297,7 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum, | |||
1300 | return -EACCES; | 1297 | return -EACCES; |
1301 | } | 1298 | } |
1302 | 1299 | ||
1303 | err = security_sem_semctl(sma, SETVAL); | 1300 | err = security_sem_semctl(&sma->sem_perm, SETVAL); |
1304 | if (err) { | 1301 | if (err) { |
1305 | rcu_read_unlock(); | 1302 | rcu_read_unlock(); |
1306 | return -EACCES; | 1303 | return -EACCES; |
@@ -1354,7 +1351,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
1354 | if (ipcperms(ns, &sma->sem_perm, cmd == SETALL ? S_IWUGO : S_IRUGO)) | 1351 | if (ipcperms(ns, &sma->sem_perm, cmd == SETALL ? S_IWUGO : S_IRUGO)) |
1355 | goto out_rcu_wakeup; | 1352 | goto out_rcu_wakeup; |
1356 | 1353 | ||
1357 | err = security_sem_semctl(sma, cmd); | 1354 | err = security_sem_semctl(&sma->sem_perm, cmd); |
1358 | if (err) | 1355 | if (err) |
1359 | goto out_rcu_wakeup; | 1356 | goto out_rcu_wakeup; |
1360 | 1357 | ||
@@ -1545,7 +1542,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid, | |||
1545 | 1542 | ||
1546 | sma = container_of(ipcp, struct sem_array, sem_perm); | 1543 | sma = container_of(ipcp, struct sem_array, sem_perm); |
1547 | 1544 | ||
1548 | err = security_sem_semctl(sma, cmd); | 1545 | err = security_sem_semctl(&sma->sem_perm, cmd); |
1549 | if (err) | 1546 | if (err) |
1550 | goto out_unlock1; | 1547 | goto out_unlock1; |
1551 | 1548 | ||
@@ -1962,7 +1959,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops, | |||
1962 | goto out_free; | 1959 | goto out_free; |
1963 | } | 1960 | } |
1964 | 1961 | ||
1965 | error = security_sem_semop(sma, sops, nsops, alter); | 1962 | error = security_sem_semop(&sma->sem_perm, sops, nsops, alter); |
1966 | if (error) { | 1963 | if (error) { |
1967 | rcu_read_unlock(); | 1964 | rcu_read_unlock(); |
1968 | goto out_free; | 1965 | goto out_free; |