Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:'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.

Proto:static int copy_strings(int argc, struct user_arg_ptr argv, struct linux_binprm *bprm)

Type:int

Parameter:

TypeParameterName
intargc
struct user_arg_ptrargv
struct linux_binprm *bprm
502  struct page * kmapped_page = NULL
503  char * kaddr = NULL
504  kpos = 0
507  When argc-- > 0 cycle
508  __user * str
512  ret = -EFAULT
513  str = get_user_arg_ptr(argv, argc)
514  If IS_ERR(str) Then Go to out
517  len = Get the size of a string in user space
518  If Not len Then Go to out
521  ret = -E2BIG
522  If Not valid_arg_len(bprm, len) Then Go to out
526  pos = p
527  str += len
528  p -= len
530  If p < argmin Then Go to out
534  When len > 0 cycle
539  Go to out
541  cond_resched()
543  offset = pos % PAGE_SIZE
544  If offset == 0 Then offset = PAGE_SIZE
548  If bytes_to_copy > len Then bytes_to_copy = len
552  pos -= bytes_to_copy
553  str -= bytes_to_copy
554  len -= bytes_to_copy
556  If Not kmapped_page || kpos != (pos & PAGE_MASK) Then
559  page = get_arg_page(bprm, pos, 1)
560  If Not page Then
561  ret = -E2BIG
562  Go to out
565  If kmapped_page Then
570  kmapped_page = page
572  kpos = pos & PAGE_MASK
576  ret = -EFAULT
577  Go to out
581  ret = 0
582  out :
583  If kmapped_page Then
584  flush_kernel_dcache_page(kmapped_page)
585  kunmap(kmapped_page)
586  put_arg_page(kmapped_page)
588  Return ret
Caller
NameDescribe
copy_strings_kernelLike copy_strings, but get argv and its values from kernel memory.
__do_execve_filesys_execve() executes a new program.