Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\exec.c Create Date:2022-07-28 20:03:56
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Finalizes the stack vm_area_struct. The flags and permissions are updated,* the stack is optionally relocated, and some extra space is added.

Proto:int setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, int executable_stack)

Type:int

Parameter:

TypeParameterName
struct linux_binprm *bprm
unsigned longstack_top
intexecutable_stack
696  mm = mm
697  vma = vma
698  struct vm_area_struct * prev = NULL
724  stack_top = arch_align_stack(stack_top)
725  stack_top = align the pointer to the (next) page boundary (stack_top)
727  If Value for the false possibility is greater at compile time(stack_top < mmap_min_addr) || Value for the false possibility is greater at compile time(The first byte after our end addresswithin vm_mm. - Our start address within vm_mm. >= stack_top - mmap_min_addr) Then Return -ENOMEM
731  stack_shift = The first byte after our end addresswithin vm_mm. - stack_top
733  p -= stack_shift
734  arg_start = p
737  If loader Then loader -= stack_shift
739  exec -= stack_shift
741  If lock for writing Then Return -EINTR
744  vm_flags = VM_STACK_FLAGS
751  If Value for the false possibility is greater at compile time(executable_stack == Enable executable stacks ) Then vm_flags |= VM_EXEC
753  Else if executable_stack == Disable executable stacks Then vm_flags &= ~VM_EXEC
755  vm_flags |= def_flags
756  vm_flags |= Bits set in the VMA until the stack is in its final location
758  ret = mprotect_fixup(vma, & prev, Our start address within vm_mm. , The first byte after our end addresswithin vm_mm. , vm_flags)
760  If ret Then Go to out_unlock
762  BUG_ON(prev != vma)
765  If stack_shift Then
766  ret = During bprm_mm_init(), we create a temporary stack at STACK_TOP_MAX. Once* the binfmt code determines where the new stack should reside, we shift it to* its final location. The process proceeds as follows:* 1) Use shift to calculate the new vma endpoints.
767  If ret Then Go to out_unlock
772  Flags, see mm.h. &= ~Bits set in the VMA until the stack is in its final location
774  stack_expand = 131072UL
775  stack_size = The first byte after our end addresswithin vm_mm. - Our start address within vm_mm.
780  rlim_stack = rlim_cur & PAGE_MASK
787  If stack_size + stack_expand > rlim_stack Then stack_base = The first byte after our end addresswithin vm_mm. - rlim_stack
789  Else stack_base = Our start address within vm_mm. - stack_expand
792  start_stack = p
793  ret = xpand a stack to a given address* - not supported under NOMMU conditions
794  If ret Then ret = -EFAULT
797  out_unlock :
798  lease a write lock
799  Return ret
Caller
NameDescribe
load_aout_binaryThese are the functions used to load a.out style executables and shared* libraries. There is no binary dependent code anywhere else.
load_elf_binary
load_elf_fdpic_binaryload an fdpic binary into various bits of memory
load_flat_binaryThese are the functions used to load flat style executables and shared* libraries. There is no binary dependent code anywhere else.