@@ -377,7 +377,7 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version)
377377 * NOTE: no locks must be held, the rwsem is taken inside this function.
378378 */
379379static int msgctl_down (struct ipc_namespace * ns , int msqid , int cmd ,
380- struct msqid64_ds * msqid64 )
380+ struct ipc64_perm * perm , int msg_qbytes )
381381{
382382 struct kern_ipc_perm * ipcp ;
383383 struct msg_queue * msq ;
@@ -387,7 +387,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
387387 rcu_read_lock ();
388388
389389 ipcp = ipcctl_obtain_check (ns , & msg_ids (ns ), msqid , cmd ,
390- & msqid64 -> msg_perm , msqid64 -> msg_qbytes );
390+ perm , msg_qbytes );
391391 if (IS_ERR (ipcp )) {
392392 err = PTR_ERR (ipcp );
393393 goto out_unlock1 ;
@@ -409,18 +409,18 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
409409 {
410410 DEFINE_WAKE_Q (wake_q );
411411
412- if (msqid64 -> msg_qbytes > ns -> msg_ctlmnb &&
412+ if (msg_qbytes > ns -> msg_ctlmnb &&
413413 !capable (CAP_SYS_RESOURCE )) {
414414 err = - EPERM ;
415415 goto out_unlock1 ;
416416 }
417417
418418 ipc_lock_object (& msq -> q_perm );
419- err = ipc_update_perm (& msqid64 -> msg_perm , ipcp );
419+ err = ipc_update_perm (perm , ipcp );
420420 if (err )
421421 goto out_unlock0 ;
422422
423- msq -> q_qbytes = msqid64 -> msg_qbytes ;
423+ msq -> q_qbytes = msg_qbytes ;
424424
425425 msq -> q_ctime = ktime_get_real_seconds ();
426426 /*
@@ -601,9 +601,10 @@ static long ksys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf, int ver
601601 case IPC_SET :
602602 if (copy_msqid_from_user (& msqid64 , buf , version ))
603603 return - EFAULT ;
604- /* fallthru */
604+ return msgctl_down (ns , msqid , cmd , & msqid64 .msg_perm ,
605+ msqid64 .msg_qbytes );
605606 case IPC_RMID :
606- return msgctl_down (ns , msqid , cmd , & msqid64 );
607+ return msgctl_down (ns , msqid , cmd , NULL , 0 );
607608 default :
608609 return - EINVAL ;
609610 }
@@ -735,9 +736,9 @@ static long compat_ksys_msgctl(int msqid, int cmd, void __user *uptr, int versio
735736 case IPC_SET :
736737 if (copy_compat_msqid_from_user (& msqid64 , uptr , version ))
737738 return - EFAULT ;
738- /* fallthru */
739+ return msgctl_down ( ns , msqid , cmd , & msqid64 . msg_perm , msqid64 . msg_qbytes );
739740 case IPC_RMID :
740- return msgctl_down (ns , msqid , cmd , & msqid64 );
741+ return msgctl_down (ns , msqid , cmd , NULL , 0 );
741742 default :
742743 return - EINVAL ;
743744 }
0 commit comments