Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:ipc\msg.c Create Date:2022-07-28 16:41:35
Last Modify:2020-03-17 22:56:56 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:This function handles some msgctl commands which require the rwsem* to be held in write mode.* NOTE: no locks must be held, the rwsem is taken inside this function.

Proto:static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, struct ipc64_perm *perm, int msg_qbytes)

Type:int

Parameter:

TypeParameterName
struct ipc_namespace *ns
intmsqid
intcmd
struct ipc64_perm *perm
intmsg_qbytes
386  lock for writing
387  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
389  ipcp = pcctl_obtain_check - retrieve an ipc object and check permissions*@ns: ipc namespace*@ids: the table of ids where to look for the ipc*@id: the id of the ipc to retrieve*@cmd: the cmd to check*@perm: the permission to set*@extra_perm: one extra permission
391  If IS_ERR(ipcp) Then
392  err = PTR_ERR(ipcp)
393  Go to out_unlock1
396  msq = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(ipcp, structmsg_queue, q_perm)
398  err = security_msg_queue_msgctl( & q_perm, cmd)
399  If err Then Go to out_unlock1
403  Case cmd == move resource
404  ipc_lock_object( & q_perm)
406  que() wakes up waiters on the sender and receiver waiting queue,* removes the message queue from message queue ID IDR, and cleans up all the* messages associated with this queue.* msg_ids.rwsem (writer) and the spinlock for this message queue are held
407  Go to out_up
408  Case cmd == set ipc_perm options
414  err = -EPERM
415  Go to out_unlock1
418  ipc_lock_object( & q_perm)
419  err = pc_update_perm - update the permissions of an ipc object*@in: the permission given as input.*@out: the permission of the ipc to set.
420  If err Then Go to out_unlock0
423  max number of bytes on queue = msg_qbytes
425  last change time = ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME* Returns the wall clock seconds since 1970. This replaces the* get_seconds() interface which is not y2038 safe on 32bit systems.
430  expunge_all(msq, - EAGAIN, & wake_q)
435  ss_wakeup(msq, & wake_q, false)
436  ipc_unlock_object( & q_perm)
437  wake_up_q( & wake_q)
439  Go to out_unlock1
441  Default
442  err = -EINVAL
443  Go to out_unlock1
446  out_unlock0 :
447  ipc_unlock_object( & q_perm)
448  out_unlock1 :
449  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
450  out_up :
451  lease a write lock
452  Return err
Caller
NameDescribe
ksys_msgctl
compat_ksys_msgctl