Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:ipc\sem.c Create Date:2022-07-28 16:44:55
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:This function handles some semctl 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 semctl_down(struct ipc_namespace *ns, int semid, int cmd, struct semid64_ds *semid64)

Type:int

Parameter:

TypeParameterName
struct ipc_namespace *ns
intsemid
intcmd
struct semid64_ds *semid64
1590  lock for writing
1591  _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
1593  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
1595  If IS_ERR(ipcp) Then
1596  err = PTR_ERR(ipcp)
1597  Go to out_unlock1
1600  sma = 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, structsem_array, sem_perm)
1602  err = security_sem_semctl( & permissions .. see ipc.h , cmd)
1603  If err Then Go to out_unlock1
1607  Case cmd == move resource
1608  If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved
1610  Free a semaphore set. freeary() is called with sem_ids.rwsem locked* as a writer and the spinlock for this semaphore set hold. sem_ids.rwsem* remains locked on exit.
1611  Go to out_up
1612  Case cmd == set ipc_perm options
1613  If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved
1614  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.
1615  If err Then Go to out_unlock0
1617  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.
1618  Break
1619  Default
1620  err = -EINVAL
1621  Go to out_unlock1
1624  out_unlock0 :
1625  sem_unlock(sma, - 1)
1626  out_unlock1 :
1627  _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()
1628  out_up :
1629  lease a write lock
1630  Return err
Caller
NameDescribe
ksys_semctl
compat_ksys_semctl