函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:The caller must hold down_write(&current->mm->mmap_sem).

函数原型:unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate, struct list_head *uf)

返回类型:unsigned long

参数:

类型参数名称
struct file *file
unsigned longaddr
unsigned longlen
unsigned longprot
unsigned longflags
vm_flags_tvm_flags
unsigned longpgoff
unsigned long *populate
struct list_head *uf
1373  mm等于mm
1374  pkey等于0
1376  populate等于0
1378  如果非len则返回:负EINVAL
1387  如果prot按位与page can be read personality按位与READ_IMPLIES_EXEC则如果非filepath_noexec( & f_path)的值则
1389  prot或等于page can be executed
1392  如果flags按位与MAP_FIXED which doesn't unmap underlying mapping flags或等于Interpret addr exactly
1395  如果非flags按位与Interpret addr exactly 的值则addr等于If a hint addr is less than mmap_min_addr change hint to be as* low as possible but still greater than mmap_min_addr
1399  len等于 align the pointer to the (next) page boundary (len)
1400  如果非len则返回:负ENOMEM
1404  如果pgofflen右移PAGE_SHIFT determines the page size 位的值小于pgoff则返回:负EOVERFLOW
1408  如果 number of VMAs 大于sysctl_max_map_count则返回:负ENOMEM
1414  addr等于get_unmapped_area(file, addr, len, pgoff, flags)
1415  如果IS_ERR_VALUE(addr)则返回:addr
1418  如果flags按位与MAP_FIXED which doesn't unmap underlying mapping
1419  vma等于Look up the first VMA which satisfies addr < vm_end, NULL if none.
1421  如果vmaOur start address within vm_mm. 小于addrlen则返回:负EEXIST
1425  如果prot恒等于page can be executed
1426  pkey等于execute_only_pkey(mm)
1427  如果pkey小于0则pkey等于0
1435  vm_flags或等于Combine the mmap "prot" argument into "vm_flags" used internally.按位或Combine the mmap "flags" argument into "vm_flags" used internally.按位或def_flags按位或limits for mprotect() etc 按位或VM_MAYWRITE按位或VM_MAYEXEC
1438  如果flags按位与pages are locked 则如果非can_do_mlock()则
1440  返回:负EPERM
1442  如果mlock_future_check(mm, vm_flags, len)则返回:负EAGAIN
1445  如果file
1446  inode等于file_inode(file)
1449  如果非file_mmap_ok(file, inode, pgoff, len)则返回:负EOVERFLOW
1452  flags_mask等于The historical set of flags that all mmap implementations implicitly* support when a ->mmap_validate() op is not provided in file_operations.按位或mmap_supported_flags
1455  : & == Share changes
1466  如果flags按位与flags_mask的反则返回:负EOPNOTSUPP
1468  如果prot按位与page can be written
1469  如果非f_mode按位与le is open for writing 的值则返回:负EACCES
1471  如果IS_SWAPFILE(host)则返回:负ETXTBSY
1479  如果IS_APPEND(inode)且f_mode按位与le is open for writing 则返回:负EACCES
1485  如果locks_verify_locked(file)则返回:负EAGAIN
1488  vm_flags或等于VM_SHARED按位或VM_MAYSHARE
1489  如果非f_mode按位与le is open for writing 的值则vm_flags与等于VM_MAYWRITE按位或VM_SHARED的值的反
1494  如果非f_mode按位与le is open for reading 的值则返回:负EACCES
1496  如果path_noexec( & f_path)则
1497  如果vm_flags按位与VM_EXEC则返回:负EPERM
1499  vm_flags与等于VM_MAYEXEC的反
1502  如果非mmap则返回:负ENODEV
1504  如果vm_flags按位与general info on the segment 按位或VM_GROWSUP的值则返回:负EINVAL
1506  退出
1508  默认
1509  返回:负EINVAL
1511  否则
1513  : & == Share changes
1514  如果vm_flags按位与general info on the segment 按位或VM_GROWSUP的值则返回:负EINVAL
1519  pgoff等于0
1520  vm_flags或等于VM_SHARED按位或VM_MAYSHARE
1521  退出
1527  退出
1528  默认
1529  返回:负EINVAL
1537  如果flags按位与don't check for reservations
1539  如果sysctl_overcommit_memory不等于OVERCOMMIT_NEVERvm_flags或等于should the VM suppress accounting
1543  如果fileis_file_hugepages(file)则vm_flags或等于should the VM suppress accounting
1547  addr等于mmap_region(file, addr, len, vm_flags, pgoff, uf)
1548  如果非IS_ERR_VALUE(addr)且vm_flags按位与VM_LOCKEDflags按位与populate (prefault) pagetables 按位或do not block on IO 的值的值恒等于populate (prefault) pagetables 的值则populate等于len
1552  返回:addr
调用者
名称描述
do_mmap_pgoff