mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
shm/security: Pass kern_ipc_perm not shmid_kernel into the shm security hooks
All of the implementations of security hooks that take shmid_kernel only access shm_perm the struct kern_ipc_perm member. This means the dependencies of the shm security hooks can be simplified by passing the kern_ipc_perm member of shmid_kernel.. Making this change will allow struct shmid_kernel to become private to ipc/shm.c. Signed-off-by: "Eric W. Biederman" <[email protected]>
This commit is contained in:
parent
aefad9593e
commit
7191adff2a
6 changed files with 52 additions and 56 deletions
17
ipc/shm.c
17
ipc/shm.c
|
|
@ -181,7 +181,7 @@ static void shm_rcu_free(struct rcu_head *head)
|
|||
rcu);
|
||||
struct shmid_kernel *shp = container_of(ptr, struct shmid_kernel,
|
||||
shm_perm);
|
||||
security_shm_free(shp);
|
||||
security_shm_free(&shp->shm_perm);
|
||||
kvfree(shp);
|
||||
}
|
||||
|
||||
|
|
@ -554,7 +554,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
|
|||
shp->mlock_user = NULL;
|
||||
|
||||
shp->shm_perm.security = NULL;
|
||||
error = security_shm_alloc(shp);
|
||||
error = security_shm_alloc(&shp->shm_perm);
|
||||
if (error) {
|
||||
kvfree(shp);
|
||||
return error;
|
||||
|
|
@ -635,10 +635,7 @@ no_file:
|
|||
*/
|
||||
static inline int shm_security(struct kern_ipc_perm *ipcp, int shmflg)
|
||||
{
|
||||
struct shmid_kernel *shp;
|
||||
|
||||
shp = container_of(ipcp, struct shmid_kernel, shm_perm);
|
||||
return security_shm_associate(shp, shmflg);
|
||||
return security_shm_associate(ipcp, shmflg);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -835,7 +832,7 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
|
|||
|
||||
shp = container_of(ipcp, struct shmid_kernel, shm_perm);
|
||||
|
||||
err = security_shm_shmctl(shp, cmd);
|
||||
err = security_shm_shmctl(&shp->shm_perm, cmd);
|
||||
if (err)
|
||||
goto out_unlock1;
|
||||
|
||||
|
|
@ -934,7 +931,7 @@ static int shmctl_stat(struct ipc_namespace *ns, int shmid,
|
|||
if (ipcperms(ns, &shp->shm_perm, S_IRUGO))
|
||||
goto out_unlock;
|
||||
|
||||
err = security_shm_shmctl(shp, cmd);
|
||||
err = security_shm_shmctl(&shp->shm_perm, cmd);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
|
|
@ -978,7 +975,7 @@ static int shmctl_do_lock(struct ipc_namespace *ns, int shmid, int cmd)
|
|||
}
|
||||
|
||||
audit_ipc_obj(&(shp->shm_perm));
|
||||
err = security_shm_shmctl(shp, cmd);
|
||||
err = security_shm_shmctl(&shp->shm_perm, cmd);
|
||||
if (err)
|
||||
goto out_unlock1;
|
||||
|
||||
|
|
@ -1348,7 +1345,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
|
|||
if (ipcperms(ns, &shp->shm_perm, acc_mode))
|
||||
goto out_unlock;
|
||||
|
||||
err = security_shm_shmat(shp, shmaddr, shmflg);
|
||||
err = security_shm_shmat(&shp->shm_perm, shmaddr, shmflg);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue