aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/shm.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 216ae727a936..22cffd78dbb1 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -780,11 +780,10 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
780 down_write(&shm_ids(ns).rw_mutex); 780 down_write(&shm_ids(ns).rw_mutex);
781 rcu_read_lock(); 781 rcu_read_lock();
782 782
783 ipcp = ipcctl_pre_down(ns, &shm_ids(ns), shmid, cmd, 783 ipcp = ipcctl_pre_down_nolock(ns, &shm_ids(ns), shmid, cmd,
784 &shmid64.shm_perm, 0); 784 &shmid64.shm_perm, 0);
785 if (IS_ERR(ipcp)) { 785 if (IS_ERR(ipcp)) {
786 err = PTR_ERR(ipcp); 786 err = PTR_ERR(ipcp);
787 /* the ipc lock is not held upon failure */
788 goto out_unlock1; 787 goto out_unlock1;
789 } 788 }
790 789
@@ -792,14 +791,16 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
792 791
793 err = security_shm_shmctl(shp, cmd); 792 err = security_shm_shmctl(shp, cmd);
794 if (err) 793 if (err)
795 goto out_unlock0; 794 goto out_unlock1;
796 795
797 switch (cmd) { 796 switch (cmd) {
798 case IPC_RMID: 797 case IPC_RMID:
798 ipc_lock_object(&shp->shm_perm);
799 /* do_shm_rmid unlocks the ipc object and rcu */ 799 /* do_shm_rmid unlocks the ipc object and rcu */
800 do_shm_rmid(ns, ipcp); 800 do_shm_rmid(ns, ipcp);
801 goto out_up; 801 goto out_up;
802 case IPC_SET: 802 case IPC_SET:
803 ipc_lock_object(&shp->shm_perm);
803 err = ipc_update_perm(&shmid64.shm_perm, ipcp); 804 err = ipc_update_perm(&shmid64.shm_perm, ipcp);
804 if (err) 805 if (err)
805 goto out_unlock0; 806 goto out_unlock0;
@@ -807,6 +808,7 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
807 break; 808 break;
808 default: 809 default:
809 err = -EINVAL; 810 err = -EINVAL;
811 goto out_unlock1;
810 } 812 }
811 813
812out_unlock0: 814out_unlock0: