函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\exec.c Create Date:2022-07-29 10:33:53
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:sys_execve() executes a new program.

函数原型:static int __do_execve_file(int fd, struct filename *filename, struct user_arg_ptr argv, struct user_arg_ptr envp, int flags, struct file *file)

返回类型:int

参数:

类型参数名称
intfd
struct filename *filename
struct user_arg_ptrargv
struct user_arg_ptrenvp
intflags
struct file *file
1720  char * pathbuf = NULL
1725  如果是错误则返回:错误
1734  如果flags按位与超出限制atomic_read( & processes)大于rlimit(RLIMIT_NPROC)则
1736  retval等于负EAGAIN
1737  转到:out_ret
1742  flags与等于超出限制的反
1744  retval等于Helper to unshare the files of the current task.* We don't want to expose copy_files internals to* the exec layer of the kernel.
1745  如果retval则转到:out_ret
1748  retval等于负ENOMEM
1749  bprm等于分配内存并置零
1750  如果非bprm则转到:out_files
1753  retval等于Prepare credentials and lock ->cred_guard_mutex.* install_exec_creds() commits the new creds and drops the lock.* Or, if exec fails before, free_bprm() should release ->cred and* and unlock.
1754  如果retval则转到:out_free
1757  determine how safe it is to execute the proposed program* - the caller must hold ->cred_guard_mutex to protect against* PTRACE_ATTACH or seccomp thread-sync
1758  in_execve等于1
1760  如果非filefile等于do_open_execat(fd, filename, flags)
1762  retval等于错误
1763  如果是错误则转到:out_unmark
1768  file等于file
1769  如果非filename
1770  filename等于"none"
1771  否则如果fd恒等于Special value used to indicateopenat should use the currentworking directory. pointer to actual string [0]恒等于'/'则
1772  filename等于 pointer to actual string
1773  否则
1774  如果 pointer to actual string [0]恒等于'\0'则pathbuf等于kasprintf(GFP_KERNEL, "/dev/fd/%d", fd)
1776  否则pathbuf等于kasprintf(GFP_KERNEL, "/dev/fd/%d/%s", fd, pointer to actual string )
1779  如果非pathbuf
1780  retval等于负ENOMEM
1781  转到:out_unmark
1788  如果close_on_exec(fd, Dependency order vs. p above. (fdt))则interp_flags或等于BINPRM_FLAGS_PATH_INACCESSIBLE
1790  filename等于pathbuf
1792  interp等于filename
1794  retval等于Create a new mm_struct and populate it with a temporary stack* vm_area_struct. We don't have enough context at this point to set the stack* flags, permissions, and offset, so we use temporary values. We'll update* them later in setup_arg_pages().
1795  如果retval则转到:out_unmark
1798  retval等于prepare_arg_pages(bprm, argv, envp)
1799  如果retval小于0则转到:out
1802  retval等于Fill the binprm structure from the inode.* Check permissions, then read the first BINPRM_BUF_SIZE bytes* This may be called multiple times for binary chains (scripts for example).
1803  如果retval小于0则转到:out
1806  retval等于Like copy_strings, but get argv and its values from kernel memory.
1807  如果retval小于0则转到:out
1810  exec等于p
1811  retval等于'copy_strings()' copies argument/environment strings from the old* processes's memory to the new process's stack. The call to get_user_pages()* ensures the destination page is created and not swapped out.
1812  如果retval小于0则转到:out
1815  retval等于'copy_strings()' copies argument/environment strings from the old* processes's memory to the new process's stack. The call to get_user_pages()* ensures the destination page is created and not swapped out.
1816  如果retval小于0则转到:out
1819  would_dump(bprm, file)
1821  retval等于exec_binprm(bprm)
1822  如果retval小于0则转到:out
1826  in_exec等于0
1827  in_execve等于0
1828  rseq_execve(当前进程)
1829  acct_update_integrals(当前进程)
1830  task_numa_free(当前进程, false)
1831  free_bprm(bprm)
1832  释放内存
1833  如果filenameputname(filename)
1835  如果displacedput_files_struct(displaced)
1837  返回:retval
1839  out :
1840  如果mm
1841  The nascent bprm->mm is not visible until exec_mmap() but it can* use a lot of memory, account these pages in current->mm temporary* for oom_badness()->get_mm_rss(). Once exec succeeds or fails, we* change the counter back via acct_arg_size(0).
1842  Decrement the use count and release all resources for an mm.
1845  out_unmark :
1846  in_exec等于0
1847  in_execve等于0
1849  out_free :
1850  free_bprm(bprm)
1851  释放内存
1853  out_files :
1854  如果displacedreset_files_struct(displaced)
1856  out_ret :
1857  如果filenameputname(filename)
1859  返回:retval
调用者
名称描述
do_execveat_common
do_execve_file