@@ -377,7 +377,7 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version)
377
377
* NOTE: no locks must be held, the rwsem is taken inside this function.
378
378
*/
379
379
static int msgctl_down (struct ipc_namespace * ns , int msqid , int cmd ,
380
- struct msqid64_ds * msqid64 )
380
+ struct ipc64_perm * perm , int msg_qbytes )
381
381
{
382
382
struct kern_ipc_perm * ipcp ;
383
383
struct msg_queue * msq ;
@@ -387,7 +387,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
387
387
rcu_read_lock ();
388
388
389
389
ipcp = ipcctl_obtain_check (ns , & msg_ids (ns ), msqid , cmd ,
390
- & msqid64 -> msg_perm , msqid64 -> msg_qbytes );
390
+ perm , msg_qbytes );
391
391
if (IS_ERR (ipcp )) {
392
392
err = PTR_ERR (ipcp );
393
393
goto out_unlock1 ;
@@ -409,18 +409,18 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
409
409
{
410
410
DEFINE_WAKE_Q (wake_q );
411
411
412
- if (msqid64 -> msg_qbytes > ns -> msg_ctlmnb &&
412
+ if (msg_qbytes > ns -> msg_ctlmnb &&
413
413
!capable (CAP_SYS_RESOURCE )) {
414
414
err = - EPERM ;
415
415
goto out_unlock1 ;
416
416
}
417
417
418
418
ipc_lock_object (& msq -> q_perm );
419
- err = ipc_update_perm (& msqid64 -> msg_perm , ipcp );
419
+ err = ipc_update_perm (perm , ipcp );
420
420
if (err )
421
421
goto out_unlock0 ;
422
422
423
- msq -> q_qbytes = msqid64 -> msg_qbytes ;
423
+ msq -> q_qbytes = msg_qbytes ;
424
424
425
425
msq -> q_ctime = ktime_get_real_seconds ();
426
426
/*
@@ -603,9 +603,10 @@ long ksys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
603
603
case IPC_SET :
604
604
if (copy_msqid_from_user (& msqid64 , buf , version ))
605
605
return - EFAULT ;
606
- /* fallthru */
606
+ return msgctl_down (ns , msqid , cmd , & msqid64 .msg_perm ,
607
+ msqid64 .msg_qbytes );
607
608
case IPC_RMID :
608
- return msgctl_down (ns , msqid , cmd , & msqid64 );
609
+ return msgctl_down (ns , msqid , cmd , NULL , 0 );
609
610
default :
610
611
return - EINVAL ;
611
612
}
@@ -724,9 +725,9 @@ long compat_ksys_msgctl(int msqid, int cmd, void __user *uptr)
724
725
case IPC_SET :
725
726
if (copy_compat_msqid_from_user (& msqid64 , uptr , version ))
726
727
return - EFAULT ;
727
- /* fallthru */
728
+ return msgctl_down ( ns , msqid , cmd , & msqid64 . msg_perm , msqid64 . msg_qbytes );
728
729
case IPC_RMID :
729
- return msgctl_down (ns , msqid , cmd , & msqid64 );
730
+ return msgctl_down (ns , msqid , cmd , NULL , 0 );
730
731
default :
731
732
return - EINVAL ;
732
733
}
0 commit comments