函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:ipc\sem.c Create Date:2022-07-27 18:20:01
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:semctl_main

函数原型:static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, int cmd, void __user *p)

返回类型:int

参数:

类型参数名称
struct ipc_namespace *ns
intsemid
intsemnum
intcmd
void __user *p
1393  sem_io等于fast_sem_io
1396  _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
1397  sma等于sem_obtain_object_check(ns, semid)
1398  如果是错误
1399  _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()
1400  返回:错误
1403  nsems等于. of semaphores in array
1405  err等于负EACCES
1406  如果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_rcu_wakeup
1409  err等于security_sem_semctl( & permissions .. see ipc.h , cmd)
1410  如果err则转到:out_rcu_wakeup
1413  err等于负EACCES
1415  :cmd恒等于get all semval's
1417  __userarray等于p
1420  If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved
1422  err等于负EIDRM
1423  转到:out_unlock
1425  如果nsems大于512 bytes on stack
1426  如果非ipc_rcu_getref( & permissions .. see ipc.h )则
1427  err等于负EIDRM
1428  转到:out_unlock
1430  sem_unlock(sma, - 1)
1434  如果(sem_io == NULL)则
1442  err等于负EIDRM
1443  转到:out_unlock
1446 i小于. of semaphores in array 循环sem_io[i]等于current value
1448  sem_unlock(sma, - 1)
1449  _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()
1450  err等于0
1451  如果copy_to_user(array, sem_io, nsems * sizeof(ushort))则err等于负EFAULT
1453  转到:out_free
1455  :cmd恒等于set all semval's
1460  如果非ipc_rcu_getref( & permissions .. see ipc.h )则
1461  err等于负EIDRM
1462  转到:out_rcu_wakeup
1464  _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()
1466  如果nsems大于512 bytes on stack
1469  如果(sem_io == NULL)则
1475  如果copy_from_user(sem_io, p, nsems * sizeof(ushort))则
1477  err等于负EFAULT
1478  转到:out_free
1481 i小于nsems循环
1484  err等于负ERANGE
1485  转到:out_free
1488  _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
1489  sem_lock_and_putref(sma)
1491  err等于负EIDRM
1492  转到:out_unlock
1495 i小于nsems循环
1496  current value 等于sem_io[i]
1500  ipc_assert_locked_object( & permissions .. see ipc.h )
1502 i小于nsems循环array of adjustments [i]等于0
1505  create/last semctl() 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.
1507  do_smart_update - optimized update_queue*@sma: semaphore array*@sops: operations that were performed*@nsops: number of operations*@otime: force setting otime*@wake_q: lockless wake-queue head* do_smart_update() does the required calls to update_queue and
1508  err等于0
1509  转到:out_unlock
1513  err等于负EINVAL
1514  如果semnum小于0或semnum大于等于nsems则转到:out_rcu_wakeup
1517  If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved
1518  如果非pc_valid_object() - helper to sort out IPC_RMID races for codepaths* where the respective ipc_ids.rwsem is not being held down.* Checks whether the ipc object is still around or if it's gone already, as
1519  err等于负EIDRM
1520  转到:out_unlock
1523  semnum等于array_index_nospec - sanitize an array index after a bounds check* For a code sequence like:* if (index < size) {* index = array_index_nospec(index, size);* val = array[index];* }* (semnum, nsems)
1524  curr等于sems[semnum]
1527  :cmd恒等于get semval
1528  err等于current value
1529  转到:out_unlock
1530  :cmd恒等于get sempid
1531  err等于pid_vnr(PID of the process that last modified the semaphore. For* Linux, specifically these are:* - semop* - semctl, via SETVAL and SETALL.* - at task exit when performing undo adjustments (see exit_sem).)
1532  转到:out_unlock
1533  :cmd恒等于get semncnt
1534  err等于The following counts are associated to each semaphore:* semncnt number of tasks waiting on semval being nonzero* semzcnt number of tasks waiting on semval being zero* Per definition, a task waits only on the semaphore of the first semop
1535  转到:out_unlock
1536  :cmd恒等于get semzcnt
1537  err等于The following counts are associated to each semaphore:* semncnt number of tasks waiting on semval being nonzero* semzcnt number of tasks waiting on semval being zero* Per definition, a task waits only on the semaphore of the first semop
1538  转到:out_unlock
1541  out_unlock :
1542  sem_unlock(sma, - 1)
1543  out_rcu_wakeup :
1544  _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()
1545  wake_up_q( & wake_q)
1546  out_free :
1547  如果sem_io不等于fast_sem_iokvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
1549  返回:err
调用者
名称描述
ksys_semctl
compat_ksys_semctl