Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:do_msgrcv

Proto:static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, int msgflg, long (*msg_handler)(void __user *, struct msg_msg *, size_t ))

Type:long

Parameter:

TypeParameterName
intmsqid
void __user *buf
size_tbufsz
longmsgtyp
intmsgflg
long (*msg_handler
1073  struct msg_msg * msg, * copy = NULL
1076  ns = ipc_ns
1078  If msqid < 0 || bufsz < 0 Then Return -EINVAL
1081  If msgflg & copy (not remove) all queue messages Then
1082  If msgflg & cv any msg except of specified type. || Not (msgflg & urn error on wait ) Then Return -EINVAL
1084  copy = prepare_copy(buf, min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(size_t, bufsz, msg_ctlmax))
1085  If IS_ERR(copy) Then Return PTR_ERR(copy)
1088  mode = convert_mode( & msgtyp, msgflg)
1090  _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
1091  msq = msq_obtain_object_check(ns, msqid)
1092  If IS_ERR(msq) Then
1093  _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()
1094  free_copy(copy)
1095  Return PTR_ERR(msq)
1098  cycle
1101  msg = ERR_PTR( - EACCES)
1102  If pcperms - check ipc permissions*@ns: ipc namespace*@ipcp: ipc permission set*@flag: desired permission set* Check user, group, other permissions for access* to ipc resources. return 0 if allowed*@flag will most probably be 0 or ``S_ Then Go to out_unlock1
1105  ipc_lock_object( & q_perm)
1109  msg = ERR_PTR( - EIDRM)
1110  Go to out_unlock0
1113  msg = find_msg(msq, & msgtyp, mode)
1114  If Not IS_ERR(msg) Then
1120  msg = ERR_PTR( - E2BIG)
1121  Go to out_unlock0
1128  msg = copy_msg(msg, copy)
1129  Go to out_unlock0
1138  atomic_dec( & msg_hdrs)
1139  ss_wakeup(msq, & wake_q, false)
1141  Go to out_unlock0
1145  If msgflg & urn error on wait Then
1146  msg = ERR_PTR( - ENOMSG)
1147  Go to out_unlock0
1150  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
1151  r_tsk = current process
1152  r_msgtype = msgtyp
1153  r_mode = mode
1154  If msgflg & error if message is too big Then r_maxsize = INT_MAX
1156  Else r_maxsize = bufsz
1158  r_msg = ERR_PTR( - EAGAIN)
1159  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (TASK_INTERRUPTIBLE)
1161  ipc_unlock_object( & q_perm)
1162  _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()
1163  schedule()
1174  _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
1186  msg = READ_ONCE(r_msg)
1187  If msg != ERR_PTR( - EAGAIN) Then Go to out_unlock1
1194  ipc_lock_object( & q_perm)
1196  msg = r_msg
1197  If msg != ERR_PTR( - EAGAIN) Then Go to out_unlock0
1200  deletes entry from list
1203  Go to out_unlock0
1206  ipc_unlock_object( & q_perm)
1209  out_unlock0 :
1210  ipc_unlock_object( & q_perm)
1211  wake_up_q( & wake_q)
1212  out_unlock1 :
1213  _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()
1214  If IS_ERR(msg) Then
1215  free_copy(copy)
1216  Return PTR_ERR(msg)
1219  bufsz = msg_handler(buf, msg, bufsz)
1220  free_msg(msg)
1222  Return bufsz
Caller
NameDescribe
ksys_msgrcv
compat_ksys_msgrcv