函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:ipc\msg.c Create Date:2022-07-27 18:17:51
Last Modify:2020-03-17 22:56:56 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:do_msgrcv

函数原型: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 ))

返回类型:long

参数:

类型参数名称
intmsqid
void __user *buf
size_tbufsz
longmsgtyp
intmsgflg
long (*msg_handler
1073  struct msg_msg * msg, * copy = NULL
1076  ns等于ipc_ns
1078  如果msqid小于0或bufsz小于0则返回:负EINVAL
1081  如果msgflg按位与copy (not remove) all queue messages
1082  如果msgflg按位与cv any msg except of specified type.或非msgflg按位与urn error on wait 的值则返回:负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  如果是错误则返回:错误
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  如果是错误
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  返回:错误
1098  循环
1101  msg等于错误号
1102  如果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_则转到:out_unlock1
1105  ipc_lock_object( & q_perm)
1109  msg等于错误号
1110  转到:out_unlock0
1113  msg等于find_msg(msq, & msgtyp, mode)
1114  如果非是错误
1119  如果bufsz小于message text size 且非msgflg按位与 error if message is too big 的值则
1120  msg等于错误号
1121  转到:out_unlock0
1128  msg等于copy_msg(msg, copy)
1129  转到:out_unlock0
1138  atomic_dec( & msg_hdrs)
1139  ss_wakeup(msq, & wake_q, false)
1141  转到:out_unlock0
1145  如果msgflg按位与urn error on wait
1146  msg等于错误号
1147  转到:out_unlock0
1150  添加链表项
1151  r_tsk等于当前进程
1152  r_msgtype等于msgtyp
1153  r_mode等于mode
1154  如果msgflg按位与 error if message is too big r_maxsize等于INT_MAX
1156  否则r_maxsize等于bufsz
1158  r_msg等于错误号
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;* (睡眠态)
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  进程调度
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  如果msg不等于错误号则转到:out_unlock1
1194  ipc_lock_object( & q_perm)
1196  msg等于r_msg
1197  如果msg不等于错误号则转到:out_unlock0
1200  删除链表项
1201  如果signal_pending(当前进程)则
1202  msg等于错误号
1203  转到: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  如果是错误
1215  free_copy(copy)
1216  返回:错误
1219  bufsz等于msg_handler(buf, msg, bufsz)
1220  free_msg(msg)
1222  返回:bufsz
调用者
名称描述
ksys_msgrcv
compat_ksys_msgrcv