函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Fix shmaddr, allocate descriptor, map shm, add attach descriptor to lists.* NOTE! Despite the name, this is NOT a direct system call entrypoint. The* "raddr" thing points to kernel space, and there has to be a wrapper around* this.

函数原型:long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr, unsigned long shmlba)

返回类型:long

参数:

类型参数名称
intshmid
char __user *shmaddr
intshmflg
ulong *raddr
unsigned longshmlba
1422  addr等于shmaddr
1426  flags等于Share changes
1432  populate等于0
1434  err等于负EINVAL
1435  如果shmid小于0则转到:out
1438  如果addr
1439  如果addr按位与shmlba减1则
1441  addr与等于shmlba减1的差的反
1448  如果非addrshmflg按位与ake-over region on attach 则转到:out
1450  否则如果addr按位与PAGE_MASK的反则
1454  转到:out
1457  flags或等于Interpret addr exactly
1458  否则如果shmflg按位与ake-over region on attach 则转到:out
1461  如果shmflg按位与ad-only access
1462  prot等于page can be read
1463  acc_mode等于S_IRUGO
1464  f_flags等于O_RDONLY
1465  否则
1466  prot等于page can be read 按位或page can be written
1467  acc_mode等于S_IRUGO按位或S_IWUGO
1468  f_flags等于O_RDWR
1470  如果shmflg按位与xecution access
1471  prot或等于page can be executed
1472  acc_mode或等于S_IXUGO
1479  ns等于ipc_ns
1480  _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
1481  shp等于shm_obtain_object_check(ns, shmid)
1482  如果是错误
1483  err等于错误
1484  转到:out_unlock
1487  err等于负EACCES
1488  如果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_unlock
1491  err等于security_shm_shmat( & shm_perm, shmaddr, shmflg)
1492  如果err则转到:out_unlock
1495  ipc_lock_object( & shm_perm)
1498  如果非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
1499  ipc_unlock_object( & shm_perm)
1500  err等于负EIDRM
1501  转到:out_unlock
1513  base等于get_file(shm_file)
1514  shm_nattch自加
1515  size等于NOTE: in a 32bit arch with a preemptable kernel and* an UP compile the i_size_read/write must be atomic* with respect to the local cpu (unlike with preempt disabled),* but they don't need to be atomic with respect to other cpus like in* true SMP (so they
1516  ipc_unlock_object( & shm_perm)
1517  _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()
1519  err等于负ENOMEM
1520  sfd等于分配内存并置零
1521  如果非sfd
1522  fput(base)
1523  转到:out_nattch
1526  file等于alloc_file_clone(base, f_flags, is_file_hugepages(base) ? & shm_file_operations_huge is now identical to shm_file_operations,* but we keep it distinct for the sake of is_file_shm_hugepages(). : & shm_file_operations)
1530  err等于错误
1531  如果是错误
1532  释放内存
1533  fput(base)
1534  转到:out_nattch
1537  id等于id
1538  ns等于get_ipc_ns(ns)
1539  file等于base
1540  vm_ops = NULL
1541  needed for tty driver, and maybe others 等于sfd
1543  err等于security_mmap_file(file, prot, flags)
1544  如果err则转到:out_fput
1547  如果lock for writing
1548  err等于负EINTR
1549  转到:out_fput
1552  如果addr且非shmflg按位与ake-over region on attach 的值则
1553  err等于负EINVAL
1554  如果addrsize小于addr则转到:invalid
1557  如果Look up the first VMA which intersects the interval start_addr..end_addr-1,NULL if none. Assume start_addr < end_addr. 则转到:invalid
1561  addr等于do_mmap_pgoff(file, addr, size, prot, flags, 0, & populate, NULL)
1562  raddr等于addr
1563  err等于0
1564  如果IS_ERR_VALUE(addr)则err等于addr
1566  invalid :
1567  lease a write lock
1568  如果populatemm_populate(addr, populate)
1571  out_fput :
1572  fput(file)
1574  out_nattch :
1575  lock for writing
1576  shp等于shm_lock_(check_) routines are called in the paths where the rwsem* is not necessarily held.
1577  shm_nattch自减
1578  如果shm_may_destroy - identifies whether shm segment should be destroyed now* Returns true if and only if there are no active users of the segment and* one of the following is true:* 1) shmctl(id, IPC_RMID, NULL) was called for this shp* 2) sysctl kernelshm_destroy(ns, shp)
1580  否则shm_unlock(shp)
1582  lease a write lock
1583  返回:err
1585  out_unlock :
1586  _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()
1587  out :
1588  返回:err
调用者
名称描述
SYSCALL_DEFINE3
COMPAT_SYSCALL_DEFINE3
ksys_ipc